Merge RubyGems-3.3.19 and Bundler-2.3.19

This commit is contained in:
Hiroshi SHIBATA 2022-08-22 11:49:38 +09:00 committed by nagachika
parent 0918783347
commit 44c926f3a9
362 changed files with 7843 additions and 7605 deletions

View file

@ -1,29 +1,29 @@
# frozen_string_literal: true
require_relative '../command'
require_relative '../package'
require_relative '../version_option'
require_relative "../command"
require_relative "../package"
require_relative "../version_option"
class Gem::Commands::BuildCommand < Gem::Command
include Gem::VersionOption
def initialize
super 'build', 'Build a gem from a gemspec'
super "build", "Build a gem from a gemspec"
add_platform_option
add_option '--force', 'skip validation of the spec' do |value, options|
add_option "--force", "skip validation of the spec" do |value, options|
options[:force] = true
end
add_option '--strict', 'consider warnings as errors when validating the spec' do |value, options|
add_option "--strict", "consider warnings as errors when validating the spec" do |value, options|
options[:strict] = true
end
add_option '-o', '--output FILE', 'output gem with the given filename' do |value, options|
add_option "-o", "--output FILE", "output gem with the given filename" do |value, options|
options[:output] = value
end
add_option '-C PATH', 'Run as if gem build was started in <PATH> instead of the current working directory.' do |value, options|
add_option "-C PATH", "Run as if gem build was started in <PATH> instead of the current working directory." do |value, options|
options[:build_path] = value
end
end

View file

@ -1,69 +1,69 @@
# frozen_string_literal: true
require_relative '../command'
require_relative '../security'
require_relative "../command"
require_relative "../security"
class Gem::Commands::CertCommand < Gem::Command
def initialize
super 'cert', 'Manage RubyGems certificates and signing settings',
super "cert", "Manage RubyGems certificates and signing settings",
:add => [], :remove => [], :list => [], :build => [], :sign => []
add_option('-a', '--add CERT',
'Add a trusted certificate.') do |cert_file, options|
add_option("-a", "--add CERT",
"Add a trusted certificate.") do |cert_file, options|
options[:add] << open_cert(cert_file)
end
add_option('-l', '--list [FILTER]',
'List trusted certificates where the',
'subject contains FILTER') do |filter, options|
filter ||= ''
add_option("-l", "--list [FILTER]",
"List trusted certificates where the",
"subject contains FILTER") do |filter, options|
filter ||= ""
options[:list] << filter
end
add_option('-r', '--remove FILTER',
'Remove trusted certificates where the',
'subject contains FILTER') do |filter, options|
add_option("-r", "--remove FILTER",
"Remove trusted certificates where the",
"subject contains FILTER") do |filter, options|
options[:remove] << filter
end
add_option('-b', '--build EMAIL_ADDR',
'Build private key and self-signed',
'certificate for EMAIL_ADDR') do |email_address, options|
add_option("-b", "--build EMAIL_ADDR",
"Build private key and self-signed",
"certificate for EMAIL_ADDR") do |email_address, options|
options[:build] << email_address
end
add_option('-C', '--certificate CERT',
'Signing certificate for --sign') do |cert_file, options|
add_option("-C", "--certificate CERT",
"Signing certificate for --sign") do |cert_file, options|
options[:issuer_cert] = open_cert(cert_file)
options[:issuer_cert_file] = cert_file
end
add_option('-K', '--private-key KEY',
'Key for --sign or --build') do |key_file, options|
add_option("-K", "--private-key KEY",
"Key for --sign or --build") do |key_file, options|
options[:key] = open_private_key(key_file)
end
add_option('-A', '--key-algorithm ALGORITHM',
'Select which key algorithm to use for --build') do |algorithm, options|
add_option("-A", "--key-algorithm ALGORITHM",
"Select which key algorithm to use for --build") do |algorithm, options|
options[:key_algorithm] = algorithm
end
add_option('-s', '--sign CERT',
'Signs CERT with the key from -K',
'and the certificate from -C') do |cert_file, options|
add_option("-s", "--sign CERT",
"Signs CERT with the key from -K",
"and the certificate from -C") do |cert_file, options|
raise Gem::OptionParser::InvalidArgument, "#{cert_file}: does not exist" unless
File.file? cert_file
options[:sign] << cert_file
end
add_option('-d', '--days NUMBER_OF_DAYS',
'Days before the certificate expires') do |days, options|
add_option("-d", "--days NUMBER_OF_DAYS",
"Days before the certificate expires") do |days, options|
options[:expiration_length_days] = days.to_i
end
add_option('-R', '--re-sign',
'Re-signs the certificate from -C with the key from -K') do |resign, options|
add_option("-R", "--re-sign",
"Re-signs the certificate from -C with the key from -K") do |resign, options|
options[:resign] = resign
end
end
@ -93,7 +93,7 @@ class Gem::Commands::CertCommand < Gem::Command
def open_private_key(key_file)
check_openssl
passphrase = ENV['GEM_PRIVATE_KEY_PASSPHRASE']
passphrase = ENV["GEM_PRIVATE_KEY_PASSPHRASE"]
key = OpenSSL::PKey.read File.read(key_file), passphrase
raise Gem::OptionParser::InvalidArgument,
"#{key_file}: private key not found" unless key.private?
@ -166,10 +166,10 @@ class Gem::Commands::CertCommand < Gem::Command
def build_key # :nodoc:
return options[:key] if options[:key]
passphrase = ask_for_password 'Passphrase for your Private Key:'
passphrase = ask_for_password "Passphrase for your Private Key:"
say "\n"
passphrase_confirmation = ask_for_password 'Please repeat the passphrase for your Private Key:'
passphrase_confirmation = ask_for_password "Please repeat the passphrase for your Private Key:"
say "\n"
raise Gem::CommandLineError,
@ -260,7 +260,7 @@ For further reading on signing gems see `ri Gem::Security`.
def load_default_key
key_file = File.join Gem.default_key_path
key = File.read key_file
passphrase = ENV['GEM_PRIVATE_KEY_PASSPHRASE']
passphrase = ENV["GEM_PRIVATE_KEY_PASSPHRASE"]
options[:key] = OpenSSL::PKey.read key, passphrase
rescue Errno::ENOENT

View file

@ -1,44 +1,44 @@
# frozen_string_literal: true
require_relative '../command'
require_relative '../version_option'
require_relative '../validator'
require_relative '../doctor'
require_relative "../command"
require_relative "../version_option"
require_relative "../validator"
require_relative "../doctor"
class Gem::Commands::CheckCommand < Gem::Command
include Gem::VersionOption
def initialize
super 'check', 'Check a gem repository for added or missing files',
super "check", "Check a gem repository for added or missing files",
:alien => true, :doctor => false, :dry_run => false, :gems => true
add_option('-a', '--[no-]alien',
add_option("-a", "--[no-]alien",
'Report "unmanaged" or rogue files in the',
'gem repository') do |value, options|
"gem repository") do |value, options|
options[:alien] = value
end
add_option('--[no-]doctor',
'Clean up uninstalled gems and broken',
'specifications') do |value, options|
add_option("--[no-]doctor",
"Clean up uninstalled gems and broken",
"specifications") do |value, options|
options[:doctor] = value
end
add_option('--[no-]dry-run',
'Do not remove files, only report what',
'would be removed') do |value, options|
add_option("--[no-]dry-run",
"Do not remove files, only report what",
"would be removed") do |value, options|
options[:dry_run] = value
end
add_option('--[no-]gems',
'Check installed gems for problems') do |value, options|
add_option("--[no-]gems",
"Check installed gems for problems") do |value, options|
options[:gems] = value
end
add_version_option 'check'
add_version_option "check"
end
def check_gems
say 'Checking gems...'
say "Checking gems..."
say
gems = get_all_gem_names rescue []
@ -57,7 +57,7 @@ class Gem::Commands::CheckCommand < Gem::Command
end
def doctor
say 'Checking for files from uninstalled gems...'
say "Checking for files from uninstalled gems..."
say
Gem.path.each do |gem_repo|
@ -72,11 +72,11 @@ class Gem::Commands::CheckCommand < Gem::Command
end
def arguments # :nodoc:
'GEMNAME name of gem to check'
"GEMNAME name of gem to check"
end
def defaults_str # :nodoc:
'--gems --alien'
"--gems --alien"
end
def description # :nodoc:

View file

@ -1,35 +1,35 @@
# frozen_string_literal: true
require_relative '../command'
require_relative '../dependency_list'
require_relative '../uninstaller'
require_relative "../command"
require_relative "../dependency_list"
require_relative "../uninstaller"
class Gem::Commands::CleanupCommand < Gem::Command
def initialize
super 'cleanup',
'Clean up old versions of installed gems',
super "cleanup",
"Clean up old versions of installed gems",
:force => false, :install_dir => Gem.dir,
:check_dev => true
add_option('-n', '-d', '--dry-run',
'Do not uninstall gems') do |value, options|
add_option("-n", "-d", "--dry-run",
"Do not uninstall gems") do |value, options|
options[:dryrun] = true
end
add_option(:Deprecated, '--dryrun',
'Do not uninstall gems') do |value, options|
add_option(:Deprecated, "--dryrun",
"Do not uninstall gems") do |value, options|
options[:dryrun] = true
end
deprecate_option('--dryrun', extra_msg: 'Use --dry-run instead')
deprecate_option("--dryrun", extra_msg: "Use --dry-run instead")
add_option('-D', '--[no-]check-development',
'Check development dependencies while uninstalling',
'(default: true)') do |value, options|
add_option("-D", "--[no-]check-development",
"Check development dependencies while uninstalling",
"(default: true)") do |value, options|
options[:check_dev] = value
end
add_option('--[no-]user-install',
'Cleanup in user\'s home directory instead',
'of GEM_HOME.') do |value, options|
add_option("--[no-]user-install",
"Cleanup in user's home directory instead",
"of GEM_HOME.") do |value, options|
options[:user_install] = value
end

View file

@ -1,39 +1,39 @@
# frozen_string_literal: true
require_relative '../command'
require_relative '../version_option'
require_relative "../command"
require_relative "../version_option"
class Gem::Commands::ContentsCommand < Gem::Command
include Gem::VersionOption
def initialize
super 'contents', 'Display the contents of the installed gems',
super "contents", "Display the contents of the installed gems",
:specdirs => [], :lib_only => false, :prefix => true,
:show_install_dir => false
add_version_option
add_option('--all',
add_option("--all",
"Contents for all gems") do |all, options|
options[:all] = all
end
add_option('-s', '--spec-dir a,b,c', Array,
add_option("-s", "--spec-dir a,b,c", Array,
"Search for gems under specific paths") do |spec_dirs, options|
options[:specdirs] = spec_dirs
end
add_option('-l', '--[no-]lib-only',
add_option("-l", "--[no-]lib-only",
"Only return files in the Gem's lib_dirs") do |lib_only, options|
options[:lib_only] = lib_only
end
add_option('--[no-]prefix',
add_option("--[no-]prefix",
"Don't include installed path prefix") do |prefix, options|
options[:prefix] = prefix
end
add_option('--[no-]show-install-dir',
'Show only the gem install dir') do |show, options|
add_option("--[no-]show-install-dir",
"Show only the gem install dir") do |show, options|
options[:show_install_dir] = show
end
@ -105,11 +105,11 @@ prefix or only the files that are requireable.
case file
when /\A#{spec.bindir}\//
# $' is POSTMATCH
[RbConfig::CONFIG['bindir'], $']
[RbConfig::CONFIG["bindir"], $']
when /\.so\z/
[RbConfig::CONFIG['archdir'], file]
[RbConfig::CONFIG["archdir"], file]
else
[RbConfig::CONFIG['rubylibdir'], file]
[RbConfig::CONFIG["rubylibdir"], file]
end
end
end

View file

@ -1,28 +1,28 @@
# frozen_string_literal: true
require_relative '../command'
require_relative '../local_remote_options'
require_relative '../version_option'
require_relative "../command"
require_relative "../local_remote_options"
require_relative "../version_option"
class Gem::Commands::DependencyCommand < Gem::Command
include Gem::LocalRemoteOptions
include Gem::VersionOption
def initialize
super 'dependency',
'Show the dependencies of an installed gem',
super "dependency",
"Show the dependencies of an installed gem",
:version => Gem::Requirement.default, :domain => :local
add_version_option
add_platform_option
add_prerelease_option
add_option('-R', '--[no-]reverse-dependencies',
'Include reverse dependencies in the output') do
add_option("-R", "--[no-]reverse-dependencies",
"Include reverse dependencies in the output") do
|value, options|
options[:reverse_dependencies] = value
end
add_option('-p', '--pipe',
add_option("-p", "--pipe",
"Pipe Format (name --version ver)") do |value, options|
options[:pipe_format] = value
end
@ -134,7 +134,7 @@ use with other commands.
def ensure_local_only_reverse_dependencies # :nodoc:
if options[:reverse_dependencies] and remote? and not local?
alert_error 'Only reverse dependencies for local gems are supported.'
alert_error "Only reverse dependencies for local gems are supported."
terminate_interaction 1
end
end
@ -142,7 +142,7 @@ use with other commands.
def ensure_specs(specs) # :nodoc:
return unless specs.empty?
patterns = options[:args].join ','
patterns = options[:args].join ","
say "No gems found matching #{patterns} (#{options[:version]})" if
Gem.configuration.verbose
@ -151,10 +151,10 @@ use with other commands.
def print_dependencies(spec, level = 0) # :nodoc:
response = String.new
response << ' ' * level + "Gem #{spec.full_name}\n"
response << " " * level + "Gem #{spec.full_name}\n"
unless spec.dependencies.empty?
spec.dependencies.sort_by {|dep| dep.name }.each do |dep|
response << ' ' * level + " #{dep}\n"
response << " " * level + " #{dep}\n"
end
end
response

View file

@ -1,9 +1,9 @@
# frozen_string_literal: true
require_relative '../command'
require_relative "../command"
class Gem::Commands::EnvironmentCommand < Gem::Command
def initialize
super 'environment', 'Display information about the RubyGems environment'
super "environment", "Display information about the RubyGems environment"
end
def arguments # :nodoc:
@ -16,7 +16,7 @@ class Gem::Commands::EnvironmentCommand < Gem::Command
platform display the supported gem platforms
<omitted> display everything
EOF
return args.gsub(/^\s+/, '')
return args.gsub(/^\s+/, "")
end
def description # :nodoc:
@ -141,7 +141,7 @@ lib/rubygems/defaults/operating_system.rb
out << " - GEM CONFIGURATION:\n"
Gem.configuration.each do |name, value|
value = value.gsub(/./, '*') if name == 'gemcutter_key'
value = value.gsub(/./, "*") if name == "gemcutter_key"
out << " - #{name.inspect} => #{value.inspect}\n"
end
@ -152,7 +152,7 @@ lib/rubygems/defaults/operating_system.rb
out << " - SHELL PATH:\n"
shell_path = ENV['PATH'].split(File::PATH_SEPARATOR)
shell_path = ENV["PATH"].split(File::PATH_SEPARATOR)
add_path out, shell_path
out

View file

@ -1,7 +1,7 @@
# frozen_string_literal: true
require_relative '../command'
require_relative '../local_remote_options'
require_relative '../version_option'
require_relative "../command"
require_relative "../local_remote_options"
require_relative "../version_option"
class Gem::Commands::FetchCommand < Gem::Command
include Gem::LocalRemoteOptions
@ -13,7 +13,7 @@ class Gem::Commands::FetchCommand < Gem::Command
:version => Gem::Requirement.default,
}
super 'fetch', 'Download a gem and place it in the current directory', defaults
super "fetch", "Download a gem and place it in the current directory", defaults
add_bulk_threshold_option
add_proxy_option
@ -24,13 +24,13 @@ class Gem::Commands::FetchCommand < Gem::Command
add_platform_option
add_prerelease_option
add_option '--[no-]suggestions', 'Suggest alternates when gems are not found' do |value, options|
add_option "--[no-]suggestions", "Suggest alternates when gems are not found" do |value, options|
options[:suggest_alternate] = value
end
end
def arguments # :nodoc:
'GEMNAME name of gem to download'
"GEMNAME name of gem to download"
end
def defaults_str # :nodoc:

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true
require_relative '../command'
require_relative '../indexer'
require_relative "../command"
require_relative "../indexer"
##
# Generates a index files for use as a gem server.
@ -9,27 +9,27 @@ require_relative '../indexer'
class Gem::Commands::GenerateIndexCommand < Gem::Command
def initialize
super 'generate_index',
'Generates the index files for a gem server directory',
:directory => '.', :build_modern => true
super "generate_index",
"Generates the index files for a gem server directory",
:directory => ".", :build_modern => true
add_option '-d', '--directory=DIRNAME',
'repository base dir containing gems subdir' do |dir, options|
add_option "-d", "--directory=DIRNAME",
"repository base dir containing gems subdir" do |dir, options|
options[:directory] = File.expand_path dir
end
add_option '--[no-]modern',
'Generate indexes for RubyGems',
'(always true)' do |value, options|
add_option "--[no-]modern",
"Generate indexes for RubyGems",
"(always true)" do |value, options|
options[:build_modern] = value
end
deprecate_option('--modern', version: '4.0', extra_msg: 'Modern indexes (specs, latest_specs, and prerelease_specs) are always generated, so this option is not needed.')
deprecate_option('--no-modern', version: '4.0', extra_msg: 'The `--no-modern` option is currently ignored. Modern indexes (specs, latest_specs, and prerelease_specs) are always generated.')
deprecate_option("--modern", version: "4.0", extra_msg: "Modern indexes (specs, latest_specs, and prerelease_specs) are always generated, so this option is not needed.")
deprecate_option("--no-modern", version: "4.0", extra_msg: "The `--no-modern` option is currently ignored. Modern indexes (specs, latest_specs, and prerelease_specs) are always generated.")
add_option '--update',
'Update modern indexes with gems added',
'since the last update' do |value, options|
add_option "--update",
"Update modern indexes with gems added",
"since the last update" do |value, options|
options[:update] = value
end
end

View file

@ -1,5 +1,5 @@
# frozen_string_literal: true
require_relative '../command'
require_relative "../command"
class Gem::Commands::HelpCommand < Gem::Command
# :stopdoc:
@ -280,7 +280,7 @@ platform.
# :startdoc:
def initialize
super 'help', "Provide help on the 'gem' command"
super "help", "Provide help on the 'gem' command"
@command_manager = Gem::CommandManager.instance
end
@ -326,7 +326,7 @@ platform.
desc_width = @command_manager.command_names.map {|n| n.size }.max + 4
summary_width = 80 - margin_width - desc_width
wrap_indent = ' ' * (margin_width + desc_width)
wrap_indent = " " * (margin_width + desc_width)
format = "#{' ' * margin_width}%-#{desc_width}s%s"
@command_manager.command_names.each do |cmd_name|

View file

@ -1,7 +1,7 @@
# frozen_string_literal: true
require_relative '../command'
require_relative '../query_utils'
require_relative "../command"
require_relative "../query_utils"
class Gem::Commands::InfoCommand < Gem::Command
include Gem::QueryUtils
@ -13,7 +13,7 @@ class Gem::Commands::InfoCommand < Gem::Command
add_query_options
remove_option('-d')
remove_option("-d")
defaults[:details] = true
defaults[:exact] = true

View file

@ -1,10 +1,10 @@
# frozen_string_literal: true
require_relative '../command'
require_relative '../install_update_options'
require_relative '../dependency_installer'
require_relative '../local_remote_options'
require_relative '../validator'
require_relative '../version_option'
require_relative "../command"
require_relative "../install_update_options"
require_relative "../dependency_installer"
require_relative "../local_remote_options"
require_relative "../validator"
require_relative "../version_option"
##
# Gem installer command line tool
@ -29,7 +29,7 @@ class Gem::Commands::InstallCommand < Gem::Command
defaults.merge!(install_update_options)
super 'install', 'Install a gem into the local repository', defaults
super "install", "Install a gem into the local repository", defaults
add_install_update_options
add_local_remote_options
@ -157,7 +157,7 @@ You can use `i` command instead of `install`.
@installed_specs = []
ENV.delete 'GEM_PATH' if options[:install_dir].nil?
ENV.delete "GEM_PATH" if options[:install_dir].nil?
check_install_dir
check_version
@ -172,7 +172,7 @@ You can use `i` command instead of `install`.
end
def install_from_gemdeps # :nodoc:
require_relative '../request_set'
require_relative "../request_set"
rs = Gem::RequestSet.new
specs = rs.install_from_gemdeps options do |req, inst|
@ -247,11 +247,11 @@ You can use `i` command instead of `install`.
def load_hooks # :nodoc:
if options[:install_as_default]
require_relative '../install_default_message'
require_relative "../install_default_message"
else
require_relative '../install_message'
require_relative "../install_message"
end
require_relative '../rdoc'
require_relative "../rdoc"
end
def show_install_errors(errors) # :nodoc:
@ -270,7 +270,7 @@ You can use `i` command instead of `install`.
def show_installed # :nodoc:
return if @installed_specs.empty?
gems = @installed_specs.length == 1 ? 'gem' : 'gems'
gems = @installed_specs.length == 1 ? "gem" : "gems"
say "#{@installed_specs.length} #{gems} installed"
end
end

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true
require_relative '../command'
require_relative '../query_utils'
require_relative "../command"
require_relative "../query_utils"
##
# Searches for gems starting with the supplied argument.
@ -9,7 +9,7 @@ class Gem::Commands::ListCommand < Gem::Command
include Gem::QueryUtils
def initialize
super 'list', 'Display local gems whose name matches REGEXP',
super "list", "Display local gems whose name matches REGEXP",
:domain => :local, :details => false, :versions => true,
:installed => nil, :version => Gem::Requirement.default

View file

@ -1,13 +1,13 @@
# frozen_string_literal: true
require_relative '../command'
require_relative "../command"
class Gem::Commands::LockCommand < Gem::Command
def initialize
super 'lock', 'Generate a lockdown list of gems',
super "lock", "Generate a lockdown list of gems",
:strict => false
add_option '-s', '--[no-]strict',
'fail if unable to satisfy a dependency' do |strict, options|
add_option "-s", "--[no-]strict",
"fail if unable to satisfy a dependency" do |strict, options|
options[:strict] = strict
end
end

View file

@ -1,12 +1,12 @@
# frozen_string_literal: true
require_relative '../command'
require_relative "../command"
unless defined? Gem::Commands::MirrorCommand
class Gem::Commands::MirrorCommand < Gem::Command
def initialize
super('mirror', 'Mirror all gem files (requires rubygems-mirror)')
super("mirror", "Mirror all gem files (requires rubygems-mirror)")
begin
Gem::Specification.find_by_name('rubygems-mirror').activate
Gem::Specification.find_by_name("rubygems-mirror").activate
rescue Gem::LoadError
# no-op
end

View file

@ -1,18 +1,18 @@
# frozen_string_literal: true
require_relative '../command'
require_relative '../version_option'
require_relative "../command"
require_relative "../version_option"
class Gem::Commands::OpenCommand < Gem::Command
include Gem::VersionOption
def initialize
super 'open', 'Open gem sources in editor'
super "open", "Open gem sources in editor"
add_option('-e', '--editor COMMAND', String,
add_option("-e", "--editor COMMAND", String,
"Prepends COMMAND to gem path. Could be used to specify editor.") do |command, options|
options[:editor] = command || get_env_editor
end
add_option('-v', '--version VERSION', String,
add_option("-v", "--version VERSION", String,
"Opens specific gem version") do |version|
options[:version] = version
end
@ -40,10 +40,10 @@ class Gem::Commands::OpenCommand < Gem::Command
end
def get_env_editor
ENV['GEM_EDITOR'] ||
ENV['VISUAL'] ||
ENV['EDITOR'] ||
'vi'
ENV["GEM_EDITOR"] ||
ENV["VISUAL"] ||
ENV["EDITOR"] ||
"vi"
end
def execute

View file

@ -1,15 +1,15 @@
# frozen_string_literal: true
require_relative '../command'
require_relative '../local_remote_options'
require_relative '../spec_fetcher'
require_relative '../version_option'
require_relative "../command"
require_relative "../local_remote_options"
require_relative "../spec_fetcher"
require_relative "../version_option"
class Gem::Commands::OutdatedCommand < Gem::Command
include Gem::LocalRemoteOptions
include Gem::VersionOption
def initialize
super 'outdated', 'Display all gems that need updates'
super "outdated", "Display all gems that need updates"
add_local_remote_options
add_platform_option

View file

@ -1,8 +1,8 @@
# frozen_string_literal: true
require_relative '../command'
require_relative '../local_remote_options'
require_relative '../gemcutter_utilities'
require_relative '../text'
require_relative "../command"
require_relative "../local_remote_options"
require_relative "../gemcutter_utilities"
require_relative "../text"
class Gem::Commands::OwnerCommand < Gem::Command
include Gem::Text
@ -34,23 +34,23 @@ permission to.
end
def initialize
super 'owner', 'Manage gem owners of a gem on the push server'
super "owner", "Manage gem owners of a gem on the push server"
add_proxy_option
add_key_option
add_otp_option
defaults.merge! :add => [], :remove => []
add_option '-a', '--add NEW_OWNER', 'Add an owner by user identifier' do |value, options|
add_option "-a", "--add NEW_OWNER", "Add an owner by user identifier" do |value, options|
options[:add] << value
end
add_option '-r', '--remove OLD_OWNER', 'Remove an owner by user identifier' do |value, options|
add_option "-r", "--remove OLD_OWNER", "Remove an owner by user identifier" do |value, options|
options[:remove] << value
end
add_option '-h', '--host HOST',
'Use another gemcutter-compatible host',
' (e.g. https://rubygems.org)' do |value, options|
add_option "-h", "--host HOST",
"Use another gemcutter-compatible host",
" (e.g. https://rubygems.org)" do |value, options|
options[:host] = value
end
end
@ -108,7 +108,7 @@ permission to.
def send_owner_request(method, name, owner)
rubygems_api_request method, "api/v1/gems/#{name}/owners", scope: get_owner_scope(method: method) do |request|
request.set_form_data 'email' => owner
request.set_form_data "email" => owner
request.add_field "Authorization", api_key
end
end

View file

@ -1,67 +1,67 @@
# frozen_string_literal: true
require_relative '../command'
require_relative '../package'
require_relative '../installer'
require_relative '../version_option'
require_relative "../command"
require_relative "../package"
require_relative "../installer"
require_relative "../version_option"
class Gem::Commands::PristineCommand < Gem::Command
include Gem::VersionOption
def initialize
super 'pristine',
'Restores installed gems to pristine condition from files located in the gem cache',
super "pristine",
"Restores installed gems to pristine condition from files located in the gem cache",
:version => Gem::Requirement.default,
:extensions => true,
:extensions_set => false,
:all => false
add_option('--all',
'Restore all installed gems to pristine',
'condition') do |value, options|
add_option("--all",
"Restore all installed gems to pristine",
"condition") do |value, options|
options[:all] = value
end
add_option('--skip=gem_name',
'used on --all, skip if name == gem_name') do |value, options|
add_option("--skip=gem_name",
"used on --all, skip if name == gem_name") do |value, options|
options[:skip] ||= []
options[:skip] << value
end
add_option('--[no-]extensions',
'Restore gems with extensions',
'in addition to regular gems') do |value, options|
add_option("--[no-]extensions",
"Restore gems with extensions",
"in addition to regular gems") do |value, options|
options[:extensions_set] = true
options[:extensions] = value
end
add_option('--only-executables',
'Only restore executables') do |value, options|
add_option("--only-executables",
"Only restore executables") do |value, options|
options[:only_executables] = value
end
add_option('--only-plugins',
'Only restore plugins') do |value, options|
add_option("--only-plugins",
"Only restore plugins") do |value, options|
options[:only_plugins] = value
end
add_option('-E', '--[no-]env-shebang',
'Rewrite executables with a shebang',
'of /usr/bin/env') do |value, options|
add_option("-E", "--[no-]env-shebang",
"Rewrite executables with a shebang",
"of /usr/bin/env") do |value, options|
options[:env_shebang] = value
end
add_option('-i', '--install-dir DIR',
'Gem repository to get binstubs and plugins installed') do |value, options|
add_option("-i", "--install-dir DIR",
"Gem repository to get binstubs and plugins installed") do |value, options|
options[:install_dir] = File.expand_path(value)
end
add_option('-n', '--bindir DIR',
'Directory where executables are',
'located') do |value, options|
add_option("-n", "--bindir DIR",
"Directory where executables are",
"located") do |value, options|
options[:bin_dir] = File.expand_path(value)
end
add_version_option('restore to', 'pristine condition')
add_version_option("restore to", "pristine condition")
end
def arguments # :nodoc:
@ -69,7 +69,7 @@ class Gem::Commands::PristineCommand < Gem::Command
end
def defaults_str # :nodoc:
'--extensions'
"--extensions"
end
def description # :nodoc:
@ -143,7 +143,7 @@ extensions will be restored.
gem = spec.cache_file
unless File.exist? gem or options[:only_executables] or options[:only_plugins]
require_relative '../remote_fetcher'
require_relative "../remote_fetcher"
say "Cached gem for #{spec.full_name} not found, attempting to fetch..."
@ -163,8 +163,8 @@ extensions will be restored.
if options.include? :env_shebang
options[:env_shebang]
else
install_defaults = Gem::ConfigFile::PLATFORM_DEFAULTS['install']
install_defaults.to_s['--env-shebang']
install_defaults = Gem::ConfigFile::PLATFORM_DEFAULTS["install"]
install_defaults.to_s["--env-shebang"]
end
bin_dir = options[:bin_dir] if options[:bin_dir]

View file

@ -1,8 +1,8 @@
# frozen_string_literal: true
require_relative '../command'
require_relative '../local_remote_options'
require_relative '../gemcutter_utilities'
require_relative '../package'
require_relative "../command"
require_relative "../local_remote_options"
require_relative "../gemcutter_utilities"
require_relative "../package"
class Gem::Commands::PushCommand < Gem::Command
include Gem::LocalRemoteOptions
@ -29,7 +29,7 @@ The push command will use ~/.gem/credentials to authenticate to a server, but yo
end
def initialize
super 'push', 'Push a gem up to the gem server', :host => self.host
super "push", "Push a gem up to the gem server", :host => self.host
@user_defined_host = false
@ -37,9 +37,9 @@ The push command will use ~/.gem/credentials to authenticate to a server, but yo
add_key_option
add_otp_option
add_option('--host HOST',
'Push to another gemcutter-compatible host',
' (e.g. https://rubygems.org)') do |value, options|
add_option("--host HOST",
"Push to another gemcutter-compatible host",
" (e.g. https://rubygems.org)") do |value, options|
options[:host] = value
@user_defined_host = true
end

View file

@ -1,7 +1,7 @@
# frozen_string_literal: true
require_relative '../command'
require_relative '../query_utils'
require_relative '../deprecate'
require_relative "../command"
require_relative "../query_utils"
require_relative "../deprecate"
class Gem::Commands::QueryCommand < Gem::Command
extend Gem::Deprecate
@ -17,15 +17,15 @@ class Gem::Commands::QueryCommand < Gem::Command
alert_warning message unless Gem::Deprecate.skip
end
def initialize(name = 'query',
summary = 'Query gem information in local or remote repositories')
def initialize(name = "query",
summary = "Query gem information in local or remote repositories")
super name, summary,
:domain => :local, :details => false, :versions => true,
:installed => nil, :version => Gem::Requirement.default
add_option('-n', '--name-matches REGEXP',
'Name of gem(s) to query on matches the',
'provided REGEXP') do |value, options|
add_option("-n", "--name-matches REGEXP",
"Name of gem(s) to query on matches the",
"provided REGEXP") do |value, options|
options[:name] = /#{value}/i
end

View file

@ -1,35 +1,35 @@
# frozen_string_literal: true
require_relative '../command'
require_relative '../version_option'
require_relative '../rdoc'
require 'fileutils'
require_relative "../command"
require_relative "../version_option"
require_relative "../rdoc"
require "fileutils"
class Gem::Commands::RdocCommand < Gem::Command
include Gem::VersionOption
def initialize
super 'rdoc', 'Generates RDoc for pre-installed gems',
super "rdoc", "Generates RDoc for pre-installed gems",
:version => Gem::Requirement.default,
:include_rdoc => false, :include_ri => true, :overwrite => false
add_option('--all',
'Generate RDoc/RI documentation for all',
'installed gems') do |value, options|
add_option("--all",
"Generate RDoc/RI documentation for all",
"installed gems") do |value, options|
options[:all] = value
end
add_option('--[no-]rdoc',
'Generate RDoc HTML') do |value, options|
add_option("--[no-]rdoc",
"Generate RDoc HTML") do |value, options|
options[:include_rdoc] = value
end
add_option('--[no-]ri',
'Generate RI data') do |value, options|
add_option("--[no-]ri",
"Generate RI data") do |value, options|
options[:include_ri] = value
end
add_option('--[no-]overwrite',
'Overwrite installed documents') do |value, options|
add_option("--[no-]overwrite",
"Overwrite installed documents") do |value, options|
options[:overwrite] = value
end
@ -69,7 +69,7 @@ Use --overwrite to force rebuilding of documentation.
end
if specs.empty?
alert_error 'No matching gems found'
alert_error "No matching gems found"
terminate_interaction 1
end
@ -79,8 +79,8 @@ Use --overwrite to force rebuilding of documentation.
doc.force = options[:overwrite]
if options[:overwrite]
FileUtils.rm_rf File.join(spec.doc_dir, 'ri')
FileUtils.rm_rf File.join(spec.doc_dir, 'rdoc')
FileUtils.rm_rf File.join(spec.doc_dir, "ri")
FileUtils.rm_rf File.join(spec.doc_dir, "rdoc")
end
begin

View file

@ -1,12 +1,12 @@
# frozen_string_literal: true
require_relative '../command'
require_relative '../query_utils'
require_relative "../command"
require_relative "../query_utils"
class Gem::Commands::SearchCommand < Gem::Command
include Gem::QueryUtils
def initialize
super 'search', 'Display remote gems whose name matches REGEXP',
super "search", "Display remote gems whose name matches REGEXP",
:domain => :remote, :details => false, :versions => true,
:installed => nil, :version => Gem::Requirement.default

View file

@ -1,12 +1,12 @@
# frozen_string_literal: true
require_relative '../command'
require_relative "../command"
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)')
super("server", "Starts up a web server that hosts the RDoc (requires rubygems-server)")
begin
Gem::Specification.find_by_name('rubygems-server').activate
Gem::Specification.find_by_name("rubygems-server").activate
rescue Gem::LoadError
# no-op
end

View file

@ -1,5 +1,5 @@
# frozen_string_literal: true
require_relative '../command'
require_relative "../command"
##
# Installs RubyGems itself. This command is ordinarily only available from a
@ -12,47 +12,47 @@ class Gem::Commands::SetupCommand < Gem::Command
ENV_PATHS = %w[/usr/bin/env /bin/env].freeze
def initialize
super 'setup', 'Install RubyGems',
super "setup", "Install RubyGems",
:format_executable => false, :document => %w[ri],
:force => true,
:site_or_vendor => 'sitelibdir',
:destdir => '', :prefix => '', :previous_version => '',
:site_or_vendor => "sitelibdir",
:destdir => "", :prefix => "", :previous_version => "",
:regenerate_binstubs => true,
:regenerate_plugins => true
add_option '--previous-version=VERSION',
'Previous version of RubyGems',
'Used for changelog processing' do |version, options|
add_option "--previous-version=VERSION",
"Previous version of RubyGems",
"Used for changelog processing" do |version, options|
options[:previous_version] = version
end
add_option '--prefix=PREFIX',
'Prefix path for installing RubyGems',
'Will not affect gem repository location' do |prefix, options|
add_option "--prefix=PREFIX",
"Prefix path for installing RubyGems",
"Will not affect gem repository location" do |prefix, options|
options[:prefix] = File.expand_path prefix
end
add_option '--destdir=DESTDIR',
'Root directory to install RubyGems into',
'Mainly used for packaging RubyGems' do |destdir, options|
add_option "--destdir=DESTDIR",
"Root directory to install RubyGems into",
"Mainly used for packaging RubyGems" do |destdir, options|
options[:destdir] = File.expand_path destdir
end
add_option '--[no-]vendor',
'Install into vendorlibdir not sitelibdir' do |vendor, options|
options[:site_or_vendor] = vendor ? 'vendorlibdir' : 'sitelibdir'
add_option "--[no-]vendor",
"Install into vendorlibdir not sitelibdir" do |vendor, options|
options[:site_or_vendor] = vendor ? "vendorlibdir" : "sitelibdir"
end
add_option '--[no-]format-executable',
'Makes `gem` match ruby',
'If Ruby is ruby18, gem will be gem18' do |value, options|
add_option "--[no-]format-executable",
"Makes `gem` match ruby",
"If Ruby is ruby18, gem will be gem18" do |value, options|
options[:format_executable] = value
end
add_option '--[no-]document [TYPES]', Array,
'Generate documentation for RubyGems',
'List the documentation types you wish to',
'generate. For example: rdoc,ri' do |value, options|
add_option "--[no-]document [TYPES]", Array,
"Generate documentation for RubyGems",
"List the documentation types you wish to",
"generate. For example: rdoc,ri" do |value, options|
options[:document] = case value
when nil then %w[rdoc ri]
when false then []
@ -60,46 +60,46 @@ class Gem::Commands::SetupCommand < Gem::Command
end
end
add_option '--[no-]rdoc',
'Generate RDoc documentation for RubyGems' do |value, options|
add_option "--[no-]rdoc",
"Generate RDoc documentation for RubyGems" do |value, options|
if value
options[:document] << 'rdoc'
options[:document] << "rdoc"
else
options[:document].delete 'rdoc'
options[:document].delete "rdoc"
end
options[:document].uniq!
end
add_option '--[no-]ri',
'Generate RI documentation for RubyGems' do |value, options|
add_option "--[no-]ri",
"Generate RI documentation for RubyGems" do |value, options|
if value
options[:document] << 'ri'
options[:document] << "ri"
else
options[:document].delete 'ri'
options[:document].delete "ri"
end
options[:document].uniq!
end
add_option '--[no-]regenerate-binstubs',
'Regenerate gem binstubs' do |value, options|
add_option "--[no-]regenerate-binstubs",
"Regenerate gem binstubs" do |value, options|
options[:regenerate_binstubs] = value
end
add_option '--[no-]regenerate-plugins',
'Regenerate gem plugins' do |value, options|
add_option "--[no-]regenerate-plugins",
"Regenerate gem plugins" do |value, options|
options[:regenerate_plugins] = value
end
add_option '-f', '--[no-]force',
'Forcefully overwrite binstubs' do |value, options|
add_option "-f", "--[no-]force",
"Forcefully overwrite binstubs" do |value, options|
options[:force] = value
end
add_option('-E', '--[no-]env-shebang',
'Rewrite executables with a shebang',
'of /usr/bin/env') do |value, options|
add_option("-E", "--[no-]env-shebang",
"Rewrite executables with a shebang",
"of /usr/bin/env") do |value, options|
options[:env_shebang] = value
end
@ -107,7 +107,7 @@ class Gem::Commands::SetupCommand < Gem::Command
end
def check_ruby_version
required_version = Gem::Requirement.new '>= 2.3.0'
required_version = Gem::Requirement.new ">= 2.3.0"
unless required_version.satisfied_by? Gem.ruby_version
alert_error "Expected Ruby version #{required_version}, is #{Gem.ruby_version}"
@ -149,7 +149,7 @@ By default, this RubyGems will install gem as:
check_ruby_version
require 'fileutils'
require "fileutils"
if Gem.configuration.really_verbose
extend FileUtils::Verbose
else
@ -194,7 +194,7 @@ By default, this RubyGems will install gem as:
end
if options[:previous_version].empty?
options[:previous_version] = Gem::VERSION.sub(/[0-9]+$/, '0')
options[:previous_version] = Gem::VERSION.sub(/[0-9]+$/, "0")
end
options[:previous_version] = Gem::Version.new(options[:previous_version])
@ -216,7 +216,7 @@ By default, this RubyGems will install gem as:
end
if documentation_success
if options[:document].include? 'rdoc'
if options[:document].include? "rdoc"
say "Rdoc documentation was installed. You may now invoke:"
say " gem server"
say "and then peruse beautifully formatted documentation for your gems"
@ -227,7 +227,7 @@ By default, this RubyGems will install gem as:
say
end
if options[:document].include? 'ri'
if options[:document].include? "ri"
say "Ruby Interactive (ri) documentation was installed. ri is kind of like man "
say "pages for Ruby libraries. You may access it like this:"
say " ri Classname"
@ -244,14 +244,14 @@ By default, this RubyGems will install gem as:
def install_executables(bin_dir)
prog_mode = options[:prog_mode] || 0755
executables = { 'gem' => 'bin' }
executables = { "gem" => "bin" }
executables.each do |tool, path|
say "Installing #{tool} executable" if @verbose
Dir.chdir path do
bin_file = "gem"
require 'tmpdir'
require "tmpdir"
dest_file = target_bin_path(bin_dir, bin_file)
bin_tmp_file = File.join Dir.tmpdir, "#{bin_file}.#{$$}"
@ -260,7 +260,7 @@ By default, this RubyGems will install gem as:
bin = File.readlines bin_file
bin[0] = shebang
File.open bin_tmp_file, 'w' do |fp|
File.open bin_tmp_file, "w" do |fp|
fp.puts bin.join
end
@ -275,7 +275,7 @@ By default, this RubyGems will install gem as:
begin
bin_cmd_file = File.join Dir.tmpdir, "#{bin_file}.bat"
File.open bin_cmd_file, 'w' do |file|
File.open bin_cmd_file, "w" do |file|
file.puts <<-TEXT
@ECHO OFF
IF NOT "%~f0" == "~f0" GOTO :WinNT
@ -296,7 +296,7 @@ By default, this RubyGems will install gem as:
def shebang
if options[:env_shebang]
ruby_name = RbConfig::CONFIG['ruby_install_name']
ruby_name = RbConfig::CONFIG["ruby_install_name"]
@env_path ||= ENV_PATHS.find {|env_path| File.executable? env_path }
"#!#{@env_path} #{ruby_name}\n"
else
@ -305,8 +305,8 @@ By default, this RubyGems will install gem as:
end
def install_lib(lib_dir)
libs = { 'RubyGems' => 'lib' }
libs['Bundler'] = 'bundler/lib'
libs = { "RubyGems" => "lib" }
libs["Bundler"] = "bundler/lib"
libs.each do |tool, path|
say "Installing #{tool}" if @verbose
@ -319,7 +319,7 @@ By default, this RubyGems will install gem as:
end
def install_rdoc
gem_doc_dir = File.join Gem.dir, 'doc'
gem_doc_dir = File.join Gem.dir, "doc"
rubygems_name = "rubygems-#{Gem::VERSION}"
rubygems_doc_dir = File.join gem_doc_dir, rubygems_name
@ -333,19 +333,19 @@ By default, this RubyGems will install gem as:
(not File.exist? rubygems_doc_dir or
File.writable? rubygems_doc_dir)
say "Removing old RubyGems RDoc and ri" if @verbose
Dir[File.join(Gem.dir, 'doc', 'rubygems-[0-9]*')].each do |dir|
Dir[File.join(Gem.dir, "doc", "rubygems-[0-9]*")].each do |dir|
rm_rf dir
end
require_relative '../rdoc'
require_relative "../rdoc"
fake_spec = Gem::Specification.new 'rubygems', Gem::VERSION
fake_spec = Gem::Specification.new "rubygems", Gem::VERSION
def fake_spec.full_gem_path
File.expand_path '../../..', __dir__
File.expand_path "../../..", __dir__
end
generate_ri = options[:document].include? 'ri'
generate_rdoc = options[:document].include? 'rdoc'
generate_ri = options[:document].include? "ri"
generate_rdoc = options[:document].include? "rdoc"
rdoc = Gem::RDoc.new fake_spec, generate_rdoc, generate_ri
rdoc.generate
@ -360,34 +360,24 @@ By default, this RubyGems will install gem as:
end
def install_default_bundler_gem(bin_dir)
specs_dir = File.join(default_dir, "specifications", "default")
mkdir_p specs_dir, :mode => 0755
bundler_spec = Dir.chdir("bundler") { Gem::Specification.load("bundler.gemspec") }
current_default_spec = Gem::Specification.default_stubs.find {|s| s.name == "bundler" }
if current_default_spec
File.delete(current_default_spec.loaded_from)
specs_dir = if current_default_spec && default_dir == Gem.default_dir
Gem::Specification.remove_spec current_default_spec
loaded_from = current_default_spec.loaded_from
File.delete(loaded_from)
File.dirname(loaded_from)
else
target_specs_dir = File.join(default_dir, "specifications", "default")
mkdir_p target_specs_dir, :mode => 0755
target_specs_dir
end
bundler_spec = Dir.chdir("bundler") { Gem::Specification.load("bundler.gemspec") }
default_spec_path = File.join(specs_dir, "#{bundler_spec.full_name}.gemspec")
Gem.write_binary(default_spec_path, bundler_spec.to_ruby)
bundler_spec = Gem::Specification.load(default_spec_path)
# The base_dir value for a specification is inferred by walking up from the
# folder where the spec was `loaded_from`. In the case of default gems, we
# walk up two levels, because they live at `specifications/default/`, whereas
# in the case of regular gems we walk up just one level because they live at
# `specifications/`. However, in this case, the gem we are installing is
# misdetected as a regular gem, when it's a default gem in reality. This is
# because when there's a `:destdir`, the `loaded_from` path has changed and
# doesn't match `Gem.default_specifications_dir` which is the criteria to
# tag a gem as a default gem. So, in that case, write the correct
# `@base_dir` directly.
bundler_spec.instance_variable_set(:@base_dir, File.dirname(File.dirname(specs_dir)))
# Remove gemspec that was same version of vendored bundler.
normal_gemspec = File.join(default_dir, "specifications", "bundler-#{bundler_spec.version}.gemspec")
if File.file? normal_gemspec
@ -407,7 +397,7 @@ By default, this RubyGems will install gem as:
cp File.join("bundler", bundler_spec.bindir, e), File.join(bundler_bin_dir, e)
end
require_relative '../installer'
require_relative "../installer"
Dir.chdir("bundler") do
built_gem = Gem::Package.build(bundler_spec)
@ -449,10 +439,10 @@ By default, this RubyGems will install gem as:
prefix = options[:prefix]
if prefix.empty?
man_dir = RbConfig::CONFIG['mandir']
man_dir = RbConfig::CONFIG["mandir"]
return unless man_dir
else
man_dir = File.join prefix, 'man'
man_dir = File.join prefix, "man"
end
prepend_destdir_if_present(man_dir)
@ -464,10 +454,10 @@ By default, this RubyGems will install gem as:
if prefix.empty?
lib_dir = RbConfig::CONFIG[site_or_vendor]
bin_dir = RbConfig::CONFIG['bindir']
bin_dir = RbConfig::CONFIG["bindir"]
else
lib_dir = File.join prefix, 'lib'
bin_dir = File.join prefix, 'bin'
lib_dir = File.join prefix, "lib"
bin_dir = File.join prefix, "bin"
end
[prepend_destdir_if_present(lib_dir), prepend_destdir_if_present(bin_dir)]
@ -475,19 +465,19 @@ By default, this RubyGems will install gem as:
def files_in(dir)
Dir.chdir dir do
Dir.glob(File.join('**', '*'), File::FNM_DOTMATCH).
Dir.glob(File.join("**", "*"), File::FNM_DOTMATCH).
select {|f| !File.directory?(f) }
end
end
def remove_old_bin_files(bin_dir)
old_bin_files = {
'gem_mirror' => 'gem mirror',
'gem_server' => 'gem server',
'gemlock' => 'gem lock',
'gemri' => 'ri',
'gemwhich' => 'gem which',
'index_gem_repository.rb' => 'gem generate_index',
"gem_mirror" => "gem mirror",
"gem_server" => "gem server",
"gemlock" => "gem lock",
"gemri" => "ri",
"gemwhich" => "gem which",
"index_gem_repository.rb" => "gem generate_index",
}
old_bin_files.each do |old_bin_file, new_name|
@ -496,7 +486,7 @@ By default, this RubyGems will install gem as:
deprecation_message = "`#{old_bin_file}` has been deprecated. Use `#{new_name}` instead."
File.open old_bin_path, 'w' do |fp|
File.open old_bin_path, "w" do |fp|
fp.write <<-EOF
#!#{Gem.ruby}
@ -506,15 +496,15 @@ abort "#{deprecation_message}"
next unless Gem.win_platform?
File.open "#{old_bin_path}.bat", 'w' do |fp|
File.open "#{old_bin_path}.bat", "w" do |fp|
fp.puts %(@ECHO.#{deprecation_message})
end
end
end
def remove_old_lib_files(lib_dir)
lib_dirs = { File.join(lib_dir, 'rubygems') => 'lib/rubygems' }
lib_dirs[File.join(lib_dir, 'bundler')] = 'bundler/lib/bundler'
lib_dirs = { File.join(lib_dir, "rubygems") => "lib/rubygems" }
lib_dirs[File.join(lib_dir, "bundler")] = "bundler/lib/bundler"
lib_dirs.each do |old_lib_dir, new_lib_dir|
lib_files = files_in(new_lib_dir)
@ -522,11 +512,11 @@ abort "#{deprecation_message}"
to_remove = old_lib_files - lib_files
gauntlet_rubygems = File.join(lib_dir, 'gauntlet_rubygems.rb')
gauntlet_rubygems = File.join(lib_dir, "gauntlet_rubygems.rb")
to_remove << gauntlet_rubygems if File.exist? gauntlet_rubygems
to_remove.delete_if do |file|
file.start_with? 'defaults'
file.start_with? "defaults"
end
remove_file_list(to_remove, old_lib_dir)
@ -552,7 +542,7 @@ abort "#{deprecation_message}"
end
def show_release_notes
release_notes = File.join Dir.pwd, 'CHANGELOG.md'
release_notes = File.join Dir.pwd, "CHANGELOG.md"
release_notes =
if File.exist? release_notes
@ -583,10 +573,10 @@ abort "#{deprecation_message}"
end
def uninstall_old_gemcutter
require_relative '../uninstaller'
require_relative "../uninstaller"
ui = Gem::Uninstaller.new('gemcutter', :all => true, :ignore => true,
:version => '< 0.4')
ui = Gem::Uninstaller.new("gemcutter", :all => true, :ignore => true,
:version => "< 0.4")
ui.uninstall
rescue Gem::InstallError
end
@ -635,7 +625,7 @@ abort "#{deprecation_message}"
destdir = options[:destdir]
return path if destdir.empty?
File.join(options[:destdir], path.gsub(/^[a-zA-Z]:/, ''))
File.join(options[:destdir], path.gsub(/^[a-zA-Z]:/, ""))
end
def install_file_list(files, dest_dir)

View file

@ -1,15 +1,15 @@
# frozen_string_literal: true
require_relative '../command'
require_relative '../gemcutter_utilities'
require_relative "../command"
require_relative "../gemcutter_utilities"
class Gem::Commands::SigninCommand < Gem::Command
include Gem::GemcutterUtilities
def initialize
super 'signin', 'Sign in to any gemcutter-compatible host. '\
'It defaults to https://rubygems.org'
super "signin", "Sign in to any gemcutter-compatible host. "\
"It defaults to https://rubygems.org"
add_option('--host HOST', 'Push to another gemcutter-compatible host') do |value, options|
add_option("--host HOST", "Push to another gemcutter-compatible host") do |value, options|
options[:host] = value
end
@ -17,10 +17,10 @@ class Gem::Commands::SigninCommand < Gem::Command
end
def description # :nodoc:
'The signin command executes host sign in for a push server (the default is'\
' https://rubygems.org). The host can be provided with the host flag or can'\
' be inferred from the provided gem. Host resolution matches the resolution'\
' strategy for the push command.'
"The signin command executes host sign in for a push server (the default is"\
" https://rubygems.org). The host can be provided with the host flag or can"\
" be inferred from the provided gem. Host resolution matches the resolution"\
" strategy for the push command."
end
def usage # :nodoc:

View file

@ -1,14 +1,14 @@
# frozen_string_literal: true
require_relative '../command'
require_relative "../command"
class Gem::Commands::SignoutCommand < Gem::Command
def initialize
super 'signout', 'Sign out from all the current sessions.'
super "signout", "Sign out from all the current sessions."
end
def description # :nodoc:
'The `signout` command is used to sign out from all current sessions,'\
' allowing you to sign in using a different set of credentials.'
"The `signout` command is used to sign out from all current sessions,"\
" allowing you to sign in using a different set of credentials."
end
def usage # :nodoc:
@ -19,13 +19,13 @@ class Gem::Commands::SignoutCommand < Gem::Command
credentials_path = Gem.configuration.credentials_path
if !File.exist?(credentials_path)
alert_error 'You are not currently signed in.'
alert_error "You are not currently signed in."
elsif !File.writable?(credentials_path)
alert_error "File '#{Gem.configuration.credentials_path}' is read-only."\
' Please make sure it is writable.'
" Please make sure it is writable."
else
Gem.configuration.unset_api_key!
say 'You have successfully signed out from all sessions.'
say "You have successfully signed out from all sessions."
end
end
end

View file

@ -1,40 +1,40 @@
# frozen_string_literal: true
require_relative '../command'
require_relative '../remote_fetcher'
require_relative '../spec_fetcher'
require_relative '../local_remote_options'
require_relative "../command"
require_relative "../remote_fetcher"
require_relative "../spec_fetcher"
require_relative "../local_remote_options"
class Gem::Commands::SourcesCommand < Gem::Command
include Gem::LocalRemoteOptions
def initialize
require 'fileutils'
require "fileutils"
super 'sources',
'Manage the sources and cache file RubyGems uses to search for gems'
super "sources",
"Manage the sources and cache file RubyGems uses to search for gems"
add_option '-a', '--add SOURCE_URI', 'Add source' do |value, options|
add_option "-a", "--add SOURCE_URI", "Add source" do |value, options|
options[:add] = value
end
add_option '-l', '--list', 'List sources' do |value, options|
add_option "-l", "--list", "List sources" do |value, options|
options[:list] = value
end
add_option '-r', '--remove SOURCE_URI', 'Remove source' do |value, options|
add_option "-r", "--remove SOURCE_URI", "Remove source" do |value, options|
options[:remove] = value
end
add_option '-c', '--clear-all',
'Remove all sources (clear the cache)' do |value, options|
add_option "-c", "--clear-all",
"Remove all sources (clear the cache)" do |value, options|
options[:clear_all] = value
end
add_option '-u', '--update', 'Update source cache' do |value, options|
add_option "-u", "--update", "Update source cache" do |value, options|
options[:update] = value
end
add_option '-f', '--[no-]force', "Do not show any confirmation prompts and behave as if 'yes' was always answered" do |value, options|
add_option "-f", "--[no-]force", "Do not show any confirmation prompts and behave as if 'yes' was always answered" do |value, options|
options[:force] = value
end
@ -82,8 +82,8 @@ Do you want to add this source?
def check_rubygems_https(source_uri) # :nodoc:
uri = URI source_uri
if uri.scheme and uri.scheme.downcase == 'http' and
uri.host.downcase == 'rubygems.org'
if uri.scheme and uri.scheme.downcase == "http" and
uri.host.downcase == "rubygems.org"
question = <<-QUESTION.chomp
https://rubygems.org is recommended for security over #{uri}
@ -112,7 +112,7 @@ Do you want to add this insecure source?
end
def defaults_str # :nodoc:
'--list'
"--list"
end
def description # :nodoc:
@ -138,8 +138,8 @@ do not recognize you should remove them.
RubyGems has been configured to serve gems via the following URLs through
its history:
* http://gems.rubyforge.org (RubyGems 1.3.6 and earlier)
* https://rubygems.org/ (RubyGems 1.3.7 through 1.8.25)
* http://gems.rubyforge.org (RubyGems 1.3.5 and earlier)
* http://rubygems.org (RubyGems 1.3.6 through 1.8.30, and 2.0.0)
* https://rubygems.org (RubyGems 2.0.1 and newer)
Since all of these sources point to the same set of gems you only need one

View file

@ -1,8 +1,8 @@
# frozen_string_literal: true
require_relative '../command'
require_relative '../local_remote_options'
require_relative '../version_option'
require_relative '../package'
require_relative "../command"
require_relative "../local_remote_options"
require_relative "../version_option"
require_relative "../package"
class Gem::Commands::SpecificationCommand < Gem::Command
include Gem::LocalRemoteOptions
@ -11,28 +11,28 @@ class Gem::Commands::SpecificationCommand < Gem::Command
def initialize
Gem.load_yaml
super 'specification', 'Display gem specification (in yaml)',
super "specification", "Display gem specification (in yaml)",
:domain => :local, :version => Gem::Requirement.default,
:format => :yaml
add_version_option('examine')
add_version_option("examine")
add_platform_option
add_prerelease_option
add_option('--all', 'Output specifications for all versions of',
'the gem') do |value, options|
add_option("--all", "Output specifications for all versions of",
"the gem") do |value, options|
options[:all] = true
end
add_option('--ruby', 'Output ruby format') do |value, options|
add_option("--ruby", "Output ruby format") do |value, options|
options[:format] = :ruby
end
add_option('--yaml', 'Output YAML format') do |value, options|
add_option("--yaml", "Output YAML format") do |value, options|
options[:format] = :yaml
end
add_option('--marshal', 'Output Marshal format') do |value, options|
add_option("--marshal", "Output Marshal format") do |value, options|
options[:format] = :marshal
end

View file

@ -1,9 +1,9 @@
# frozen_string_literal: true
require_relative '../command'
require_relative "../command"
class Gem::Commands::StaleCommand < Gem::Command
def initialize
super('stale', 'List gems along with access times')
super("stale", "List gems along with access times")
end
def description # :nodoc:

View file

@ -1,8 +1,8 @@
# frozen_string_literal: true
require_relative '../command'
require_relative '../version_option'
require_relative '../uninstaller'
require 'fileutils'
require_relative "../command"
require_relative "../version_option"
require_relative "../uninstaller"
require "fileutils"
##
# Gem uninstaller command line tool
@ -13,78 +13,78 @@ class Gem::Commands::UninstallCommand < Gem::Command
include Gem::VersionOption
def initialize
super 'uninstall', 'Uninstall gems from the local repository',
super "uninstall", "Uninstall gems from the local repository",
:version => Gem::Requirement.default, :user_install => true,
:check_dev => false, :vendor => false
add_option('-a', '--[no-]all',
'Uninstall all matching versions'
add_option("-a", "--[no-]all",
"Uninstall all matching versions"
) do |value, options|
options[:all] = value
end
add_option('-I', '--[no-]ignore-dependencies',
'Ignore dependency requirements while',
'uninstalling') do |value, options|
add_option("-I", "--[no-]ignore-dependencies",
"Ignore dependency requirements while",
"uninstalling") do |value, options|
options[:ignore] = value
end
add_option('-D', '--[no-]check-development',
'Check development dependencies while uninstalling',
'(default: false)') do |value, options|
add_option("-D", "--[no-]check-development",
"Check development dependencies while uninstalling",
"(default: false)") do |value, options|
options[:check_dev] = value
end
add_option('-x', '--[no-]executables',
'Uninstall applicable executables without',
'confirmation') do |value, options|
add_option("-x", "--[no-]executables",
"Uninstall applicable executables without",
"confirmation") do |value, options|
options[:executables] = value
end
add_option('-i', '--install-dir DIR',
'Directory to uninstall gem from') do |value, options|
add_option("-i", "--install-dir DIR",
"Directory to uninstall gem from") do |value, options|
options[:install_dir] = File.expand_path(value)
end
add_option('-n', '--bindir DIR',
'Directory to remove executables from') do |value, options|
add_option("-n", "--bindir DIR",
"Directory to remove executables from") do |value, options|
options[:bin_dir] = File.expand_path(value)
end
add_option('--[no-]user-install',
'Uninstall from user\'s home directory',
'in addition to GEM_HOME.') do |value, options|
add_option("--[no-]user-install",
"Uninstall from user's home directory",
"in addition to GEM_HOME.") do |value, options|
options[:user_install] = value
end
add_option('--[no-]format-executable',
'Assume executable names match Ruby\'s prefix and suffix.') do |value, options|
add_option("--[no-]format-executable",
"Assume executable names match Ruby's prefix and suffix.") do |value, options|
options[:format_executable] = value
end
add_option('--[no-]force',
'Uninstall all versions of the named gems',
'ignoring dependencies') do |value, options|
add_option("--[no-]force",
"Uninstall all versions of the named gems",
"ignoring dependencies") do |value, options|
options[:force] = value
end
add_option('--[no-]abort-on-dependent',
'Prevent uninstalling gems that are',
'depended on by other gems.') do |value, options|
add_option("--[no-]abort-on-dependent",
"Prevent uninstalling gems that are",
"depended on by other gems.") do |value, options|
options[:abort_on_dependent] = value
end
add_version_option
add_platform_option
add_option('--vendor',
'Uninstall gem from the vendor directory.',
'Only for use by gem repackagers.') do |value, options|
add_option("--vendor",
"Uninstall gem from the vendor directory.",
"Only for use by gem repackagers.") do |value, options|
unless Gem.vendor_dir
raise Gem::OptionParser::InvalidOption.new 'your platform is not supported'
raise Gem::OptionParser::InvalidOption.new "your platform is not supported"
end
alert_warning 'Use your OS package manager to uninstall vendor gems'
alert_warning "Use your OS package manager to uninstall vendor gems"
options[:vendor] = true
options[:install_dir] = Gem.vendor_dir
end

View file

@ -1,9 +1,9 @@
# frozen_string_literal: true
require_relative '../command'
require_relative '../version_option'
require_relative '../security_option'
require_relative '../remote_fetcher'
require_relative '../package'
require_relative "../command"
require_relative "../version_option"
require_relative "../security_option"
require_relative "../remote_fetcher"
require_relative "../package"
# forward-declare
@ -17,18 +17,18 @@ class Gem::Commands::UnpackCommand < Gem::Command
include Gem::SecurityOption
def initialize
require 'fileutils'
require "fileutils"
super 'unpack', 'Unpack an installed gem to the current directory',
super "unpack", "Unpack an installed gem to the current directory",
:version => Gem::Requirement.default,
:target => Dir.pwd
add_option('--target=DIR',
'target directory for unpacking') do |value, options|
add_option("--target=DIR",
"target directory for unpacking") do |value, options|
options[:target] = value
end
add_option('--spec', 'unpack the gem specification') do |value, options|
add_option("--spec", "unpack the gem specification") do |value, options|
options[:spec] = true
end
@ -103,11 +103,11 @@ command help for an example.
end
end
File.open destination, 'w' do |io|
File.open destination, "w" do |io|
io.write metadata
end
else
basename = File.basename path, '.gem'
basename = File.basename path, ".gem"
target_dir = File.expand_path basename, options[:target]
package = Gem::Package.new path, security_policy

View file

@ -1,13 +1,13 @@
# frozen_string_literal: true
require_relative '../command'
require_relative '../command_manager'
require_relative '../dependency_installer'
require_relative '../install_update_options'
require_relative '../local_remote_options'
require_relative '../spec_fetcher'
require_relative '../version_option'
require_relative '../install_message' # must come before rdoc for messaging
require_relative '../rdoc'
require_relative "../command"
require_relative "../command_manager"
require_relative "../dependency_installer"
require_relative "../install_update_options"
require_relative "../local_remote_options"
require_relative "../spec_fetcher"
require_relative "../version_option"
require_relative "../install_message" # must come before rdoc for messaging
require_relative "../rdoc"
class Gem::Commands::UpdateCommand < Gem::Command
include Gem::InstallUpdateOptions
@ -25,7 +25,7 @@ class Gem::Commands::UpdateCommand < Gem::Command
options.merge!(install_update_options)
super 'update', 'Update installed gems to the latest version', options
super "update", "Update installed gems to the latest version", options
add_install_update_options
@ -35,8 +35,8 @@ class Gem::Commands::UpdateCommand < Gem::Command
value
end
add_option('--system [VERSION]', Gem::Version,
'Update the RubyGems system software') do |value, options|
add_option("--system [VERSION]", Gem::Version,
"Update the RubyGems system software") do |value, options|
value = true unless value
options[:system] = value
@ -166,13 +166,8 @@ command to remove old versions.
def highest_remote_name_tuple(spec) # :nodoc:
spec_tuples = fetch_remote_gems spec
matching_gems = spec_tuples.select do |g,_|
g.name == spec.name and g.match_platform?
end
highest_remote_gem = matching_gems.max
highest_remote_gem ||= [Gem::NameTuple.null]
highest_remote_gem = spec_tuples.max
return unless highest_remote_gem
highest_remote_gem.first
end
@ -181,13 +176,13 @@ command to remove old versions.
args = update_rubygems_arguments
version = spec.version
update_dir = File.join spec.base_dir, 'gems', "rubygems-update-#{version}"
update_dir = File.join spec.base_dir, "gems", "rubygems-update-#{version}"
Dir.chdir update_dir do
say "Installing RubyGems #{version}" unless options[:silent]
installed = preparing_gem_layout_for(version) do
system Gem.ruby, '--disable-gems', 'setup.rb', *args
system Gem.ruby, "--disable-gems", "setup.rb", *args
end
say "RubyGems system software updated" if installed unless options[:silent]
@ -218,30 +213,22 @@ command to remove old versions.
version = options[:system]
update_latest = version == true
if update_latest
version = Gem::Version.new Gem::VERSION
requirement = Gem::Requirement.new ">= #{Gem::VERSION}"
else
unless update_latest
version = Gem::Version.new version
requirement = Gem::Requirement.new version
return version, requirement
end
version = Gem::Version.new Gem::VERSION
requirement = Gem::Requirement.new ">= #{Gem::VERSION}"
rubygems_update = Gem::Specification.new
rubygems_update.name = 'rubygems-update'
rubygems_update.name = "rubygems-update"
rubygems_update.version = version
hig = {
'rubygems-update' => rubygems_update,
}
gems_to_update = which_to_update hig, options[:args], :system
up_ver = gems_to_update.first.version
target = if update_latest
up_ver
else
version
end
highest_remote_tup = highest_remote_name_tuple(rubygems_update)
target = highest_remote_tup ? highest_remote_tup.version : version
return target, requirement
end
@ -291,8 +278,8 @@ command to remove old versions.
check_oldest_rubygems version
installed_gems = Gem::Specification.find_all_by_name 'rubygems-update', requirement
installed_gems = update_gem('rubygems-update', version) if installed_gems.empty? || installed_gems.first.version != version
installed_gems = Gem::Specification.find_all_by_name "rubygems-update", requirement
installed_gems = update_gem("rubygems-update", version) if installed_gems.empty? || installed_gems.first.version != version
return if installed_gems.empty?
install_rubygems installed_gems.first
@ -300,17 +287,17 @@ command to remove old versions.
def update_rubygems_arguments # :nodoc:
args = []
args << '--silent' if options[:silent]
args << '--prefix' << Gem.prefix if Gem.prefix
args << '--no-document' unless options[:document].include?('rdoc') || options[:document].include?('ri')
args << '--no-format-executable' if options[:no_format_executable]
args << '--previous-version' << Gem::VERSION if
args << "--silent" if options[:silent]
args << "--prefix" << Gem.prefix if Gem.prefix
args << "--no-document" unless options[:document].include?("rdoc") || options[:document].include?("ri")
args << "--no-format-executable" if options[:no_format_executable]
args << "--previous-version" << Gem::VERSION if
options[:system] == true or
Gem::Version.new(options[:system]) >= Gem::Version.new(2)
args
end
def which_to_update(highest_installed_gems, gem_names, system = false)
def which_to_update(highest_installed_gems, gem_names)
result = []
highest_installed_gems.each do |l_name, l_spec|
@ -318,12 +305,9 @@ command to remove old versions.
gem_names.none? {|name| name == l_spec.name }
highest_remote_tup = highest_remote_name_tuple l_spec
highest_remote_ver = highest_remote_tup.version
highest_installed_ver = l_spec.version
next unless highest_remote_tup
if system or (highest_installed_ver < highest_remote_ver)
result << Gem::NameTuple.new(l_spec.name, [highest_installed_ver, highest_remote_ver].max, highest_remote_tup.platform)
end
result << highest_remote_tup
end
result

View file

@ -1,17 +1,17 @@
# frozen_string_literal: true
require_relative '../command'
require_relative "../command"
class Gem::Commands::WhichCommand < Gem::Command
def initialize
super 'which', 'Find the location of a library file you can require',
super "which", "Find the location of a library file you can require",
:search_gems_first => false, :show_all => false
add_option '-a', '--[no-]all', 'show all matching files' do |show_all, options|
add_option "-a", "--[no-]all", "show all matching files" do |show_all, options|
options[:show_all] = show_all
end
add_option '-g', '--[no-]gems-first',
'search gems before non-gems' do |gems_first, options|
add_option "-g", "--[no-]gems-first",
"search gems before non-gems" do |gems_first, options|
options[:search_gems_first] = gems_first
end
end
@ -39,7 +39,7 @@ requiring to see why it does not behave as you expect.
found = true
options[:args].each do |arg|
arg = arg.sub(/#{Regexp.union(*Gem.suffixes)}$/, '')
arg = arg.sub(/#{Regexp.union(*Gem.suffixes)}$/, "")
dirs = $LOAD_PATH
spec = Gem::Specification.find_by_path arg

View file

@ -1,8 +1,8 @@
# frozen_string_literal: true
require_relative '../command'
require_relative '../local_remote_options'
require_relative '../version_option'
require_relative '../gemcutter_utilities'
require_relative "../command"
require_relative "../local_remote_options"
require_relative "../version_option"
require_relative "../gemcutter_utilities"
class Gem::Commands::YankCommand < Gem::Command
include Gem::LocalRemoteOptions
@ -28,15 +28,15 @@ data you will need to change them immediately and yank your gem.
end
def initialize
super 'yank', 'Remove a pushed gem from the index'
super "yank", "Remove a pushed gem from the index"
add_version_option("remove")
add_platform_option("remove")
add_otp_option
add_option('--host HOST',
'Yank from another gemcutter-compatible host',
' (e.g. https://rubygems.org)') do |value, options|
add_option("--host HOST",
"Yank from another gemcutter-compatible host",
" (e.g. https://rubygems.org)") do |value, options|
options[:host] = value
end
@ -76,10 +76,10 @@ data you will need to change them immediately and yank your gem.
request.add_field("Authorization", api_key)
data = {
'gem_name' => name,
'version' => version,
"gem_name" => name,
"version" => version,
}
data['platform'] = platform if platform
data["platform"] = platform if platform
request.set_form_data data
end