Class: YARD::Server::Adapter Abstract
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Subclasses:
|
|
Inherits: | Object |
Defined in: | lib/yard/server/adapter.rb |
Overview
This class implements the bridge between the Router
and the server
backend for a specific server type. ::YARD
implements concrete adapters
for WEBrick and Rack respectively, though other adapters can be made
for other server architectures.
Subclassing Notes
To create a concrete adapter class, implement the #start method to initiate the server backend.
Class Method Summary
-
.new(libs, opts = {}, server_opts = {}) ⇒ Adapter
constructor
Creates a new adapter object.
-
.setup ⇒ void
Performs any global initialization for the adapter.
-
.shutdown ⇒ void
Performs any global shutdown procedures for the adapter.
Instance Attribute Summary
Instance Method Summary
-
#add_library(library)
Adds a library to the #libraries mapping for a given library object.
-
#start
abstract
Implement this method to connect your adapter to your server.
Constructor Details
.new(libs, opts = {}, server_opts = {}) ⇒ Adapter
Creates a new adapter object
# File 'lib/yard/server/adapter.rb', line 71
def initialize(libs, opts = {}, server_opts = {}) self.class.setup self.libraries = libs self. = opts self. = server_opts self.document_root = [:DocumentRoot] self.router = ( [:router] || Router).new(self) [:adapter] = self log.debug "Serving libraries using #{self.class}: #{libraries.keys.join(', ')}" log.debug "Caching on" if [:caching] log.debug "Document root: #{document_root}" if document_root end
Class Method Details
.setup ⇒ void
If you subclass this method, make sure to call super
.
This method returns an undefined value.
Performs any global initialization for the adapter.
# File 'lib/yard/server/adapter.rb', line 48
def self.setup Templates::Template.extra_includes |= [YARD::Server::DocServerHelper] Templates::Engine.template_paths |= [File.dirname(__FILE__) + '/templates'] end
.shutdown ⇒ void
If you subclass this method, make sure to call super
.
This method returns an undefined value.
Performs any global shutdown procedures for the adapter.
# File 'lib/yard/server/adapter.rb', line 56
def self.shutdown Templates::Template.extra_includes -= [YARD::Server::DocServerHelper] Templates::Engine.template_paths -= [File.dirname(__FILE__) + '/templates'] end
Instance Attribute Details
#document_root ⇒ String (rw)
# File 'lib/yard/server/adapter.rb', line 27
attr_accessor :document_root
#libraries ⇒ Hash{String=>Array<LibraryVersion>} (rw)
# File 'lib/yard/server/adapter.rb', line 32
attr_accessor :libraries
#options ⇒ Hash (rw)
# File 'lib/yard/server/adapter.rb', line 36
attr_accessor :
#router ⇒ Router (rw)
# File 'lib/yard/server/adapter.rb', line 43
attr_accessor :router
#server_options ⇒ Hash (rw)
# File 'lib/yard/server/adapter.rb', line 40
attr_accessor :
Instance Method Details
#add_library(library)
Adds a library to the #libraries mapping for a given library object.
#start
Implement this method to connect your adapter to your server.
# File 'lib/yard/server/adapter.rb', line 95
def start raise NotImplementedError end