ruby-changes:69561
From: Hiroshi <ko1@a...>
Date: Tue, 2 Nov 2021 10:45:34 +0900 (JST)
Subject: [ruby-changes:69561] 4a39167260 (master): Removed the related code of `gem server`
https://git.ruby-lang.org/ruby.git/commit/?id=4a39167260 From 4a39167260fbd0e8accf42ef7dee27ae73159f8f Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA <hsbt@r...> Date: Thu, 28 Oct 2021 17:28:59 +0900 Subject: Removed the related code of `gem server` --- lib/rubygems/commands/server_command.rb | 91 +-- lib/rubygems/server.rb | 882 ---------------------- test/rubygems/test_gem_commands_server_command.rb | 50 +- test/rubygems/test_gem_server.rb | 608 --------------- 4 files changed, 18 insertions(+), 1613 deletions(-) delete mode 100644 lib/rubygems/server.rb delete mode 100644 test/rubygems/test_gem_server.rb diff --git a/lib/rubygems/commands/server_command.rb b/lib/rubygems/commands/server_command.rb index f3c08efb5eb..f8cad3b5db7 100644 --- a/lib/rubygems/commands/server_command.rb +++ b/lib/rubygems/commands/server_command.rb @@ -1,88 +1,25 @@ https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/server_command.rb#L1 # frozen_string_literal: true require_relative '../command' -require_relative '../server' -require_relative '../deprecate' -class Gem::Commands::ServerCommand < Gem::Command - extend Gem::Deprecate - rubygems_deprecate_command - - def initialize - super 'server', 'Documentation and gem repository HTTP server', - :port => 8808, :gemdir => [], :daemon => false - - OptionParser.accept :Port do |port| - if port =~ /\A\d+\z/ - port = Integer port - raise OptionParser::InvalidArgument, "#{port}: not a port number" if - port > 65535 - - port - else - begin - Socket.getservbyname port - rescue SocketError - raise OptionParser::InvalidArgument, "#{port}: no such named service" - end +unless defined? Gem::Commands::ServerCommand + class Gem::Commands::ServerCommand < Gem::Command + def initialize + super('server', 'Starts up a web server that hosts the RDoc (requires rubygems-server)') + begin + Gem::Specification.find_by_name('rubygems-server').activate + rescue Gem::LoadError + # no-op end end - add_option '-p', '--port=PORT', :Port, - 'port to listen on' do |port, options| - options[:port] = port - end - - add_option '-d', '--dir=GEMDIR', - 'directories from which to serve gems', - 'multiple directories may be provided' do |gemdir, options| - options[:gemdir] << File.expand_path(gemdir) + def description # :nodoc: + <<-EOF +The server command has been moved to the rubygems-server gem. + EOF end - add_option '--[no-]daemon', 'run as a daemon' do |daemon, options| - options[:daemon] = daemon + def execute + alert_error "Install the rubygems-server gem for the server command" end - - add_option '-b', '--bind=HOST,HOST', - 'addresses to bind', Array do |address, options| - options[:addresses] ||= [] - options[:addresses].push(*address) - end - - add_option '-l', '--launch[=COMMAND]', - 'launches a browser window', - "COMMAND defaults to 'start' on Windows", - "and 'open' on all other platforms" do |launch, options| - launch ||= Gem.win_platform? ? 'start' : 'open' - options[:launch] = launch - end - end - - def defaults_str # :nodoc: - "--port 8808 --dir #{Gem.dir} --no-daemon" - end - - def description # :nodoc: - <<-EOF -The server command starts up a web server that hosts the RDoc for your -installed gems and can operate as a server for installation of gems on other -machines. - -The cache files for installed gems must exist to use the server as a source -for gem installation. - -To install gems from a running server, use `gem install GEMNAME --source -http://gem_server_host:8808` - -You can set up a shortcut to gem server documentation using the URL: - - http://localhost:8808/rdoc?q=%s - Firefox - http://localhost:8808/rdoc?q=* - LaunchBar - - EOF - end - - def execute - options[:gemdir] = Gem.path if options[:gemdir].empty? - Gem::Server.run options end end diff --git a/lib/rubygems/server.rb b/lib/rubygems/server.rb deleted file mode 100644 index 45be05bcda7..00000000000 --- a/lib/rubygems/server.rb +++ /dev/null @@ -1,882 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/server_command.rb#L0 -# frozen_string_literal: true -require 'zlib' -require 'erb' -require 'uri' - -require_relative '../rubygems' -require_relative '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 = <<-ERB.freeze - <form class="headerSearch" name="headerSearchForm" method="get" action="/rdoc"> - <div id="search" style="float:right"> - <label for="q">Filter/Search</label> - <input id="q" type="text" style="width:10em" name="q"> - <button type="submit" style="display:none"></button> - </div> - </form> - ERB - - DOC_TEMPLATE = <<-'ERB'.freeze - <?xml version="1.0" encoding="iso-8859-1"?> - <!DOCTYPE html - PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> - - <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> - <head> - <title>RubyGems Documentation Index</title> - <link rel="stylesheet" href="gem-server-rdoc-style.css" type="text/css" media="screen" /> - </head> - <body> - <div id="fileHeader"> -<%= SEARCH %> - <h1>RubyGems Documentation Index</h1> - </div> - <!-- banner header --> - - <div id="bodyContent"> - <div id="contextContent"> - <div id="description"> - <h1>Summary</h1> - <p>There are <%=values["gem_count"]%> gems installed:</p> - <p> - <%= values["specs"].map { |v| "<a href=\"##{u v["name"]}\">#{h v["name"]}</a>" }.join ', ' %>. - <h1>Gems</h1> - - <dl> - <% values["specs"].each do |spec| %> - <dt> - <% if spec["first_name_entry"] then %> - <a name="<%=h spec["name"]%>"></a> - <% end %> - - <b><%=h spec["name"]%> <%=h spec["version"]%></b> - - <% if spec["ri_installed"] || spec["rdoc_installed"] then %> - <a href="<%=spec["doc_path"]%>">[rdoc]</a> - <% else %> - <span title="rdoc not installed">[rdoc]</span> - <% end %> - - <% if spec["homepage"] then %> - <a href="<%=uri_encode spec["homepage"]%>" title="<%=h spec["homepage"]%>">[www]</a> - <% else %> - <span title="no homepage available">[www]</span> - <% end %> - - <% if spec["has_deps"] then %> - - depends on - <%= spec["dependencies"].map { |v| "<a href=\"##{u v["name"]}\">#{h v["name"]}</a>" }.join ', ' %>. - <% end %> - </dt> - <dd> - <%=spec["summary"]%> - <% if spec["executables"] then %> - <br/> - - <% if spec["only_one_executable"] then %> - Executable is - <% else %> - Executables are - <%end%> - - <%= spec["executables"].map { |v| "<span class=\"context-item-name\">#{h v["executable"]}</span>"}.join ', ' %>. - - <%end%> - <br/> - <br/> - </dd> - <% end %> - </dl> - - </div> - </div> - </div> - <div id="validator-badges"> - <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p> - </div> - </body> - </html> - ERB - - # CSS is copy & paste from rdoc-style.css, RDoc V1.0.1 - 20041108 - RDOC_CSS = <<-CSS.freeze -body { - font-family: Verdana,Arial,Helvetica,sans-serif; - font-size: 90%; - margin: 0; - margin-left: 40px; - padding: 0; - background: white; -} - -h1,h2,h3,h4 { margin: 0; color: #efefef; background: transparent; } -h1 { font-size: 150%; } -h2,h3,h4 { margin-top: 1em; } - -a { background: #eef; color: #039; text-decoration: none; } -a:hover { background: #039; color: #eef; } - -/* Override the base stylesheets Anchor inside a table cell */ -td > a { - background: transparent; - color: #039; - text-decoration: none; -} - -/* and inside a section title */ -.section-title > a { - background: transparent; - color: #eee; - text-decoration: none; -} - -/* === Structural elements =================================== */ - -div#index { - margin: 0; - margin-left: -40px; - padding: 0; - font-size: 90%; -} - - -div#index a { - margin-left: 0.7em; -} - -div#index .section-bar { - margin-left: 0px; - padding-left: 0.7em; - background: #ccc; - font-size: small; -} - - -div#classHeader, div#fileHeader { - width: auto; - color: white; - padding: 0.5em 1.5em 0.5em 1.5em; - margin: 0; - margin-left: -40px; - border-bottom: 3px solid #006; -} - -div#classHeader a, div#fileHeader a { - background: inherit; - color: white; -} - -div#classHeader td, div#fileHeader td { - background: inherit; - color: white; -} - - -div#fileHeader { - background: #057; -} - -div#classHeader { - background: #048; -} - - -.class-name-in-header { - font-size: 180%; - font-weight: bold; -} - - -div#bodyContent { - padding: 0 1.5em 0 1.5em; -} - -div#description { - padding: 0.5em 1.5em; - background: #efefef; - border: 1px dotted #999; -} - -div#description h1,h2,h3,h4,h5,h6 { - color: #125;; - background: transparent; -} (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/