Class: YARD::Server::Adapter

Inherits:
Object
  • Object
show all
Defined in:
lib/yard/server/adapter.rb

Overview

Since:

  • 0.6.0

Direct Known Subclasses

RackAdapter, WebrickAdapter

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(libs, opts = {}, server_opts = {}) ⇒ Adapter

Returns a new instance of Adapter.

Since:

  • 0.6.0



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/yard/server/adapter.rb', line 28

def initialize(libs, opts = {}, server_opts = {})
  self.class.setup
  self.libraries = libs
  self.options = opts
  self.server_options = server_opts
  self.document_root = server_options[:DocumentRoot]
  self.router = (options[:router] || Router).new(self)
  options[:adapter] = self
  log.debug "Serving libraries using #{self.class}: #{libraries.keys.join(', ')}"
  log.debug "Caching on" if options[:caching]
  log.debug "Document root: #{document_root}" if document_root
end

Instance Attribute Details

#document_rootString

Returns the location where static files are located, if any.

Returns:

  • (String)

    the location where static files are located, if any

Since:

  • 0.6.0



8
9
10
# File 'lib/yard/server/adapter.rb', line 8

def document_root
  @document_root
end

#librariesObject

Since:

  • 0.6.0



10
11
12
# File 'lib/yard/server/adapter.rb', line 10

def libraries
  @libraries
end

#optionsObject

Since:

  • 0.6.0



12
13
14
# File 'lib/yard/server/adapter.rb', line 12

def options
  @options
end

#routerObject

Since:

  • 0.6.0



16
17
18
# File 'lib/yard/server/adapter.rb', line 16

def router
  @router
end

#server_optionsObject

Since:

  • 0.6.0



14
15
16
# File 'lib/yard/server/adapter.rb', line 14

def server_options
  @server_options
end

Class Method Details

.setupObject

Since:

  • 0.6.0



18
19
20
21
# File 'lib/yard/server/adapter.rb', line 18

def self.setup
  Templates::Template.extra_includes |= [YARD::Server::DocServerHelper]
  Templates::Engine.template_paths |= [File.dirname(__FILE__) + '/templates']
end

.shutdownObject

Since:

  • 0.6.0



23
24
25
26
# File 'lib/yard/server/adapter.rb', line 23

def self.shutdown
  Templates::Template.extra_includes -= [YARD::Server::DocServerHelper]
  Templates::Engine.template_paths -= [File.dirname(__FILE__) + '/templates']
end

Instance Method Details

#add_library(library) ⇒ Object

Since:

  • 0.6.0



41
42
43
44
# File 'lib/yard/server/adapter.rb', line 41

def add_library(library)
  libraries[library.name] ||= []
  libraries[library.name] |= [library]
end

#startObject

Raises:

  • (NotImplementedError)

Since:

  • 0.6.0



46
47
48
# File 'lib/yard/server/adapter.rb', line 46

def start
  raise NotImplementedError
end