# frozen_string_literal: false require 'webrick' require 'zlib' require 'erb' require 'rubygems' require 'rubygems/rdoc' ## # Gem::Server and allows users to serve gems for consumption by # `gem --remote-install`. # # gem_server starts an HTTP server on the given port and serves the following: # * "/" - Browsing of gem spec files for installed gems # * "/specs.#{Gem.marshal_version}.gz" - specs name/version/platform index # * "/latest_specs.#{Gem.marshal_version}.gz" - latest specs # name/version/platform index # * "/quick/" - Individual gemspecs # * "/gems" - Direct access to download the installable gems # * "/rdoc?q=" - Search for installed rdoc documentation # # == Usage # # gem_server = Gem::Server.new Gem.dir, 8089, false # gem_server.run # #-- # TODO Refactor into a real WEBrick servlet to remove code duplication. class Gem::Server attr_reader :spec_dirs include ERB::Util include Gem::UserInteraction SEARCH = <<-SEARCH
SEARCH DOC_TEMPLATE = <<-'DOC_TEMPLATE'There are <%=values["gem_count"]%> gems installed:
<%= values["specs"].map { |v| "#{v["name"]}" }.join ', ' %>.
No gems matched <%= h query.inspect %>
Back to complete gem index
<%=doc_items.length%> documentation topics found.
Back to complete gem index