Class: YARD::Server::Router
- Inherits:
-
Object
- Object
- YARD::Server::Router
- Includes:
- Commands, StaticCaching
- Defined in:
- lib/yard/server/router.rb
Overview
Instance Attribute Summary collapse
Instance Method Summary collapse
- #call(request) ⇒ Object
- #docs_prefix ⇒ Object
-
#initialize(adapter) ⇒ Router
constructor
A new instance of Router.
- #list_prefix ⇒ Object
-
#parse_library_from_path(paths) ⇒ Array(LibraryVersion, Array<String>)
The library followed by the rest of the path components in the request path.
- #search_prefix ⇒ Object
Methods included from StaticCaching
Constructor Details
#initialize(adapter) ⇒ Router
Returns a new instance of Router.
11 12 13 |
# File 'lib/yard/server/router.rb', line 11 def initialize(adapter) self.adapter = adapter end |
Instance Attribute Details
#adapter ⇒ Object
9 10 11 |
# File 'lib/yard/server/router.rb', line 9 def adapter @adapter end |
#request ⇒ Object
7 8 9 |
# File 'lib/yard/server/router.rb', line 7 def request @request end |
Instance Method Details
#call(request) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/yard/server/router.rb', line 15 def call(request) self.request = request if result = (check_static_cache || route) result else StaticFileCommand.new(adapter.).call(request) end end |
#docs_prefix ⇒ Object
24 |
# File 'lib/yard/server/router.rb', line 24 def docs_prefix; 'docs' end |
#list_prefix ⇒ Object
25 |
# File 'lib/yard/server/router.rb', line 25 def list_prefix; 'list' end |
#parse_library_from_path(paths) ⇒ Array(LibraryVersion, Array<String>)
Returns the library followed by the rest of the path components in the request path. LibraryVersion will be nil if no matching library was found.
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/yard/server/router.rb', line 31 def parse_library_from_path(paths) return [adapter.libraries.values.first.first, paths] if adapter.[:single_library] library, paths = nil, paths.dup if libs = adapter.libraries[paths.first] paths.shift if library = libs.find {|l| l.version == paths.first } paths.shift else # use the last lib in the list library = libs.last end end [library, paths] end |
#search_prefix ⇒ Object
26 |
# File 'lib/yard/server/router.rb', line 26 def search_prefix; 'search' end |