lib/yard/server/router.rb in yard-0.7.5 vs lib/yard/server/router.rb in yard-0.8.0

- old
+ new

@@ -46,11 +46,11 @@ # Perform routing on a specific request, serving the request as a static # file through {Commands::StaticFileCommand} if no route is found. # # @param [Adapter Dependent] request the request object - # @return [Array(Number,Hash,Array)] the Rack-style server response data + # @return [Array(Numeric,Hash,Array)] the Rack-style server response data def call(request) self.request = request if result = (check_static_cache || route) result else @@ -95,12 +95,12 @@ # Performs routing algorithm to find which prefix is called, first # parsing out library name/version information. # # @return [Array(Numeric,Hash,Array<String>)] the Rack-style response # @return [nil] if no route is matched - def route - path = request.path.gsub(%r{//+}, '/').gsub(%r{^/|/$}, '') + 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('/') @@ -148,16 +148,10 @@ # Routes requests from {#list_prefix} and calls the appropriate command # @param (see #route_docs) # @return (see #route_docs) def route_list(library, paths) return if paths.empty? - case paths.shift - when "class"; cmd = ListClassesCommand - when "methods"; cmd = ListMethodsCommand - when "files"; cmd = ListFilesCommand - else; return - end - cmd.new(final_options(library, paths)).call(request) + ListCommand.new(final_options(library, paths)).call(request) end # Routes requests from {#search_prefix} and calls the appropriate command # @param (see #route_docs) # @return (see #route_docs)