Method: YARD::Server::Router#parse_library_from_path

Defined in:
lib/yard/server/router.rb

#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.

Returns:

  • (Array(LibraryVersion, Array<String>))

    the library followed by the rest of the path components in the request path. LibraryVersion will be nil if no matching library was found.

Since:

  • 0.6.0



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/yard/server/router.rb', line 77

def parse_library_from_path(paths)
  return [adapter.libraries.values.first.first, paths] if adapter.options[:single_library]
  library, paths = nil, paths.dup
  if libs = adapter.libraries[paths.first]
    paths.shift
    if library = libs.find {|l| l.version == paths.first }
      request.version_supplied = true if request
      paths.shift
    else # use the last lib in the list
      request.version_supplied = false if request
      library = libs.last
    end
  end
  [library, paths]
end