diff options
Diffstat (limited to 'lib/rubygems/command.rb')
| -rw-r--r-- | lib/rubygems/command.rb | 53 |
1 files changed, 24 insertions, 29 deletions
diff --git a/lib/rubygems/command.rb b/lib/rubygems/command.rb index ce057af440..d38363f293 100644 --- a/lib/rubygems/command.rb +++ b/lib/rubygems/command.rb @@ -1,11 +1,12 @@ # frozen_string_literal: true + #-- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others. # All rights reserved. # See LICENSE.txt for permissions. #++ -require_relative "optparse" +require_relative "vendored_optparse" require_relative "requirement" require_relative "user_interaction" @@ -19,9 +20,7 @@ require_relative "user_interaction" class Gem::Command include Gem::UserInteraction - Gem::OptionParser.accept Symbol do |value| - value.to_sym - end + Gem::OptionParser.accept Symbol, &:to_sym ## # The name of the command. @@ -118,7 +117,7 @@ class Gem::Command # Unhandled arguments (gem names, files, etc.) are left in # <tt>options[:args]</tt>. - def initialize(command, summary=nil, defaults={}) + def initialize(command, summary = nil, defaults = {}) @command = command @summary = summary @program_name = "gem #{command}" @@ -191,7 +190,7 @@ class Gem::Command "Please specify at least one gem name (e.g. gem build GEMNAME)" end - args.select {|arg| arg !~ /^-/ } + args.reject {|arg| arg.start_with?("-") } end ## @@ -315,7 +314,7 @@ class Gem::Command options[:build_args] = build_args if options[:silent] - old_ui = self.ui + old_ui = ui self.ui = ui = Gem::SilentUI.new end @@ -397,22 +396,21 @@ class Gem::Command def check_deprecated_options(options) options.each do |option| - if option_is_deprecated?(option) - deprecation = @deprecated_options[command][option] - version_to_expire = deprecation["rg_version_to_expire"] + next unless option_is_deprecated?(option) + deprecation = @deprecated_options[command][option] + version_to_expire = deprecation["rg_version_to_expire"] - deprecate_option_msg = if version_to_expire - "The \"#{option}\" option has been deprecated and will be removed in Rubygems #{version_to_expire}." - else - "The \"#{option}\" option has been deprecated and will be removed in future versions of Rubygems." - end + deprecate_option_msg = if version_to_expire + "The \"#{option}\" option has been deprecated and will be removed in Rubygems #{version_to_expire}." + else + "The \"#{option}\" option has been deprecated and will be removed in future versions of Rubygems." + end - extra_msg = deprecation["extra_msg"] + extra_msg = deprecation["extra_msg"] - deprecate_option_msg += " #{extra_msg}" if extra_msg + deprecate_option_msg += " #{extra_msg}" if extra_msg - alert_warning(deprecate_option_msg) - end + alert_warning(deprecate_option_msg) end end @@ -430,9 +428,9 @@ class Gem::Command def handles?(args) parser.parse!(args.dup) - return true + true rescue StandardError - return false + false end ## @@ -459,7 +457,7 @@ class Gem::Command until extra.empty? do ex = [] ex << extra.shift - ex << extra.shift if extra.first.to_s =~ /^[^-]/ + ex << extra.shift if /^[^-]/.match?(extra.first.to_s) result << ex if handles?(ex) end @@ -487,7 +485,7 @@ class Gem::Command @parser.separator nil @parser.separator " Description:" - formatted.split("\n").each do |line| + formatted.each_line do |line| @parser.separator " #{line.rstrip}" end end @@ -514,8 +512,8 @@ class Gem::Command @parser.separator nil @parser.separator " #{title}:" - content.split(/\n/).each do |line| - @parser.separator " #{line}" + content.each_line do |line| + @parser.separator " #{line.rstrip}" end end @@ -524,7 +522,7 @@ class Gem::Command @parser.separator nil @parser.separator " Summary:" - wrap(@summary, 80 - 4).split("\n").each do |line| + wrap(@summary, 80 - 4).each_line do |line| @parser.separator " #{line.strip}" end end @@ -652,9 +650,6 @@ RubyGems is a package manager for Ruby. gem help platforms gem platforms guide gem help <COMMAND> show help on COMMAND (e.g. 'gem help install') - gem server present a web page at - http://localhost:8808/ - with info about installed gems Further information: https://guides.rubygems.org HELP |
