Method: YARD::Server::Router#route

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

#route(path = request.path) ⇒ Array(Numeric,Hash,Array<String>)? (protected)

Performs routing algorithm to find which prefix is called, first parsing out library name/version information.

Returns:

Since:

  • 0.6.0


100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/yard/server/router.rb', line 100

def route(path = request.path)
  path = path.gsub(%r{//+}, '/').gsub(%r{^/|/$}, '')
  return route_index if path.empty? || path == docs_prefix
  case path
  when /^(#{docs_prefix}|#{list_prefix}|#{search_prefix})(\/.*|$)/
    prefix = $1
    paths = $2.gsub(%r{^/|/$}, '').split('/')
    library, paths = *parse_library_from_path(paths)
    return unless library
    return case prefix
    when docs_prefix;   route_docs(library, paths)
    when list_prefix;   route_list(library, paths)
    when search_prefix; route_search(library, paths)
    end
  end
  nil
end