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)
-
- (Object) adapter
Returns the value of attribute adapter.
-
- (Object) request
Returns the value of attribute request.
Instance Method Summary (collapse)
- - (Object) call(request)
- - (Object) docs_prefix
-
- (Router) initialize(adapter)
constructor
A new instance of Router.
- - (Object) list_prefix
-
- (Array(LibraryVersion, Array<String>)) parse_library_from_path(paths)
The library followed by the rest of the path components in the request path.
- - (Object) search_prefix
Methods included from StaticCaching
Constructor Details
- (Router) initialize(adapter)
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
- (Object) adapter
Returns the value of attribute adapter
9 10 11 |
# File 'lib/yard/server/router.rb', line 9 def adapter @adapter end |
- (Object) request
Returns the value of attribute request
7 8 9 |
# File 'lib/yard/server/router.rb', line 7 def request @request end |
Instance Method Details
- (Object) call(request)
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 |
- (Object) docs_prefix
24 |
# File 'lib/yard/server/router.rb', line 24 def docs_prefix; 'docs' end |
- (Object) list_prefix
25 |
# File 'lib/yard/server/router.rb', line 25 def list_prefix; 'list' end |
- (Array(LibraryVersion, Array<String>)) parse_library_from_path(paths)
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 |
- (Object) search_prefix
26 |
# File 'lib/yard/server/router.rb', line 26 def search_prefix; 'search' end |