diff options
author | Takuya Noguchi <[email protected]> | 2022-07-17 08:08:51 +0000 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2022-07-22 12:07:23 +0900 |
commit | d7ffd3fea402239b16833cc434404a7af82d44f3 (patch) | |
tree | 9794942135111c36e6b6bce69e070ca556b89028 /lib/rubygems | |
parent | 388c4e1076ac5a58d5008abc8e0a8d017698875a (diff) |
RubyGems: Enable Style/StringLiterals cop
Signed-off-by: Takuya Noguchi <[email protected]>
Diffstat (limited to 'lib/rubygems')
137 files changed, 1324 insertions, 1324 deletions
diff --git a/lib/rubygems/basic_specification.rb b/lib/rubygems/basic_specification.rb index b3b63b51aa..526a5069c2 100644 --- a/lib/rubygems/basic_specification.rb +++ b/lib/rubygems/basic_specification.rb @@ -47,7 +47,7 @@ class Gem::BasicSpecification # directory. def gem_build_complete_path # :nodoc: - File.join extension_dir, 'gem.build_complete' + File.join extension_dir, "gem.build_complete" end ## @@ -103,7 +103,7 @@ class Gem::BasicSpecification def extensions_dir Gem.default_ext_dir_for(base_dir) || - File.join(base_dir, 'extensions', Gem::Platform.local.to_s, + File.join(base_dir, "extensions", Gem::Platform.local.to_s, Gem.extension_api_version) end diff --git a/lib/rubygems/command.rb b/lib/rubygems/command.rb index f74cb419f9..9fc3360fa1 100644 --- a/lib/rubygems/command.rb +++ b/lib/rubygems/command.rb @@ -5,9 +5,9 @@ # See LICENSE.txt for permissions. #++ -require_relative 'optparse' -require_relative 'requirement' -require_relative 'user_interaction' +require_relative "optparse" +require_relative "requirement" +require_relative "user_interaction" ## # Base class for all Gem commands. When creating a new gem command, define @@ -76,7 +76,7 @@ class Gem::Command when Array @extra_args = value when String - @extra_args = value.split(' ') + @extra_args = value.split(" ") end end @@ -556,7 +556,7 @@ class Gem::Command def configure_options(header, option_list) return if option_list.nil? or option_list.empty? - header = header.to_s.empty? ? '' : "#{header} " + header = header.to_s.empty? ? "" : "#{header} " @parser.separator " #{header}Options:" option_list.each do |args, handler| @@ -565,7 +565,7 @@ class Gem::Command end end - @parser.separator '' + @parser.separator "" end ## @@ -578,13 +578,13 @@ class Gem::Command # ---------------------------------------------------------------- # Add the options common to all commands. - add_common_option('-h', '--help', - 'Get help on this command') do |value, options| + add_common_option("-h", "--help", + "Get help on this command") do |value, options| options[:help] = true end - add_common_option('-V', '--[no-]verbose', - 'Set the verbose level of output') do |value, options| + add_common_option("-V", "--[no-]verbose", + "Set the verbose level of output") do |value, options| # Set us to "really verbose" so the progress meter works if Gem.configuration.verbose and value Gem.configuration.verbose = 1 @@ -593,7 +593,7 @@ class Gem::Command end end - add_common_option('-q', '--quiet', 'Silence command progress meter') do |value, options| + add_common_option("-q", "--quiet", "Silence command progress meter") do |value, options| Gem.configuration.verbose = false end @@ -606,20 +606,20 @@ class Gem::Command # commands. Both options are actually handled before the other # options get parsed. - add_common_option('--config-file FILE', - 'Use this config file instead of default') do + add_common_option("--config-file FILE", + "Use this config file instead of default") do end - add_common_option('--backtrace', - 'Show stack backtrace on errors') do + add_common_option("--backtrace", + "Show stack backtrace on errors") do end - add_common_option('--debug', - 'Turn on Ruby debugging') do + add_common_option("--debug", + "Turn on Ruby debugging") do end - add_common_option('--norc', - 'Avoid loading any .gemrc file') do + add_common_option("--norc", + "Avoid loading any .gemrc file") do end # :stopdoc: diff --git a/lib/rubygems/command_manager.rb b/lib/rubygems/command_manager.rb index e421f89884..9d49138ae7 100644 --- a/lib/rubygems/command_manager.rb +++ b/lib/rubygems/command_manager.rb @@ -5,9 +5,9 @@ # See LICENSE.txt for permissions. #++ -require_relative 'command' -require_relative 'user_interaction' -require_relative 'text' +require_relative "command" +require_relative "user_interaction" +require_relative "text" ## # The command manager registers and installs all the individual sub-commands @@ -73,9 +73,9 @@ class Gem::CommandManager ].freeze ALIAS_COMMANDS = { - 'i' => 'install', - 'login' => 'signin', - 'logout' => 'signout', + "i" => "install", + "login" => "signin", + "logout" => "signout", }.freeze ## @@ -104,7 +104,7 @@ class Gem::CommandManager # Register all the subcommands supported by the gem command. def initialize - require 'timeout' + require "timeout" @commands = {} BUILTIN_COMMANDS.each do |name| @@ -169,10 +169,10 @@ class Gem::CommandManager end case args.first - when '-h', '--help' then + when "-h", "--help" then say Gem::Command::HELP terminate_interaction 0 - when '-v', '--version' then + when "-v", "--version" then say Gem::VERSION terminate_interaction 0 when /^-/ then diff --git a/lib/rubygems/commands/build_command.rb b/lib/rubygems/commands/build_command.rb index 6d1a057dfa..accbd7e97d 100644 --- a/lib/rubygems/commands/build_command.rb +++ b/lib/rubygems/commands/build_command.rb @@ -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 diff --git a/lib/rubygems/commands/cert_command.rb b/lib/rubygems/commands/cert_command.rb index b59564d575..56bf5ce689 100644 --- a/lib/rubygems/commands/cert_command.rb +++ b/lib/rubygems/commands/cert_command.rb @@ -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 diff --git a/lib/rubygems/commands/check_command.rb b/lib/rubygems/commands/check_command.rb index 3b6b97ae3b..4d1f8782b1 100644 --- a/lib/rubygems/commands/check_command.rb +++ b/lib/rubygems/commands/check_command.rb @@ -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: diff --git a/lib/rubygems/commands/cleanup_command.rb b/lib/rubygems/commands/cleanup_command.rb index dc181e4de0..7f143999eb 100644 --- a/lib/rubygems/commands/cleanup_command.rb +++ b/lib/rubygems/commands/cleanup_command.rb @@ -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 diff --git a/lib/rubygems/commands/contents_command.rb b/lib/rubygems/commands/contents_command.rb index 716022c458..3dd0b16265 100644 --- a/lib/rubygems/commands/contents_command.rb +++ b/lib/rubygems/commands/contents_command.rb @@ -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 diff --git a/lib/rubygems/commands/dependency_command.rb b/lib/rubygems/commands/dependency_command.rb index d2fed022fe..c9ddc9af0a 100644 --- a/lib/rubygems/commands/dependency_command.rb +++ b/lib/rubygems/commands/dependency_command.rb @@ -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 diff --git a/lib/rubygems/commands/environment_command.rb b/lib/rubygems/commands/environment_command.rb index b6b3d3812c..d95e1d0dbb 100644 --- a/lib/rubygems/commands/environment_command.rb +++ b/lib/rubygems/commands/environment_command.rb @@ -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 diff --git a/lib/rubygems/commands/fetch_command.rb b/lib/rubygems/commands/fetch_command.rb index c8ecb0d48c..582563ba81 100644 --- a/lib/rubygems/commands/fetch_command.rb +++ b/lib/rubygems/commands/fetch_command.rb @@ -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: diff --git a/lib/rubygems/commands/generate_index_command.rb b/lib/rubygems/commands/generate_index_command.rb index 87200dab91..8bb24c9ce3 100644 --- a/lib/rubygems/commands/generate_index_command.rb +++ b/lib/rubygems/commands/generate_index_command.rb @@ -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 diff --git a/lib/rubygems/commands/help_command.rb b/lib/rubygems/commands/help_command.rb index 7f3383c9f3..8bfb4458ff 100644 --- a/lib/rubygems/commands/help_command.rb +++ b/lib/rubygems/commands/help_command.rb @@ -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| diff --git a/lib/rubygems/commands/info_command.rb b/lib/rubygems/commands/info_command.rb index 3f2dd4ae0b..ced7751ff5 100644 --- a/lib/rubygems/commands/info_command.rb +++ b/lib/rubygems/commands/info_command.rb @@ -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 diff --git a/lib/rubygems/commands/install_command.rb b/lib/rubygems/commands/install_command.rb index 87563accb0..690f90c2e4 100644 --- a/lib/rubygems/commands/install_command.rb +++ b/lib/rubygems/commands/install_command.rb @@ -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 diff --git a/lib/rubygems/commands/list_command.rb b/lib/rubygems/commands/list_command.rb index 010d968f9c..011873b99c 100644 --- a/lib/rubygems/commands/list_command.rb +++ b/lib/rubygems/commands/list_command.rb @@ -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 diff --git a/lib/rubygems/commands/lock_command.rb b/lib/rubygems/commands/lock_command.rb index cb6229a2cb..da636492c9 100644 --- a/lib/rubygems/commands/lock_command.rb +++ b/lib/rubygems/commands/lock_command.rb @@ -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 diff --git a/lib/rubygems/commands/mirror_command.rb b/lib/rubygems/commands/mirror_command.rb index 7daa47e2f0..b633cd3d81 100644 --- a/lib/rubygems/commands/mirror_command.rb +++ b/lib/rubygems/commands/mirror_command.rb @@ -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 diff --git a/lib/rubygems/commands/open_command.rb b/lib/rubygems/commands/open_command.rb index 1e616fd68f..d5283f72dd 100644 --- a/lib/rubygems/commands/open_command.rb +++ b/lib/rubygems/commands/open_command.rb @@ -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 diff --git a/lib/rubygems/commands/outdated_command.rb b/lib/rubygems/commands/outdated_command.rb index 162d338320..1785194389 100644 --- a/lib/rubygems/commands/outdated_command.rb +++ b/lib/rubygems/commands/outdated_command.rb @@ -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 diff --git a/lib/rubygems/commands/owner_command.rb b/lib/rubygems/commands/owner_command.rb index 42b0d79135..4a0f7aa3e4 100644 --- a/lib/rubygems/commands/owner_command.rb +++ b/lib/rubygems/commands/owner_command.rb @@ -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 diff --git a/lib/rubygems/commands/pristine_command.rb b/lib/rubygems/commands/pristine_command.rb index 030c1bffce..d4dadf0736 100644 --- a/lib/rubygems/commands/pristine_command.rb +++ b/lib/rubygems/commands/pristine_command.rb @@ -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] diff --git a/lib/rubygems/commands/push_command.rb b/lib/rubygems/commands/push_command.rb index 4d0d5a9f4b..46b65f4e15 100644 --- a/lib/rubygems/commands/push_command.rb +++ b/lib/rubygems/commands/push_command.rb @@ -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 diff --git a/lib/rubygems/commands/query_command.rb b/lib/rubygems/commands/query_command.rb index 442c4b19bb..c6315acf8c 100644 --- a/lib/rubygems/commands/query_command.rb +++ b/lib/rubygems/commands/query_command.rb @@ -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 diff --git a/lib/rubygems/commands/rdoc_command.rb b/lib/rubygems/commands/rdoc_command.rb index 7c5d6212f5..17ad6f836b 100644 --- a/lib/rubygems/commands/rdoc_command.rb +++ b/lib/rubygems/commands/rdoc_command.rb @@ -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 diff --git a/lib/rubygems/commands/search_command.rb b/lib/rubygems/commands/search_command.rb index 75d99986f9..3f8f7e13f2 100644 --- a/lib/rubygems/commands/search_command.rb +++ b/lib/rubygems/commands/search_command.rb @@ -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 diff --git a/lib/rubygems/commands/server_command.rb b/lib/rubygems/commands/server_command.rb index f8cad3b5db..56be07c79d 100644 --- a/lib/rubygems/commands/server_command.rb +++ b/lib/rubygems/commands/server_command.rb @@ -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 diff --git a/lib/rubygems/commands/setup_command.rb b/lib/rubygems/commands/setup_command.rb index db2fefa65e..1ed889a713 100644 --- a/lib/rubygems/commands/setup_command.rb +++ b/lib/rubygems/commands/setup_command.rb @@ -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 @@ -397,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) @@ -439,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) @@ -454,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)] @@ -465,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| @@ -486,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} @@ -496,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) @@ -512,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) @@ -542,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 @@ -573,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 @@ -625,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) diff --git a/lib/rubygems/commands/signin_command.rb b/lib/rubygems/commands/signin_command.rb index 23bb2f937f..2660eee4f3 100644 --- a/lib/rubygems/commands/signin_command.rb +++ b/lib/rubygems/commands/signin_command.rb @@ -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: diff --git a/lib/rubygems/commands/signout_command.rb b/lib/rubygems/commands/signout_command.rb index c9485e0c1b..fa688ea3f8 100644 --- a/lib/rubygems/commands/signout_command.rb +++ b/lib/rubygems/commands/signout_command.rb @@ -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 diff --git a/lib/rubygems/commands/sources_command.rb b/lib/rubygems/commands/sources_command.rb index 884d9445c9..a5f2d022c6 100644 --- a/lib/rubygems/commands/sources_command.rb +++ b/lib/rubygems/commands/sources_command.rb @@ -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: diff --git a/lib/rubygems/commands/specification_command.rb b/lib/rubygems/commands/specification_command.rb index 6fba3a36ec..6457a755ae 100644 --- a/lib/rubygems/commands/specification_command.rb +++ b/lib/rubygems/commands/specification_command.rb @@ -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 diff --git a/lib/rubygems/commands/stale_command.rb b/lib/rubygems/commands/stale_command.rb index 62a97966f1..0246f42e3e 100644 --- a/lib/rubygems/commands/stale_command.rb +++ b/lib/rubygems/commands/stale_command.rb @@ -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: diff --git a/lib/rubygems/commands/uninstall_command.rb b/lib/rubygems/commands/uninstall_command.rb index 467c8bf7ed..d03a96bf87 100644 --- a/lib/rubygems/commands/uninstall_command.rb +++ b/lib/rubygems/commands/uninstall_command.rb @@ -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 diff --git a/lib/rubygems/commands/unpack_command.rb b/lib/rubygems/commands/unpack_command.rb index 3f1708375f..a365e85416 100644 --- a/lib/rubygems/commands/unpack_command.rb +++ b/lib/rubygems/commands/unpack_command.rb @@ -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 diff --git a/lib/rubygems/commands/update_command.rb b/lib/rubygems/commands/update_command.rb index 04ce0ea935..a079642669 100644 --- a/lib/rubygems/commands/update_command.rb +++ b/lib/rubygems/commands/update_command.rb @@ -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 @@ -176,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] @@ -224,7 +224,7 @@ command to remove old versions. 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 highest_remote_tup = highest_remote_name_tuple(rubygems_update) @@ -278,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 @@ -287,11 +287,11 @@ 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 diff --git a/lib/rubygems/commands/which_command.rb b/lib/rubygems/commands/which_command.rb index 44e87a2b98..78493e9380 100644 --- a/lib/rubygems/commands/which_command.rb +++ b/lib/rubygems/commands/which_command.rb @@ -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 diff --git a/lib/rubygems/commands/yank_command.rb b/lib/rubygems/commands/yank_command.rb index cad78aec5f..1499f72f5d 100644 --- a/lib/rubygems/commands/yank_command.rb +++ b/lib/rubygems/commands/yank_command.rb @@ -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 diff --git a/lib/rubygems/config_file.rb b/lib/rubygems/config_file.rb index 5dd2bfe88d..d711a51bd0 100644 --- a/lib/rubygems/config_file.rb +++ b/lib/rubygems/config_file.rb @@ -5,8 +5,8 @@ # See LICENSE.txt for permissions. #++ -require_relative 'user_interaction' -require 'rbconfig' +require_relative "user_interaction" +require "rbconfig" ## # Gem::ConfigFile RubyGems options and gem command options from gemrc. @@ -71,7 +71,7 @@ class Gem::ConfigFile # :startdoc: - SYSTEM_WIDE_CONFIG_FILE = File.join SYSTEM_CONFIG_PATH, 'gemrc' + SYSTEM_WIDE_CONFIG_FILE = File.join SYSTEM_CONFIG_PATH, "gemrc" ## # List of arguments supplied to the config file object. @@ -182,20 +182,20 @@ class Gem::ConfigFile @update_sources = DEFAULT_UPDATE_SOURCES @concurrent_downloads = DEFAULT_CONCURRENT_DOWNLOADS @cert_expiration_length_days = DEFAULT_CERT_EXPIRATION_LENGTH_DAYS - @ipv4_fallback_enabled = ENV['IPV4_FALLBACK_ENABLED'] == 'true' || DEFAULT_IPV4_FALLBACK_ENABLED + @ipv4_fallback_enabled = ENV["IPV4_FALLBACK_ENABLED"] == "true" || DEFAULT_IPV4_FALLBACK_ENABLED operating_system_config = Marshal.load Marshal.dump(OPERATING_SYSTEM_DEFAULTS) platform_config = Marshal.load Marshal.dump(PLATFORM_DEFAULTS) system_config = load_file SYSTEM_WIDE_CONFIG_FILE user_config = load_file config_file_name.dup.tap(&Gem::UNTAINT) - environment_config = (ENV['GEMRC'] || '') + environment_config = (ENV["GEMRC"] || "") .split(File::PATH_SEPARATOR).inject({}) do |result, file| result.merge load_file file end @hash = operating_system_config.merge platform_config - unless args.index '--norc' + unless args.index "--norc" @hash = @hash.merge system_config @hash = @hash.merge user_config @hash = @hash.merge environment_config @@ -269,7 +269,7 @@ if you believe they were disclosed to a third party. # Location of RubyGems.org credentials def credentials_path - credentials = File.join Gem.user_home, '.gem', 'credentials' + credentials = File.join Gem.user_home, ".gem", "credentials" if File.exist? credentials credentials else @@ -320,13 +320,13 @@ if you believe they were disclosed to a third party. config = load_file(credentials_path).merge(host => api_key) dirname = File.dirname credentials_path - require 'fileutils' + require "fileutils" FileUtils.mkdir_p(dirname) Gem.load_yaml permissions = 0600 & (~File.umask) - File.open(credentials_path, 'w', permissions) do |f| + File.open(credentials_path, "w", permissions) do |f| f.write config.to_yaml end @@ -389,7 +389,7 @@ if you believe they were disclosed to a third party. yield :backtrace, @backtrace yield :bulk_threshold, @bulk_threshold - yield 'config_file_name', @config_file_name if @config_file_name + yield "config_file_name", @config_file_name if @config_file_name hash.each(&block) end @@ -405,7 +405,7 @@ if you believe they were disclosed to a third party. when /^--debug$/ then $DEBUG = true - warn 'NOTE: Debugging mode prints all exceptions even when rescued' + warn "NOTE: Debugging mode prints all exceptions even when rescued" else @args << arg end @@ -444,7 +444,7 @@ if you believe they were disclosed to a third party. @hash[:ssl_client_cert] if @hash.key? :ssl_client_cert keys = yaml_hash.keys.map {|key| key.to_s } - keys << 'debug' + keys << "debug" re = Regexp.union(*keys) @hash.each do |key, value| @@ -458,10 +458,10 @@ if you believe they were disclosed to a third party. # Writes out this config file, replacing its source. def write - require 'fileutils' + require "fileutils" FileUtils.mkdir_p File.dirname(config_file_name) - File.open config_file_name, 'w' do |io| + File.open config_file_name, "w" do |io| io.write to_yaml end end diff --git a/lib/rubygems/core_ext/kernel_gem.rb b/lib/rubygems/core_ext/kernel_gem.rb index e722225739..6f96cab84f 100644 --- a/lib/rubygems/core_ext/kernel_gem.rb +++ b/lib/rubygems/core_ext/kernel_gem.rb @@ -39,7 +39,7 @@ module Kernel # GEM_SKIP=libA:libB ruby -I../libA -I../libB ./mycode.rb def gem(gem_name, *requirements) # :doc: - skip_list = (ENV['GEM_SKIP'] || "").split(/:/) + skip_list = (ENV["GEM_SKIP"] || "").split(/:/) raise Gem::LoadError, "skipping #{gem_name}" if skip_list.include? gem_name if gem_name.kind_of? Gem::Dependency diff --git a/lib/rubygems/core_ext/kernel_require.rb b/lib/rubygems/core_ext/kernel_require.rb index 23badd75d2..8064d813e1 100644 --- a/lib/rubygems/core_ext/kernel_require.rb +++ b/lib/rubygems/core_ext/kernel_require.rb @@ -5,7 +5,7 @@ # See LICENSE.txt for permissions. #++ -require 'monitor' +require "monitor" module Kernel diff --git a/lib/rubygems/core_ext/kernel_warn.rb b/lib/rubygems/core_ext/kernel_warn.rb index 3373cfdd3b..7df6c48b8f 100644 --- a/lib/rubygems/core_ext/kernel_warn.rb +++ b/lib/rubygems/core_ext/kernel_warn.rb @@ -39,7 +39,7 @@ if RUBY_VERSION >= "2.5" && !Gem::KERNEL_WARN_IGNORES_INTERNAL_ENTRIES start += 1 if path = loc.path - unless path.start_with?(rubygems_path) or path.start_with?('<internal:') + unless path.start_with?(rubygems_path) or path.start_with?("<internal:") # Non-rubygems frames uplevel -= 1 end diff --git a/lib/rubygems/core_ext/tcpsocket_init.rb b/lib/rubygems/core_ext/tcpsocket_init.rb index 2a79b63bd6..c9e0a92953 100644 --- a/lib/rubygems/core_ext/tcpsocket_init.rb +++ b/lib/rubygems/core_ext/tcpsocket_init.rb @@ -1,4 +1,4 @@ -require 'socket' +require "socket" module CoreExtensions module TCPSocketExt diff --git a/lib/rubygems/defaults.rb b/lib/rubygems/defaults.rb index 39b69ddb1c..d27f286265 100644 --- a/lib/rubygems/defaults.rb +++ b/lib/rubygems/defaults.rb @@ -20,10 +20,10 @@ module Gem # specified in the environment def self.default_spec_cache_dir - default_spec_cache_dir = File.join Gem.user_home, '.gem', 'specs' + default_spec_cache_dir = File.join Gem.user_home, ".gem", "specs" unless File.exist?(default_spec_cache_dir) - default_spec_cache_dir = File.join Gem.data_home, 'gem', 'specs' + default_spec_cache_dir = File.join Gem.data_home, "gem", "specs" end default_spec_cache_dir @@ -34,7 +34,7 @@ module Gem # specified in the environment def self.default_dir - @default_dir ||= File.join(RbConfig::CONFIG['rubylibprefix'], 'gems', RbConfig::CONFIG['ruby_version']) + @default_dir ||= File.join(RbConfig::CONFIG["rubylibprefix"], "gems", RbConfig::CONFIG["ruby_version"]) end ## @@ -81,7 +81,7 @@ module Gem Dir.home.dup rescue if Gem.win_platform? - File.expand_path File.join(ENV['HOMEDRIVE'] || ENV['SystemDrive'], '/') + File.expand_path File.join(ENV["HOMEDRIVE"] || ENV["SystemDrive"], "/") else File.expand_path "/" end @@ -103,7 +103,7 @@ module Gem gem_dir = File.join(Gem.user_home, ".gem") gem_dir = File.join(Gem.data_home, "gem") unless File.exist?(gem_dir) parts = [gem_dir, ruby_engine] - parts << RbConfig::CONFIG['ruby_version'] unless RbConfig::CONFIG['ruby_version'].empty? + parts << RbConfig::CONFIG["ruby_version"] unless RbConfig::CONFIG["ruby_version"].empty? File.join parts end @@ -111,14 +111,14 @@ module Gem # The path to standard location of the user's configuration directory. def self.config_home - @config_home ||= (ENV["XDG_CONFIG_HOME"] || File.join(Gem.user_home, '.config')) + @config_home ||= (ENV["XDG_CONFIG_HOME"] || File.join(Gem.user_home, ".config")) end ## # Finds the user's config file def self.find_config_file - gemrc = File.join Gem.user_home, '.gemrc' + gemrc = File.join Gem.user_home, ".gemrc" if File.exist? gemrc gemrc else @@ -137,14 +137,14 @@ module Gem # The path to standard location of the user's cache directory. def self.cache_home - @cache_home ||= (ENV["XDG_CACHE_HOME"] || File.join(Gem.user_home, '.cache')) + @cache_home ||= (ENV["XDG_CACHE_HOME"] || File.join(Gem.user_home, ".cache")) end ## # The path to standard location of the user's data directory. def self.data_home - @data_home ||= (ENV["XDG_DATA_HOME"] || File.join(Gem.user_home, '.local', 'share')) + @data_home ||= (ENV["XDG_DATA_HOME"] || File.join(Gem.user_home, ".local", "share")) end ## @@ -169,7 +169,7 @@ module Gem # Deduce Ruby's --program-prefix and --program-suffix from its install name def self.default_exec_format - exec_format = RbConfig::CONFIG['ruby_install_name'].sub('ruby', '%s') rescue '%s' + exec_format = RbConfig::CONFIG["ruby_install_name"].sub("ruby", "%s") rescue "%s" unless exec_format =~ /%s/ raise Gem::Exception, @@ -183,7 +183,7 @@ module Gem # The default directory for binaries def self.default_bindir - RbConfig::CONFIG['bindir'] + RbConfig::CONFIG["bindir"] end def self.ruby_engine @@ -227,14 +227,14 @@ module Gem # Directory where vendor gems are installed. def self.vendor_dir # :nodoc: - if vendor_dir = ENV['GEM_VENDOR'] + if vendor_dir = ENV["GEM_VENDOR"] return vendor_dir.dup end - return nil unless RbConfig::CONFIG.key? 'vendordir' + return nil unless RbConfig::CONFIG.key? "vendordir" - File.join RbConfig::CONFIG['vendordir'], 'gems', - RbConfig::CONFIG['ruby_version'] + File.join RbConfig::CONFIG["vendordir"], "gems", + RbConfig::CONFIG["ruby_version"] end ## diff --git a/lib/rubygems/dependency.rb b/lib/rubygems/dependency.rb index 3640362364..c561db1af2 100644 --- a/lib/rubygems/dependency.rb +++ b/lib/rubygems/dependency.rb @@ -97,14 +97,14 @@ class Gem::Dependency end def pretty_print(q) # :nodoc: - q.group 1, 'Gem::Dependency.new(', ')' do + q.group 1, "Gem::Dependency.new(", ")" do q.pp name - q.text ',' + q.text "," q.breakable q.pp requirement - q.text ',' + q.text "," q.breakable q.pp type @@ -197,7 +197,7 @@ class Gem::Dependency reqs = other.requirement.requirements return false unless reqs.length == 1 - return false unless reqs.first.first == '=' + return false unless reqs.first.first == "=" version = reqs.first.last diff --git a/lib/rubygems/dependency_installer.rb b/lib/rubygems/dependency_installer.rb index 913bba32eb..acdad6b98f 100644 --- a/lib/rubygems/dependency_installer.rb +++ b/lib/rubygems/dependency_installer.rb @@ -1,12 +1,12 @@ # frozen_string_literal: true -require_relative '../rubygems' -require_relative 'dependency_list' -require_relative 'package' -require_relative 'installer' -require_relative 'spec_fetcher' -require_relative 'user_interaction' -require_relative 'available_set' -require_relative 'deprecate' +require_relative "../rubygems" +require_relative "dependency_list" +require_relative "package" +require_relative "installer" +require_relative "spec_fetcher" +require_relative "user_interaction" +require_relative "available_set" +require_relative "deprecate" ## # Installs a gem along with all its dependencies from local and remote gems. diff --git a/lib/rubygems/dependency_list.rb b/lib/rubygems/dependency_list.rb index 10e08fc703..3cecb1e536 100644 --- a/lib/rubygems/dependency_list.rb +++ b/lib/rubygems/dependency_list.rb @@ -5,8 +5,8 @@ # See LICENSE.txt for permissions. #++ -require_relative 'tsort' -require_relative 'deprecate' +require_relative "tsort" +require_relative "deprecate" ## # Gem::DependencyList is used for installing and uninstalling gems in the diff --git a/lib/rubygems/doctor.rb b/lib/rubygems/doctor.rb index d14c64a166..662eff9559 100644 --- a/lib/rubygems/doctor.rb +++ b/lib/rubygems/doctor.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative '../rubygems' -require_relative 'user_interaction' +require_relative "../rubygems" +require_relative "user_interaction" ## # Cleans up after a partially-failed uninstall or for an invalid @@ -19,13 +19,13 @@ class Gem::Doctor # subdirectory. REPOSITORY_EXTENSION_MAP = [ # :nodoc: - ['specifications', '.gemspec'], - ['build_info', '.info'], - ['cache', '.gem'], - ['doc', ''], - ['extensions', ''], - ['gems', ''], - ['plugins', ''], + ["specifications", ".gemspec"], + ["build_info", ".info"], + ["cache", ".gem"], + ["doc", ""], + ["extensions", ""], + ["gems", ""], + ["plugins", ""], ].freeze missing = @@ -74,8 +74,8 @@ class Gem::Doctor Gem.use_paths @gem_repository.to_s unless gem_repository? - say 'This directory does not appear to be a RubyGems repository, ' + - 'skipping' + say "This directory does not appear to be a RubyGems repository, " + + "skipping" say return end @@ -111,16 +111,16 @@ class Gem::Doctor basename = File.basename(child, extension) next if installed_specs.include? basename next if /^rubygems-\d/ =~ basename - next if 'specifications' == sub_directory and 'default' == basename - next if 'plugins' == sub_directory and Gem.plugin_suffix_regexp =~ basename + next if "specifications" == sub_directory and "default" == basename + next if "plugins" == sub_directory and Gem.plugin_suffix_regexp =~ basename - type = File.directory?(child) ? 'directory' : 'file' + type = File.directory?(child) ? "directory" : "file" action = if @dry_run - 'Extra' + "Extra" else FileUtils.rm_r(child) - 'Removed' + "Removed" end say "#{action} #{type} #{sub_directory}/#{File.basename(child)}" diff --git a/lib/rubygems/errors.rb b/lib/rubygems/errors.rb index e6e222033d..ac82a551a5 100644 --- a/lib/rubygems/errors.rb +++ b/lib/rubygems/errors.rb @@ -136,8 +136,8 @@ module Gem "Found %s (%s), but was for platform%s %s" % [@name, @version, - @platforms.size == 1 ? '' : 's', - @platforms.join(' ,')] + @platforms.size == 1 ? "" : "s", + @platforms.join(" ,")] end end diff --git a/lib/rubygems/exceptions.rb b/lib/rubygems/exceptions.rb index 1806869098..5fadbe9bca 100644 --- a/lib/rubygems/exceptions.rb +++ b/lib/rubygems/exceptions.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require_relative 'deprecate' -require_relative 'unknown_command_spell_checker' +require_relative "deprecate" +require_relative "unknown_command_spell_checker" ## # Base exception class for RubyGems. All exception raised by RubyGems are a @@ -27,7 +27,7 @@ class Gem::UnknownCommandError < Gem::Exception if DidYouMean.respond_to?(:correct_error) DidYouMean.correct_error(Gem::UnknownCommandError, Gem::UnknownCommandSpellChecker) else - DidYouMean::SPELL_CHECKERS['Gem::UnknownCommandError'] = + DidYouMean::SPELL_CHECKERS["Gem::UnknownCommandError"] = Gem::UnknownCommandSpellChecker prepend DidYouMean::Correctable @@ -154,7 +154,7 @@ class Gem::ImpossibleDependenciesError < Gem::Exception def build_message # :nodoc: requester = @request.requester - requester = requester ? requester.spec.full_name : 'The user' + requester = requester ? requester.spec.full_name : "The user" dependency = @request.dependency message = "#{requester} requires #{dependency} but it conflicted:\n".dup diff --git a/lib/rubygems/ext.rb b/lib/rubygems/ext.rb index 59fd830437..d714985c21 100644 --- a/lib/rubygems/ext.rb +++ b/lib/rubygems/ext.rb @@ -10,10 +10,10 @@ module Gem::Ext; end -require_relative 'ext/build_error' -require_relative 'ext/builder' -require_relative 'ext/configure_builder' -require_relative 'ext/ext_conf_builder' -require_relative 'ext/rake_builder' -require_relative 'ext/cmake_builder' -require_relative 'ext/cargo_builder' +require_relative "ext/build_error" +require_relative "ext/builder" +require_relative "ext/configure_builder" +require_relative "ext/ext_conf_builder" +require_relative "ext/rake_builder" +require_relative "ext/cmake_builder" +require_relative "ext/cargo_builder" diff --git a/lib/rubygems/ext/build_error.rb b/lib/rubygems/ext/build_error.rb index 8ef57ed91a..727bc065c2 100644 --- a/lib/rubygems/ext/build_error.rb +++ b/lib/rubygems/ext/build_error.rb @@ -2,7 +2,7 @@ ## # Raised when there is an error while building extensions. -require_relative '../exceptions' +require_relative "../exceptions" class Gem::Ext::BuildError < Gem::InstallError end diff --git a/lib/rubygems/ext/builder.rb b/lib/rubygems/ext/builder.rb index 99dd2c162c..c5a03806b9 100644 --- a/lib/rubygems/ext/builder.rb +++ b/lib/rubygems/ext/builder.rb @@ -5,7 +5,7 @@ # See LICENSE.txt for permissions. #++ -require_relative '../user_interaction' +require_relative "../user_interaction" class Gem::Ext::Builder include Gem::UserInteraction @@ -18,29 +18,29 @@ class Gem::Ext::Builder end def self.make(dest_path, results, make_dir = Dir.pwd, sitedir = nil) - unless File.exist? File.join(make_dir, 'Makefile') - raise Gem::InstallError, 'Makefile not found' + unless File.exist? File.join(make_dir, "Makefile") + raise Gem::InstallError, "Makefile not found" end # try to find make program from Ruby configure arguments first - RbConfig::CONFIG['configure_args'] =~ /with-make-prog\=(\w+)/ - make_program_name = ENV['MAKE'] || ENV['make'] || $1 + RbConfig::CONFIG["configure_args"] =~ /with-make-prog\=(\w+)/ + make_program_name = ENV["MAKE"] || ENV["make"] || $1 unless make_program_name - make_program_name = (/mswin/ =~ RUBY_PLATFORM) ? 'nmake' : 'make' + make_program_name = (/mswin/ =~ RUBY_PLATFORM) ? "nmake" : "make" end make_program = Shellwords.split(make_program_name) # The installation of the bundled gems is failed when DESTDIR is empty in mswin platform. - destdir = (/\bnmake/i !~ make_program_name || ENV['DESTDIR'] && ENV['DESTDIR'] != "") ? 'DESTDIR=%s' % ENV['DESTDIR'] : '' + destdir = (/\bnmake/i !~ make_program_name || ENV["DESTDIR"] && ENV["DESTDIR"] != "") ? "DESTDIR=%s" % ENV["DESTDIR"] : "" env = [destdir] if sitedir - env << 'sitearchdir=%s' % sitedir - env << 'sitelibdir=%s' % sitedir + env << "sitearchdir=%s" % sitedir + env << "sitelibdir=%s" % sitedir end - ['clean', '', 'install'].each do |target| + ["clean", "", "install"].each do |target| # Pass DESTDIR via command line to override what's in MAKEFLAGS cmd = [ *make_program, @@ -50,7 +50,7 @@ class Gem::Ext::Builder begin run(cmd, results, "make #{target}".rstrip, make_dir) rescue Gem::InstallError - raise unless target == 'clean' # ignore clean failure + raise unless target == "clean" # ignore clean failure end end end @@ -59,7 +59,7 @@ class Gem::Ext::Builder verbose = Gem.configuration.really_verbose begin - rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], nil + rubygems_gemdeps, ENV["RUBYGEMS_GEMDEPS"] = ENV["RUBYGEMS_GEMDEPS"], nil if verbose puts("current directory: #{dir}") p(command) @@ -70,7 +70,7 @@ class Gem::Ext::Builder require "open3" # Set $SOURCE_DATE_EPOCH for the subprocess. - build_env = { 'SOURCE_DATE_EPOCH' => Gem.source_date_epoch_string }.merge(env) + build_env = { "SOURCE_DATE_EPOCH" => Gem.source_date_epoch_string }.merge(env) output, status = begin Open3.capture2e(build_env, *command, :chdir => dir) rescue => error @@ -82,7 +82,7 @@ class Gem::Ext::Builder results << output end ensure - ENV['RUBYGEMS_GEMDEPS'] = rubygems_gemdeps + ENV["RUBYGEMS_GEMDEPS"] = rubygems_gemdeps end unless status.success? @@ -212,11 +212,11 @@ EOF # Writes +output+ to gem_make.out in the extension install directory. def write_gem_make_out(output) # :nodoc: - destination = File.join @spec.extension_dir, 'gem_make.out' + destination = File.join @spec.extension_dir, "gem_make.out" FileUtils.mkdir_p @spec.extension_dir - File.open destination, 'wb' do |io| + File.open destination, "wb" do |io| io.puts output end diff --git a/lib/rubygems/ext/cargo_builder.rb b/lib/rubygems/ext/cargo_builder.rb index 232c0a313d..e33b07a8a2 100644 --- a/lib/rubygems/ext/cargo_builder.rb +++ b/lib/rubygems/ext/cargo_builder.rb @@ -29,14 +29,14 @@ class Gem::Ext::CargoBuilder < Gem::Ext::Builder def build_crate(dest_path, results, args, cargo_dir) env = build_env cmd = cargo_command(cargo_dir, dest_path, args) - runner.call cmd, results, 'cargo', cargo_dir, env + runner.call cmd, results, "cargo", cargo_dir, env results end def build_env build_env = rb_config_env - build_env["RUBY_STATIC"] = "true" if ruby_static? && ENV.key?('RUBY_STATIC') + build_env["RUBY_STATIC"] = "true" if ruby_static? && ENV.key?("RUBY_STATIC") build_env end @@ -46,7 +46,7 @@ class Gem::Ext::CargoBuilder < Gem::Ext::Builder cmd = [] cmd += [cargo, "rustc"] - cmd += ["--target", ENV['CARGO_BUILD_TARGET']] if ENV['CARGO_BUILD_TARGET'] + cmd += ["--target", ENV["CARGO_BUILD_TARGET"]] if ENV["CARGO_BUILD_TARGET"] cmd += ["--target-dir", dest_path] cmd += ["--manifest-path", manifest] cmd += ["--lib"] @@ -144,13 +144,13 @@ class Gem::Ext::CargoBuilder < Gem::Ext::Builder def cargo_dylib_path(dest_path) prefix = so_ext == "dll" ? "" : "lib" path_parts = [dest_path] - path_parts << ENV['CARGO_BUILD_TARGET'] if ENV['CARGO_BUILD_TARGET'] + path_parts << ENV["CARGO_BUILD_TARGET"] if ENV["CARGO_BUILD_TARGET"] path_parts += [profile_target_directory, "#{prefix}#{cargo_crate_name}.#{so_ext}"] File.join(*path_parts) end def cargo_crate_name - spec.metadata.fetch('cargo_crate_name', spec.name).tr('-', '_') + spec.metadata.fetch("cargo_crate_name", spec.name).tr("-", "_") end def rustc_dynamic_linker_flags(dest_dir) @@ -297,8 +297,8 @@ class Gem::Ext::CargoBuilder < Gem::Ext::Builder def profile_target_directory case profile - when :release then 'release' - when :dev then 'debug' + when :release then "release" + when :dev then "debug" else raise "unknown target directory for profile: #{profile}" end end diff --git a/lib/rubygems/ext/cmake_builder.rb b/lib/rubygems/ext/cmake_builder.rb index e47cabef84..b162664784 100644 --- a/lib/rubygems/ext/cmake_builder.rb +++ b/lib/rubygems/ext/cmake_builder.rb @@ -2,8 +2,8 @@ class Gem::Ext::CmakeBuilder < Gem::Ext::Builder def self.build(extension, dest_path, results, args=[], lib_dir=nil, cmake_dir=Dir.pwd) - unless File.exist?(File.join(cmake_dir, 'Makefile')) - require_relative '../command' + unless File.exist?(File.join(cmake_dir, "Makefile")) + require_relative "../command" cmd = ["cmake", ".", "-DCMAKE_INSTALL_PREFIX=#{dest_path}", *Gem::Command.build_args] run cmd, results, class_name, cmake_dir diff --git a/lib/rubygems/ext/configure_builder.rb b/lib/rubygems/ext/configure_builder.rb index eb2f9fce61..51106c6370 100644 --- a/lib/rubygems/ext/configure_builder.rb +++ b/lib/rubygems/ext/configure_builder.rb @@ -7,7 +7,7 @@ class Gem::Ext::ConfigureBuilder < Gem::Ext::Builder def self.build(extension, dest_path, results, args=[], lib_dir=nil, configure_dir=Dir.pwd) - unless File.exist?(File.join(configure_dir, 'Makefile')) + unless File.exist?(File.join(configure_dir, "Makefile")) cmd = ["sh", "./configure", "--prefix=#{dest_path}", *args] run cmd, results, class_name, configure_dir diff --git a/lib/rubygems/ext/ext_conf_builder.rb b/lib/rubygems/ext/ext_conf_builder.rb index 2f0183fe2f..f8920596d5 100644 --- a/lib/rubygems/ext/ext_conf_builder.rb +++ b/lib/rubygems/ext/ext_conf_builder.rb @@ -7,8 +7,8 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder def self.build(extension, dest_path, results, args=[], lib_dir=nil, extension_dir=Dir.pwd) - require 'fileutils' - require 'tempfile' + require "fileutils" + require "tempfile" tmp_dest = Dir.mktmpdir(".gem.", extension_dir) @@ -22,16 +22,16 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder begin require "shellwords" - cmd = Gem.ruby.shellsplit << "-I" << File.expand_path('../..', __dir__) << File.basename(extension) + cmd = Gem.ruby.shellsplit << "-I" << File.expand_path("../..", __dir__) << File.basename(extension) cmd.push(*args) run(cmd, results, class_name, extension_dir) do |s, r| - mkmf_log = File.join(extension_dir, 'mkmf.log') + mkmf_log = File.join(extension_dir, "mkmf.log") if File.exist? mkmf_log unless s.success? r << "To see why this extension failed to compile, please check" \ " the mkmf.log which can be found here:\n" - r << " " + File.join(dest_path, 'mkmf.log') + "\n" + r << " " + File.join(dest_path, "mkmf.log") + "\n" end FileUtils.mv mkmf_log, dest_path end @@ -67,7 +67,7 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder private def self.get_relative_path(path, base) - path[0..base.length - 1] = '.' if path.start_with?(base) + path[0..base.length - 1] = "." if path.start_with?(base) path end end diff --git a/lib/rubygems/ext/rake_builder.rb b/lib/rubygems/ext/rake_builder.rb index fed98e741c..9f2e099d40 100644 --- a/lib/rubygems/ext/rake_builder.rb +++ b/lib/rubygems/ext/rake_builder.rb @@ -11,16 +11,16 @@ class Gem::Ext::RakeBuilder < Gem::Ext::Builder run([Gem.ruby, File.basename(extension), *args], results, class_name, extension_dir) end - rake = ENV['rake'] + rake = ENV["rake"] if rake require "shellwords" rake = rake.shellsplit else begin - rake = [Gem.ruby, "-I#{File.expand_path("../..", __dir__)}", "-rrubygems", Gem.bin_path('rake', 'rake')] + rake = [Gem.ruby, "-I#{File.expand_path("../..", __dir__)}", "-rrubygems", Gem.bin_path("rake", "rake")] rescue Gem::Exception - rake = [Gem.default_exec_format % 'rake'] + rake = [Gem.default_exec_format % "rake"] end end diff --git a/lib/rubygems/gem_runner.rb b/lib/rubygems/gem_runner.rb index b3f925773b..31890a60d7 100644 --- a/lib/rubygems/gem_runner.rb +++ b/lib/rubygems/gem_runner.rb @@ -5,9 +5,9 @@ # See LICENSE.txt for permissions. #++ -require_relative '../rubygems' -require_relative 'command_manager' -require_relative 'deprecate' +require_relative "../rubygems" +require_relative "command_manager" +require_relative "deprecate" ## # Run an instance of the gem program. @@ -41,7 +41,7 @@ class Gem::GemRunner config_args = Gem.configuration[command_name] config_args = case config_args when String - config_args.split ' ' + config_args.split " " else Array(config_args) end @@ -56,7 +56,7 @@ class Gem::GemRunner # other arguments in the list. def extract_build_args(args) # :nodoc: - return [] unless offset = args.index('--') + return [] unless offset = args.index("--") build_args = args.slice!(offset...args.length) diff --git a/lib/rubygems/gemcutter_utilities.rb b/lib/rubygems/gemcutter_utilities.rb index af0d957bc8..1eeb341bb8 100644 --- a/lib/rubygems/gemcutter_utilities.rb +++ b/lib/rubygems/gemcutter_utilities.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative 'remote_fetcher' -require_relative 'text' +require_relative "remote_fetcher" +require_relative "text" ## # Utility methods for using the RubyGems API. @@ -19,8 +19,8 @@ module Gem::GemcutterUtilities # Add the --key option def add_key_option - add_option('-k', '--key KEYNAME', Symbol, - 'Use the given API key', + add_option("-k", "--key KEYNAME", Symbol, + "Use the given API key", "from #{Gem.configuration.credentials_path}") do |value,options| options[:key] = value end @@ -30,9 +30,9 @@ module Gem::GemcutterUtilities # Add the --otp option def add_otp_option - add_option('--otp CODE', - 'Digit code for multifactor authentication', - 'You can also use the environment variable GEM_HOST_OTP_CODE') do |value, options| + add_option("--otp CODE", + "Digit code for multifactor authentication", + "You can also use the environment variable GEM_HOST_OTP_CODE") do |value, options| options[:otp] = value end end @@ -69,7 +69,7 @@ module Gem::GemcutterUtilities @host ||= begin - env_rubygems_host = ENV['RUBYGEMS_HOST'] + env_rubygems_host = ENV["RUBYGEMS_HOST"] env_rubygems_host = nil if env_rubygems_host and env_rubygems_host.empty? @@ -83,7 +83,7 @@ module Gem::GemcutterUtilities # If +allowed_push_host+ metadata is present, then it will only allow that host. def rubygems_api_request(method, path, host = nil, allowed_push_host = nil, scope: nil, &block) - require 'net/http' + require "net/http" self.host = host if host unless self.host @@ -118,7 +118,7 @@ module Gem::GemcutterUtilities end def mfa_unauthorized?(response) - response.kind_of?(Net::HTTPUnauthorized) && response.body.start_with?('You have enabled multifactor authentication') + response.kind_of?(Net::HTTPUnauthorized) && response.body.start_with?("You have enabled multifactor authentication") end def update_scope(scope) @@ -240,13 +240,13 @@ module Gem::GemcutterUtilities end def ask_otp - say 'You have enabled multi-factor authentication. Please enter OTP code.' - options[:otp] = ask 'Code: ' + say "You have enabled multi-factor authentication. Please enter OTP code." + options[:otp] = ask "Code: " end def pretty_host(host) if default_host? - 'RubyGems.org' + "RubyGems.org" else host end diff --git a/lib/rubygems/indexer.rb b/lib/rubygems/indexer.rb index a5a86f4111..2299932f45 100644 --- a/lib/rubygems/indexer.rb +++ b/lib/rubygems/indexer.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require_relative '../rubygems' -require_relative 'package' -require 'tmpdir' +require_relative "../rubygems" +require_relative "package" +require "tmpdir" ## # Top level class for building the gem repository index. @@ -43,28 +43,28 @@ class Gem::Indexer # Create an indexer that will index the gems in +directory+. def initialize(directory, options = {}) - require 'fileutils' - require 'tmpdir' - require 'zlib' + require "fileutils" + require "tmpdir" + require "zlib" options = { :build_modern => true }.merge options @build_modern = options[:build_modern] @dest_directory = directory - @directory = Dir.mktmpdir 'gem_generate_index' + @directory = Dir.mktmpdir "gem_generate_index" marshal_name = "Marshal.#{Gem.marshal_version}" - @master_index = File.join @directory, 'yaml' + @master_index = File.join @directory, "yaml" @marshal_index = File.join @directory, marshal_name - @quick_dir = File.join @directory, 'quick' + @quick_dir = File.join @directory, "quick" @quick_marshal_dir = File.join @quick_dir, marshal_name @quick_marshal_dir_base = File.join "quick", marshal_name # FIX: UGH - @quick_index = File.join @quick_dir, 'index' - @latest_index = File.join @quick_dir, 'latest_index' + @quick_index = File.join @quick_dir, "index" + @latest_index = File.join @quick_dir, "latest_index" @specs_index = File.join @directory, "specs.#{Gem.marshal_version}" @latest_specs_index = @@ -104,7 +104,7 @@ class Gem::Indexer files = [] - Gem.time 'Generated Marshal quick index gemspecs' do + Gem.time "Generated Marshal quick index gemspecs" do specs.each do |spec| next if spec.default_gem? spec_file_name = "#{spec.original_name}.gemspec.rz" @@ -112,7 +112,7 @@ class Gem::Indexer marshal_zipped = Gem.deflate Marshal.dump(spec) - File.open marshal_name, 'wb' do |io| + File.open marshal_name, "wb" do |io| io.write marshal_zipped end @@ -136,7 +136,7 @@ class Gem::Indexer say "Generating #{name} index" Gem.time "Generated #{name} index" do - File.open(file, 'wb') do |io| + File.open(file, "wb") do |io| specs = index.map do |*spec| # We have to splat here because latest_specs is an array, while the # others are hashes. @@ -169,10 +169,10 @@ class Gem::Indexer latest_specs = Gem::Specification._latest_specs specs - build_modern_index(released.sort, @specs_index, 'specs') - build_modern_index(latest_specs.sort, @latest_specs_index, 'latest specs') + build_modern_index(released.sort, @specs_index, "specs") + build_modern_index(latest_specs.sort, @latest_specs_index, "latest specs") build_modern_index(prerelease.sort, @prerelease_specs_index, - 'prerelease specs') + "prerelease specs") @files += [@specs_index, "#{@specs_index}.gz", @@ -217,7 +217,7 @@ class Gem::Indexer def compress_indices say "Compressing indices" - Gem.time 'Compressed indices' do + Gem.time "Compressed indices" do if @build_modern gzip @specs_index gzip @latest_specs_index @@ -252,7 +252,7 @@ class Gem::Indexer zipped = Gem.deflate data - File.open "#{filename}.#{extension}", 'wb' do |io| + File.open "#{filename}.#{extension}", "wb" do |io| io.write zipped end end @@ -308,7 +308,7 @@ class Gem::Indexer end files = files.map do |path| - path.sub(/^#{Regexp.escape @directory}\/?/, '') # HACK? + path.sub(/^#{Regexp.escape @directory}\/?/, "") # HACK? end files.each do |file| @@ -358,7 +358,7 @@ class Gem::Indexer end if updated_gems.empty? - say 'No new gems' + say "No new gems" terminate_interaction 0 end @@ -367,7 +367,7 @@ class Gem::Indexer files = build_marshal_gemspecs specs - Gem.time 'Updated indexes' do + Gem.time "Updated indexes" do update_specs_index released, @dest_specs_index, @specs_index update_specs_index released, @dest_latest_specs_index, @latest_specs_index update_specs_index(prerelease, @@ -389,7 +389,7 @@ class Gem::Indexer files << "#{@prerelease_specs_index}.gz" files = files.map do |path| - path.sub(/^#{Regexp.escape @directory}\/?/, '') # HACK? + path.sub(/^#{Regexp.escape @directory}\/?/, "") # HACK? end files.each do |file| @@ -420,7 +420,7 @@ class Gem::Indexer specs_index = compact_specs specs_index.uniq.sort - File.open dest, 'wb' do |io| + File.open dest, "wb" do |io| Marshal.dump specs_index, io end end diff --git a/lib/rubygems/install_default_message.rb b/lib/rubygems/install_default_message.rb index 052ef528e1..0d112a15df 100644 --- a/lib/rubygems/install_default_message.rb +++ b/lib/rubygems/install_default_message.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative '../rubygems' -require_relative 'user_interaction' +require_relative "../rubygems" +require_relative "user_interaction" ## # A post-install hook that displays "Successfully installed diff --git a/lib/rubygems/install_message.rb b/lib/rubygems/install_message.rb index 861ead3770..2565f36261 100644 --- a/lib/rubygems/install_message.rb +++ b/lib/rubygems/install_message.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative '../rubygems' -require_relative 'user_interaction' +require_relative "../rubygems" +require_relative "user_interaction" ## # A default post-install hook that displays "Successfully installed diff --git a/lib/rubygems/install_update_options.rb b/lib/rubygems/install_update_options.rb index 454104435d..79effcf21f 100644 --- a/lib/rubygems/install_update_options.rb +++ b/lib/rubygems/install_update_options.rb @@ -5,8 +5,8 @@ # See LICENSE.txt for permissions. #++ -require_relative '../rubygems' -require_relative 'security_option' +require_relative "../rubygems" +require_relative "security_option" ## # Mixin methods for install and update options for Gem::Commands @@ -18,22 +18,22 @@ module Gem::InstallUpdateOptions # Add the install/update options to the option parser. def add_install_update_options - add_option(:"Install/Update", '-i', '--install-dir DIR', - 'Gem repository directory to get installed', - 'gems') do |value, options| + add_option(:"Install/Update", "-i", "--install-dir DIR", + "Gem repository directory to get installed", + "gems") do |value, options| options[:install_dir] = File.expand_path(value) end - add_option(:"Install/Update", '-n', '--bindir DIR', - 'Directory where executables will be', - 'placed when the gem is installed') do |value, options| + add_option(:"Install/Update", "-n", "--bindir DIR", + "Directory where executables will be", + "placed when the gem is installed") do |value, options| options[:bin_dir] = File.expand_path(value) end - add_option(:"Install/Update", '--document [TYPES]', Array, - 'Generate documentation for installed gems', - 'List the documentation types you wish to', - 'generate. For example: rdoc,ri') do |value, options| + add_option(:"Install/Update", "--document [TYPES]", Array, + "Generate documentation for installed gems", + "List the documentation types you wish to", + "generate. For example: rdoc,ri") do |value, options| options[:document] = case value when nil then %w[ri] when false then [] @@ -41,63 +41,63 @@ module Gem::InstallUpdateOptions end end - add_option(:"Install/Update", '--build-root DIR', - 'Temporary installation root. Useful for building', - 'packages. Do not use this when installing remote gems.') do |value, options| + add_option(:"Install/Update", "--build-root DIR", + "Temporary installation root. Useful for building", + "packages. Do not use this when installing remote gems.") do |value, options| options[:build_root] = File.expand_path(value) end - add_option(:"Install/Update", '--vendor', - 'Install gem into the vendor directory.', - 'Only for use by gem repackagers.') do |value, options| + add_option(:"Install/Update", "--vendor", + "Install gem into 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 options[:vendor] = true options[:install_dir] = Gem.vendor_dir end - add_option(:"Install/Update", '-N', '--no-document', - 'Disable documentation generation') do |value, options| + add_option(:"Install/Update", "-N", "--no-document", + "Disable documentation generation") do |value, options| options[:document] = [] end - add_option(:"Install/Update", '-E', '--[no-]env-shebang', + add_option(:"Install/Update", "-E", "--[no-]env-shebang", "Rewrite the shebang line on installed", "scripts to use /usr/bin/env") do |value, options| options[:env_shebang] = value end - add_option(:"Install/Update", '-f', '--[no-]force', - 'Force gem to install, bypassing dependency', - 'checks') do |value, options| + add_option(:"Install/Update", "-f", "--[no-]force", + "Force gem to install, bypassing dependency", + "checks") do |value, options| options[:force] = value end - add_option(:"Install/Update", '-w', '--[no-]wrappers', - 'Use bin wrappers for executables', - 'Not available on dosish platforms') do |value, options| + add_option(:"Install/Update", "-w", "--[no-]wrappers", + "Use bin wrappers for executables", + "Not available on dosish platforms") do |value, options| options[:wrappers] = value end add_security_option - add_option(:"Install/Update", '--ignore-dependencies', - 'Do not install any required dependent gems') do |value, options| + add_option(:"Install/Update", "--ignore-dependencies", + "Do not install any required dependent gems") do |value, options| options[:ignore_dependencies] = value end - add_option(:"Install/Update", '--[no-]format-executable', - 'Make installed executable names match Ruby.', - 'If Ruby is ruby18, foo_exec will be', - 'foo_exec18') do |value, options| + add_option(:"Install/Update", "--[no-]format-executable", + "Make installed executable names match Ruby.", + "If Ruby is ruby18, foo_exec will be", + "foo_exec18") do |value, options| options[:format_executable] = value end - add_option(:"Install/Update", '--[no-]user-install', - 'Install in user\'s home directory instead', - 'of GEM_HOME.') do |value, options| + add_option(:"Install/Update", "--[no-]user-install", + "Install in user's home directory instead", + "of GEM_HOME.") do |value, options| options[:user_install] = value end @@ -133,9 +133,9 @@ module Gem::InstallUpdateOptions options[:post_install_message] = value end - add_option(:"Install/Update", '-g', '--file [FILE]', - 'Read from a gem dependencies API file and', - 'install the listed gems') do |v,o| + add_option(:"Install/Update", "-g", "--file [FILE]", + "Read from a gem dependencies API file and", + "install the listed gems") do |v,o| v = Gem::GEM_DEP_FILES.find do |file| File.exist? file end unless v @@ -150,32 +150,32 @@ module Gem::InstallUpdateOptions options[:gemdeps] = v end - add_option(:"Install/Update", '--without GROUPS', Array, - 'Omit the named groups (comma separated)', - 'when installing from a gem dependencies', - 'file') do |v,o| + add_option(:"Install/Update", "--without GROUPS", Array, + "Omit the named groups (comma separated)", + "when installing from a gem dependencies", + "file") do |v,o| options[:without_groups].concat v.map {|without| without.intern } end - add_option(:"Install/Update", '--default', - 'Add the gem\'s full specification to', - 'specifications/default and extract only its bin') do |v,o| + add_option(:"Install/Update", "--default", + "Add the gem's full specification to", + "specifications/default and extract only its bin") do |v,o| options[:install_as_default] = v end - add_option(:"Install/Update", '--explain', - 'Rather than install the gems, indicate which would', - 'be installed') do |v,o| + add_option(:"Install/Update", "--explain", + "Rather than install the gems, indicate which would", + "be installed") do |v,o| options[:explain] = v end - add_option(:"Install/Update", '--[no-]lock', - 'Create a lock file (when used with -g/--file)') do |v,o| + add_option(:"Install/Update", "--[no-]lock", + "Create a lock file (when used with -g/--file)") do |v,o| options[:lock] = v end - add_option(:"Install/Update", '--[no-]suggestions', - 'Suggest alternates when gems are not found') do |v,o| + add_option(:"Install/Update", "--[no-]suggestions", + "Suggest alternates when gems are not found") do |v,o| options[:suggest_alternate] = v end end @@ -193,7 +193,7 @@ module Gem::InstallUpdateOptions # Default description for the gem install and update commands. def install_update_defaults_str - '--document=ri' + "--document=ri" end end diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb index 7484145467..52307f6d93 100644 --- a/lib/rubygems/installer.rb +++ b/lib/rubygems/installer.rb @@ -5,12 +5,12 @@ # See LICENSE.txt for permissions. #++ -require_relative 'installer_uninstaller_utils' -require_relative 'exceptions' -require_relative 'deprecate' -require_relative 'package' -require_relative 'ext' -require_relative 'user_interaction' +require_relative "installer_uninstaller_utils" +require_relative "exceptions" +require_relative "deprecate" +require_relative "package" +require_relative "ext" +require_relative "user_interaction" ## # The installer installs the files contained in the .gem into the Gem.home. @@ -125,14 +125,14 @@ class Gem::Installer @spec = spec end - def extract_files(destination_dir, pattern = '*') + def extract_files(destination_dir, pattern = "*") FileUtils.mkdir_p destination_dir spec.files.each do |file| file = File.join destination_dir, file next if File.exist? file FileUtils.mkdir_p File.dirname(file) - File.open file, 'w' do |fp| + File.open file, "w" do |fp| fp.puts "# #{file}" end end @@ -177,7 +177,7 @@ class Gem::Installer # :post_install_message:: Print gem post install message if true def initialize(package, options={}) - require 'fileutils' + require "fileutils" @options = options @package = package @@ -219,7 +219,7 @@ class Gem::Installer ruby_executable = false existing = nil - File.open generated_bin, 'rb' do |io| + File.open generated_bin, "rb" do |io| line = io.gets shebang = /^#!.*ruby/ @@ -256,7 +256,7 @@ class Gem::Installer question = "#{spec.name}'s executable \"#{filename}\" conflicts with ".dup if ruby_executable - question << (existing || 'an unknown executable') + question << (existing || "an unknown executable") return if ask_yes_no "#{question}\nOverwrite the executable?", false @@ -474,7 +474,7 @@ class Gem::Installer if Gem.win_platform? script_name = formatted_program_filename(filename) + ".bat" script_path = File.join bindir, File.basename(script_name) - File.open script_path, 'w' do |file| + File.open script_path, "w" do |file| file.puts windows_stub_script(bindir, filename) end @@ -504,7 +504,7 @@ class Gem::Installer dir_mode = options[:prog_mode] || (mode | 0111) unless dir_mode == mode - require 'fileutils' + require "fileutils" FileUtils.chmod dir_mode, bin_path end @@ -541,10 +541,10 @@ class Gem::Installer def generate_bin_script(filename, bindir) bin_script_path = File.join bindir, formatted_program_filename(filename) - require 'fileutils' + require "fileutils" FileUtils.rm_f bin_script_path # prior install may have been --no-wrappers - File.open bin_script_path, 'wb', 0755 do |file| + File.open bin_script_path, "wb", 0755 do |file| file.print app_script_text(filename) file.chmod(options[:prog_mode] || 0755) end @@ -565,7 +565,7 @@ class Gem::Installer if File.exist? dst if File.symlink? dst link = File.readlink(dst).split File::SEPARATOR - cur_version = Gem::Version.create(link[-3].sub(/^.*-/, '')) + cur_version = Gem::Version.create(link[-3].sub(/^.*-/, "")) return if spec.version < cur_version end File.unlink dst @@ -684,9 +684,9 @@ class Gem::Installer @build_args = options[:build_args] unless @build_root.nil? - @bin_dir = File.join(@build_root, @bin_dir.gsub(/^[a-zA-Z]:/, '')) - @gem_home = File.join(@build_root, @gem_home.gsub(/^[a-zA-Z]:/, '')) - @plugins_dir = File.join(@build_root, @plugins_dir.gsub(/^[a-zA-Z]:/, '')) + @bin_dir = File.join(@build_root, @bin_dir.gsub(/^[a-zA-Z]:/, "")) + @gem_home = File.join(@build_root, @gem_home.gsub(/^[a-zA-Z]:/, "")) + @plugins_dir = File.join(@build_root, @plugins_dir.gsub(/^[a-zA-Z]:/, "")) alert_warning "You build with buildroot.\n Build root: #{@build_root}\n Bin dir: #{@bin_dir}\n Gem home: #{@gem_home}\n Plugins dir: #{@plugins_dir}" end end @@ -697,7 +697,7 @@ class Gem::Installer user_bin_dir = @bin_dir || Gem.bindir(gem_home) user_bin_dir = user_bin_dir.tr(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR - path = ENV['PATH'] + path = ENV["PATH"] path = path.tr(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR if Gem.win_platform? @@ -708,7 +708,7 @@ class Gem::Installer path = path.split(File::PATH_SEPARATOR) unless path.include? user_bin_dir - unless !Gem.win_platform? && (path.include? user_bin_dir.sub(ENV['HOME'], '~')) + unless !Gem.win_platform? && (path.include? user_bin_dir.sub(ENV["HOME"], "~")) alert_warning "You don't have #{user_bin_dir} in your PATH,\n\t gem executables will not run." self.class.path_warning = true end @@ -788,7 +788,7 @@ TEXT end def gemdeps_load(name) - return '' if name == "bundler" + return "" if name == "bundler" <<-TEXT @@ -824,7 +824,7 @@ TEXT TEXT elsif bindir.downcase.start_with? rb_topdir.downcase # stub within ruby folder, but not standard bin. Portable - require 'pathname' + require "pathname" from = Pathname.new bindir to = Pathname.new "#{rb_topdir}/bin" rel = to.relative_path_from from @@ -935,14 +935,14 @@ TEXT def write_build_info_file return if build_args.empty? - build_info_dir = File.join gem_home, 'build_info' + build_info_dir = File.join gem_home, "build_info" dir_mode = options[:dir_mode] FileUtils.mkdir_p build_info_dir, :mode => dir_mode && 0755 build_info_file = File.join build_info_dir, "#{spec.full_name}.info" - File.open build_info_file, 'w' do |io| + File.open build_info_file, "w" do |io| build_args.each do |arg| io.puts arg end @@ -955,7 +955,7 @@ TEXT # Writes the .gem file to the cache directory def write_cache_file - cache_file = File.join gem_home, 'cache', spec.file_name + cache_file = File.join gem_home, "cache", spec.file_name @package.copy_to cache_file end @@ -987,7 +987,7 @@ TEXT end def load_relative_enabled? - rb_config["LIBRUBY_RELATIVE"] == 'yes' + rb_config["LIBRUBY_RELATIVE"] == "yes" end def bash_prolog_script diff --git a/lib/rubygems/installer_uninstaller_utils.rb b/lib/rubygems/installer_uninstaller_utils.rb index 2c8b7c635e..d97b4e29b1 100644 --- a/lib/rubygems/installer_uninstaller_utils.rb +++ b/lib/rubygems/installer_uninstaller_utils.rb @@ -9,12 +9,12 @@ module Gem::InstallerUninstallerUtils plugins = spec.plugins return if plugins.empty? - require 'pathname' + require "pathname" spec.plugins.each do |plugin| plugin_script_path = File.join plugins_dir, "#{spec.name}_plugin#{File.extname(plugin)}" - File.open plugin_script_path, 'wb' do |file| + File.open plugin_script_path, "wb" do |file| file.puts "require_relative '#{Pathname.new(plugin).relative_path_from(Pathname.new(plugins_dir))}'" end diff --git a/lib/rubygems/local_remote_options.rb b/lib/rubygems/local_remote_options.rb index 6b5e08bf1c..b2c2dea905 100644 --- a/lib/rubygems/local_remote_options.rb +++ b/lib/rubygems/local_remote_options.rb @@ -5,8 +5,8 @@ # See LICENSE.txt for permissions. #++ -require 'uri' -require_relative '../rubygems' +require "uri" +require_relative "../rubygems" ## # Mixin methods for local and remote Gem::Command options. @@ -38,18 +38,18 @@ module Gem::LocalRemoteOptions # Add local/remote options to the command line parser. def add_local_remote_options - add_option(:"Local/Remote", '-l', '--local', - 'Restrict operations to the LOCAL domain') do |value, options| + add_option(:"Local/Remote", "-l", "--local", + "Restrict operations to the LOCAL domain") do |value, options| options[:domain] = :local end - add_option(:"Local/Remote", '-r', '--remote', - 'Restrict operations to the REMOTE domain') do |value, options| + add_option(:"Local/Remote", "-r", "--remote", + "Restrict operations to the REMOTE domain") do |value, options| options[:domain] = :remote end - add_option(:"Local/Remote", '-b', '--both', - 'Allow LOCAL and REMOTE operations') do |value, options| + add_option(:"Local/Remote", "-b", "--both", + "Allow LOCAL and REMOTE operations") do |value, options| options[:domain] = :both end @@ -64,7 +64,7 @@ module Gem::LocalRemoteOptions # Add the --bulk-threshold option def add_bulk_threshold_option - add_option(:"Local/Remote", '-B', '--bulk-threshold COUNT', + add_option(:"Local/Remote", "-B", "--bulk-threshold COUNT", "Threshold for switching to bulk", "synchronization (default #{Gem.configuration.bulk_threshold})") do |value, options| @@ -76,8 +76,8 @@ module Gem::LocalRemoteOptions # Add the --clear-sources option def add_clear_sources_option - add_option(:"Local/Remote", '--clear-sources', - 'Clear the gem sources') do |value, options| + add_option(:"Local/Remote", "--clear-sources", + "Clear the gem sources") do |value, options| Gem.sources = nil options[:sources_cleared] = true end @@ -89,8 +89,8 @@ module Gem::LocalRemoteOptions def add_proxy_option accept_uri_http - add_option(:"Local/Remote", '-p', '--[no-]http-proxy [URL]', URI::HTTP, - 'Use HTTP proxy for remote operations') do |value, options| + add_option(:"Local/Remote", "-p", "--[no-]http-proxy [URL]", URI::HTTP, + "Use HTTP proxy for remote operations") do |value, options| options[:http_proxy] = (value == false) ? :no_proxy : value Gem.configuration[:http_proxy] = options[:http_proxy] end @@ -102,9 +102,9 @@ module Gem::LocalRemoteOptions def add_source_option accept_uri_http - add_option(:"Local/Remote", '-s', '--source URL', URI::HTTP, - 'Append URL to list of remote gem sources') do |source, options| - source << '/' if source !~ /\/\z/ + add_option(:"Local/Remote", "-s", "--source URL", URI::HTTP, + "Append URL to list of remote gem sources") do |source, options| + source << "/" if source !~ /\/\z/ if options.delete :sources_cleared Gem.sources = [source] @@ -118,8 +118,8 @@ module Gem::LocalRemoteOptions # Add the --update-sources option def add_update_sources_option - add_option(:Deprecated, '-u', '--[no-]update-sources', - 'Update local source cache') do |value, options| + add_option(:Deprecated, "-u", "--[no-]update-sources", + "Update local source cache") do |value, options| Gem.configuration.update_sources = value end end diff --git a/lib/rubygems/mock_gem_ui.rb b/lib/rubygems/mock_gem_ui.rb index 914ecb9a71..5cc67ad099 100644 --- a/lib/rubygems/mock_gem_ui.rb +++ b/lib/rubygems/mock_gem_ui.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require_relative 'user_interaction' +require_relative "user_interaction" ## # This Gem::StreamUI subclass records input and output to StringIO for @@ -40,7 +40,7 @@ class Gem::MockGemUi < Gem::StreamUI end def initialize(input = "") - require 'stringio' + require "stringio" ins = StringIO.new input outs = StringIO.new errs = StringIO.new diff --git a/lib/rubygems/name_tuple.rb b/lib/rubygems/name_tuple.rb index c732d7f968..b9f330ee4d 100644 --- a/lib/rubygems/name_tuple.rb +++ b/lib/rubygems/name_tuple.rb @@ -48,7 +48,7 @@ class Gem::NameTuple def full_name case @platform - when nil, 'ruby', '' + when nil, "ruby", "" "#{@name}-#{@version}" else "#{@name}-#{@version}-#{@platform}" diff --git a/lib/rubygems/optparse.rb b/lib/rubygems/optparse.rb index 65be9f6b74..6ed718423c 100644 --- a/lib/rubygems/optparse.rb +++ b/lib/rubygems/optparse.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -require_relative 'optparse/lib/optparse' +require_relative "optparse/lib/optparse" diff --git a/lib/rubygems/package.rb b/lib/rubygems/package.rb index 2dd8e8c28e..1e87837b0e 100644 --- a/lib/rubygems/package.rb +++ b/lib/rubygems/package.rb @@ -5,8 +5,8 @@ #++ require_relative "../rubygems" -require_relative 'security' -require_relative 'user_interaction' +require_relative "security" +require_relative "user_interaction" ## # Example using a Gem::Package @@ -158,7 +158,7 @@ class Gem::Package return super unless gem.present? return super unless gem.start - return super unless gem.start.include? 'MD5SUM =' + return super unless gem.start.include? "MD5SUM =" Gem::Package::Old.new gem end @@ -178,9 +178,9 @@ class Gem::Package tar = Gem::Package::TarReader.new io tar.each_entry do |entry| case entry.full_name - when 'metadata' then + when "metadata" then metadata = entry.read - when 'metadata.gz' then + when "metadata.gz" then metadata = Gem::Util.gunzip entry.read end end @@ -193,7 +193,7 @@ class Gem::Package # Creates a new package that will read or write to the file +gem+. def initialize(gem, security_policy) # :notnew: - require 'zlib' + require "zlib" @gem = gem @@ -229,7 +229,7 @@ class Gem::Package end end - tar.add_file_signed 'checksums.yaml.gz', 0444, @signer do |io| + tar.add_file_signed "checksums.yaml.gz", 0444, @signer do |io| gzip_to io do |gz_io| Psych.dump checksums_by_algorithm, gz_io end @@ -241,7 +241,7 @@ class Gem::Package # and adds this file to the +tar+. def add_contents(tar) # :nodoc: - digests = tar.add_file_signed 'data.tar.gz', 0444, @signer do |io| + digests = tar.add_file_signed "data.tar.gz", 0444, @signer do |io| gzip_to io do |gz_io| Gem::Package::TarWriter.new gz_io do |data_tar| add_files data_tar @@ -249,7 +249,7 @@ class Gem::Package end end - @checksums['data.tar.gz'] = digests + @checksums["data.tar.gz"] = digests end ## @@ -266,7 +266,7 @@ class Gem::Package next unless stat.file? tar.add_file_simple file, stat.mode, stat.size do |dst_io| - File.open file, 'rb' do |src_io| + File.open file, "rb" do |src_io| dst_io.write src_io.read 16384 until src_io.eof? end end @@ -277,13 +277,13 @@ class Gem::Package # Adds the package's Gem::Specification to the +tar+ file def add_metadata(tar) # :nodoc: - digests = tar.add_file_signed 'metadata.gz', 0444, @signer do |io| + digests = tar.add_file_signed "metadata.gz", 0444, @signer do |io| gzip_to io do |gz_io| gz_io.write @spec.to_yaml end end - @checksums['metadata.gz'] = digests + @checksums["metadata.gz"] = digests end ## @@ -335,7 +335,7 @@ EOM gem_tar = Gem::Package::TarReader.new io gem_tar.each do |entry| - next unless entry.full_name == 'data.tar.gz' + next unless entry.full_name == "data.tar.gz" open_tar_gz entry do |pkg_tar| pkg_tar.each do |contents_entry| @@ -387,7 +387,7 @@ EOM reader = Gem::Package::TarReader.new io reader.each do |entry| - next unless entry.full_name == 'data.tar.gz' + next unless entry.full_name == "data.tar.gz" extract_tar_gz entry, destination_dir, pattern @@ -420,7 +420,7 @@ EOM real_destination = link_target.start_with?("/") ? link_target : File.expand_path(link_target, File.dirname(destination)) raise Gem::Package::SymlinkError.new(entry.full_name, real_destination, destination_dir) unless - normalize_path(real_destination).start_with? normalize_path(destination_dir + '/') + normalize_path(real_destination).start_with? normalize_path(destination_dir + "/") end FileUtils.rm_rf destination @@ -439,7 +439,7 @@ EOM directories << mkdir end - File.open destination, 'wb' do |out| + File.open destination, "wb" do |out| out.write entry.read FileUtils.chmod file_mode(entry.header.mode), destination end if entry.file? @@ -481,13 +481,13 @@ EOM def install_location(filename, destination_dir) # :nodoc: raise Gem::Package::PathError.new(filename, destination_dir) if - filename.start_with? '/' + filename.start_with? "/" destination_dir = File.realpath(destination_dir) destination = File.expand_path(filename, destination_dir) raise Gem::Package::PathError.new(destination, destination_dir) unless - normalize_path(destination).start_with? normalize_path(destination_dir + '/') + normalize_path(destination).start_with? normalize_path(destination_dir + "/") destination.tap(&Gem::UNTAINT) destination @@ -506,9 +506,9 @@ EOM def load_spec(entry) # :nodoc: case entry.full_name - when 'metadata' then + when "metadata" then @spec = Gem::Specification.from_yaml entry.read - when 'metadata.gz' then + when "metadata.gz" then Zlib::GzipReader.wrap(entry, external_encoding: Encoding::UTF_8) do |gzio| @spec = Gem::Specification.from_yaml gzio.read end @@ -532,7 +532,7 @@ EOM def read_checksums(gem) Gem.load_yaml - @checksums = gem.seek 'checksums.yaml.gz' do |entry| + @checksums = gem.seek "checksums.yaml.gz" do |entry| Zlib::GzipReader.wrap entry do |gz_io| Gem::SafeYAML.safe_load gz_io.read end @@ -544,7 +544,7 @@ EOM # certificate and key are not present only checksum generation is set up. def setup_signer(signer_options: {}) - passphrase = ENV['GEM_PRIVATE_KEY_PASSPHRASE'] + passphrase = ENV["GEM_PRIVATE_KEY_PASSPHRASE"] if @spec.signing_key @signer = Gem::Security::Signer.new( @@ -651,7 +651,7 @@ EOM case file_name when "metadata", "metadata.gz" then load_spec entry - when 'data.tar.gz' then + when "data.tar.gz" then verify_gz entry end rescue @@ -668,12 +668,12 @@ EOM end unless @spec - raise Gem::Package::FormatError.new 'package metadata is missing', @gem + raise Gem::Package::FormatError.new "package metadata is missing", @gem end - unless @files.include? 'data.tar.gz' + unless @files.include? "data.tar.gz" raise Gem::Package::FormatError.new \ - 'package content (data.tar.gz) is missing', @gem + "package content (data.tar.gz) is missing", @gem end if duplicates = @files.group_by {|f| f }.select {|k,v| v.size > 1 }.map(&:first) and duplicates.any? @@ -693,12 +693,12 @@ EOM end end -require_relative 'package/digest_io' -require_relative 'package/source' -require_relative 'package/file_source' -require_relative 'package/io_source' -require_relative 'package/old' -require_relative 'package/tar_header' -require_relative 'package/tar_reader' -require_relative 'package/tar_reader/entry' -require_relative 'package/tar_writer' +require_relative "package/digest_io" +require_relative "package/source" +require_relative "package/file_source" +require_relative "package/io_source" +require_relative "package/old" +require_relative "package/tar_header" +require_relative "package/tar_reader" +require_relative "package/tar_reader/entry" +require_relative "package/tar_writer" diff --git a/lib/rubygems/package/file_source.rb b/lib/rubygems/package/file_source.rb index 114a950c77..14c7a9f6d2 100644 --- a/lib/rubygems/package/file_source.rb +++ b/lib/rubygems/package/file_source.rb @@ -22,10 +22,10 @@ class Gem::Package::FileSource < Gem::Package::Source # :nodoc: all end def with_write_io(&block) - File.open path, 'wb', &block + File.open path, "wb", &block end def with_read_io(&block) - File.open path, 'rb', &block + File.open path, "rb", &block end end diff --git a/lib/rubygems/package/old.rb b/lib/rubygems/package/old.rb index 301d403411..09a02d3ecd 100644 --- a/lib/rubygems/package/old.rb +++ b/lib/rubygems/package/old.rb @@ -19,8 +19,8 @@ class Gem::Package::Old < Gem::Package # cannot be written. def initialize(gem, security_policy) - require 'fileutils' - require 'zlib' + require "fileutils" + require "zlib" Gem.load_yaml @contents = nil @@ -41,7 +41,7 @@ class Gem::Package::Old < Gem::Package read_until_dashes io # spec header = file_list io - @contents = header.map {|file| file['path'] } + @contents = header.map {|file| file["path"] } end end @@ -59,7 +59,7 @@ class Gem::Package::Old < Gem::Package raise Gem::Exception, errstr unless header header.each do |entry| - full_name = entry['path'] + full_name = entry["path"] destination = install_location full_name, destination_dir @@ -73,13 +73,13 @@ class Gem::Package::Old < Gem::Package file_data = Zlib::Inflate.inflate file_data raise Gem::Package::FormatError, "#{full_name} in #{@gem} is corrupt" if - file_data.length != entry['size'].to_i + file_data.length != entry["size"].to_i FileUtils.rm_rf destination FileUtils.mkdir_p File.dirname(destination), :mode => dir_mode && 0755 - File.open destination, 'wb', file_mode(entry['mode']) do |out| + File.open destination, "wb", file_mode(entry["mode"]) do |out| out.write file_data end @@ -119,7 +119,7 @@ class Gem::Package::Old < Gem::Package loop do line = io.gets - return if line.chomp == '__END__' + return if line.chomp == "__END__" break unless line end @@ -160,7 +160,7 @@ class Gem::Package::Old < Gem::Package return true unless @security_policy raise Gem::Security::Exception, - 'old format gems do not contain signatures and cannot be verified' if + "old format gems do not contain signatures and cannot be verified" if @security_policy.verify_data true diff --git a/lib/rubygems/package/tar_header.rb b/lib/rubygems/package/tar_header.rb index ce9b49e3eb..fb70765dde 100644 --- a/lib/rubygems/package/tar_header.rb +++ b/lib/rubygems/package/tar_header.rb @@ -53,42 +53,42 @@ class Gem::Package::TarHeader ## # Pack format for a tar header - PACK_FORMAT = 'a100' + # name - 'a8' + # mode - 'a8' + # uid - 'a8' + # gid - 'a12' + # size - 'a12' + # mtime - 'a7a' + # chksum - 'a' + # typeflag - 'a100' + # linkname - 'a6' + # magic - 'a2' + # version - 'a32' + # uname - 'a32' + # gname - 'a8' + # devmajor - 'a8' + # devminor - 'a155' # prefix + PACK_FORMAT = "a100" + # name + "a8" + # mode + "a8" + # uid + "a8" + # gid + "a12" + # size + "a12" + # mtime + "a7a" + # chksum + "a" + # typeflag + "a100" + # linkname + "a6" + # magic + "a2" + # version + "a32" + # uname + "a32" + # gname + "a8" + # devmajor + "a8" + # devminor + "a155" # prefix ## # Unpack format for a tar header - UNPACK_FORMAT = 'A100' + # name - 'A8' + # mode - 'A8' + # uid - 'A8' + # gid - 'A12' + # size - 'A12' + # mtime - 'A8' + # checksum - 'A' + # typeflag - 'A100' + # linkname - 'A6' + # magic - 'A2' + # version - 'A32' + # uname - 'A32' + # gname - 'A8' + # devmajor - 'A8' + # devminor - 'A155' # prefix + UNPACK_FORMAT = "A100" + # name + "A8" + # mode + "A8" + # uid + "A8" + # gid + "A12" + # size + "A12" + # mtime + "A8" + # checksum + "A" + # typeflag + "A100" + # linkname + "A6" + # magic + "A2" + # version + "A32" + # uname + "A32" + # gname + "A8" + # devmajor + "A8" + # devminor + "A155" # prefix attr_reader(*FIELDS) @@ -134,7 +134,7 @@ class Gem::Package::TarHeader # \ff flags a negative 256-based number # In case we have a match, parse it as a signed binary value # in big-endian order, except that the high-order bit is ignored. - return str.unpack('N2').last if str =~ /\A[\x80\xff]/n + return str.unpack("N2").last if str =~ /\A[\x80\xff]/n strict_oct(str) end diff --git a/lib/rubygems/package/tar_reader.rb b/lib/rubygems/package/tar_reader.rb index 41121f3bfb..cdc3fdc015 100644 --- a/lib/rubygems/package/tar_reader.rb +++ b/lib/rubygems/package/tar_reader.rb @@ -121,4 +121,4 @@ class Gem::Package::TarReader end end -require_relative 'tar_reader/entry' +require_relative "tar_reader/entry" diff --git a/lib/rubygems/package/tar_reader/entry.rb b/lib/rubygems/package/tar_reader/entry.rb index 5865599d3a..8634381c18 100644 --- a/lib/rubygems/package/tar_reader/entry.rb +++ b/lib/rubygems/package/tar_reader/entry.rb @@ -68,9 +68,9 @@ class Gem::Package::TarReader::Entry @header.name end rescue ArgumentError => e - raise unless e.message == 'string contains null byte' + raise unless e.message == "string contains null byte" raise Gem::Package::TarInvalidError, - 'tar is corrupt, name contains null byte' + "tar is corrupt, name contains null byte" end ## diff --git a/lib/rubygems/package/tar_writer.rb b/lib/rubygems/package/tar_writer.rb index 877cc167c9..6f068f50c2 100644 --- a/lib/rubygems/package/tar_writer.rb +++ b/lib/rubygems/package/tar_writer.rb @@ -166,7 +166,7 @@ class Gem::Package::TarWriter def add_file_signed(name, mode, signer) digest_algorithms = [ signer.digest_algorithm, - Gem::Security.create_digest('SHA512'), + Gem::Security.create_digest("SHA512"), ].compact.uniq digests = add_file_digest name, mode, digest_algorithms do |io| @@ -304,14 +304,14 @@ class Gem::Package::TarWriter raise Gem::Package::TooLongFileName.new("File \"#{name}\" has a too long path (should be 256 or less)") end - prefix = '' + prefix = "" if name.bytesize > 100 - parts = name.split('/', -1) # parts are never empty here + parts = name.split("/", -1) # parts are never empty here name = parts.pop # initially empty for names with a trailing slash ("foo/.../bar/") - prefix = parts.join('/') # if empty, then it's impossible to split (parts is empty too) + prefix = parts.join("/") # if empty, then it's impossible to split (parts is empty too) while !parts.empty? && (prefix.bytesize > 155 || name.empty?) - name = parts.pop + '/' + name - prefix = parts.join('/') + name = parts.pop + "/" + name + prefix = parts.join("/") end if name.bytesize > 100 or prefix.empty? diff --git a/lib/rubygems/package_task.rb b/lib/rubygems/package_task.rb index bb48616b0e..8432bc5806 100644 --- a/lib/rubygems/package_task.rb +++ b/lib/rubygems/package_task.rb @@ -20,9 +20,9 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -require_relative '../rubygems' -require_relative 'package' -require 'rake/packagetask' +require_relative "../rubygems" +require_relative "package" +require "rake/packagetask" ## # Create a package based upon a Gem::Specification. Gem packages, as well as @@ -113,7 +113,7 @@ class Gem::PackageTask < Rake::PackageTask Gem::Package.build gem_spec verbose trace do - mv gem_file, '..' + mv gem_file, ".." end end end diff --git a/lib/rubygems/platform.rb b/lib/rubygems/platform.rb index 8fcabf164d..607e3906d6 100644 --- a/lib/rubygems/platform.rb +++ b/lib/rubygems/platform.rb @@ -12,7 +12,7 @@ class Gem::Platform attr_accessor :cpu, :os, :version def self.local - arch = RbConfig::CONFIG['arch'] + arch = RbConfig::CONFIG["arch"] arch = "#{arch}_60" if arch =~ /mswin(?:32|64)$/ @local ||= new(arch) end @@ -56,7 +56,7 @@ class Gem::Platform case arch when Gem::Platform::CURRENT then Gem::Platform.local - when Gem::Platform::RUBY, nil, '' then + when Gem::Platform::RUBY, nil, "" then Gem::Platform::RUBY else super @@ -68,7 +68,7 @@ class Gem::Platform when Array then @cpu, @os, @version = arch when String then - arch = arch.split '-' + arch = arch.split "-" if arch.length > 2 and arch.last !~ /\d/ # reassemble x86-linux-gnu extra = arch.pop @@ -78,7 +78,7 @@ class Gem::Platform cpu = arch.shift @cpu = case cpu - when /i\d86/ then 'x86' + when /i\d86/ then "x86" else cpu end @@ -91,31 +91,31 @@ class Gem::Platform @cpu, os = nil, cpu if os.nil? # legacy jruby @os, @version = case os - when /aix(\d+)?/ then [ 'aix', $1 ] - when /cygwin/ then [ 'cygwin', nil ] - when /darwin(\d+)?/ then [ 'darwin', $1 ] - when /^macruby$/ then [ 'macruby', nil ] - when /freebsd(\d+)?/ then [ 'freebsd', $1 ] - when /hpux(\d+)?/ then [ 'hpux', $1 ] - when /^java$/, /^jruby$/ then [ 'java', nil ] - when /^java([\d.]*)/ then [ 'java', $1 ] - when /^dalvik(\d+)?$/ then [ 'dalvik', $1 ] - when /^dotnet$/ then [ 'dotnet', nil ] - when /^dotnet([\d.]*)/ then [ 'dotnet', $1 ] - when /linux-?((?!gnu)\w+)?/ then [ 'linux', $1 ] - when /mingw32/ then [ 'mingw32', nil ] - when /mingw-?(\w+)?/ then [ 'mingw', $1 ] + when /aix(\d+)?/ then [ "aix", $1 ] + when /cygwin/ then [ "cygwin", nil ] + when /darwin(\d+)?/ then [ "darwin", $1 ] + when /^macruby$/ then [ "macruby", nil ] + when /freebsd(\d+)?/ then [ "freebsd", $1 ] + when /hpux(\d+)?/ then [ "hpux", $1 ] + when /^java$/, /^jruby$/ then [ "java", nil ] + when /^java([\d.]*)/ then [ "java", $1 ] + when /^dalvik(\d+)?$/ then [ "dalvik", $1 ] + when /^dotnet$/ then [ "dotnet", nil ] + when /^dotnet([\d.]*)/ then [ "dotnet", $1 ] + when /linux-?((?!gnu)\w+)?/ then [ "linux", $1 ] + when /mingw32/ then [ "mingw32", nil ] + when /mingw-?(\w+)?/ then [ "mingw", $1 ] when /(mswin\d+)(\_(\d+))?/ then os, version = $1, $3 - @cpu = 'x86' if @cpu.nil? and os =~ /32$/ + @cpu = "x86" if @cpu.nil? and os =~ /32$/ [os, version] - when /netbsdelf/ then [ 'netbsdelf', nil ] - when /openbsd(\d+\.\d+)?/ then [ 'openbsd', $1 ] - when /bitrig(\d+\.\d+)?/ then [ 'bitrig', $1 ] - when /solaris(\d+\.\d+)?/ then [ 'solaris', $1 ] + when /netbsdelf/ then [ "netbsdelf", nil ] + when /openbsd(\d+\.\d+)?/ then [ "openbsd", $1 ] + when /bitrig(\d+\.\d+)?/ then [ "bitrig", $1 ] + when /solaris(\d+\.\d+)?/ then [ "solaris", $1 ] # test when /^(\w+_platform)(\d+)?/ then [ $1, $2 ] - else [ 'unknown', nil ] + else [ "unknown", nil ] end when Gem::Platform then @cpu = arch.cpu @@ -131,7 +131,7 @@ class Gem::Platform end def to_s - to_a.compact.join '-' + to_a.compact.join "-" end ## @@ -160,12 +160,12 @@ class Gem::Platform return nil unless Gem::Platform === other # universal-mingw32 matches x64-mingw-ucrt - return true if (@cpu == 'universal' or other.cpu == 'universal') and - @os.start_with?('mingw') and other.os.start_with?('mingw') + return true if (@cpu == "universal" or other.cpu == "universal") and + @os.start_with?("mingw") and other.os.start_with?("mingw") # cpu - ([nil,'universal'].include?(@cpu) or [nil, 'universal'].include?(other.cpu) or @cpu == other.cpu or - (@cpu == 'arm' and other.cpu.start_with?("arm"))) and + ([nil,"universal"].include?(@cpu) or [nil, "universal"].include?(other.cpu) or @cpu == other.cpu or + (@cpu == "arm" and other.cpu.start_with?("arm"))) and # os @os == other.os and @@ -184,17 +184,17 @@ class Gem::Platform when String then # This data is from http://gems.rubyforge.org/gems/yaml on 19 Aug 2007 other = case other - when /^i686-darwin(\d)/ then ['x86', 'darwin', $1 ] - when /^i\d86-linux/ then ['x86', 'linux', nil ] - when 'java', 'jruby' then [nil, 'java', nil ] - when /^dalvik(\d+)?$/ then [nil, 'dalvik', $1 ] - when /dotnet(\-(\d+\.\d+))?/ then ['universal','dotnet', $2 ] - when /mswin32(\_(\d+))?/ then ['x86', 'mswin32', $2 ] - when /mswin64(\_(\d+))?/ then ['x64', 'mswin64', $2 ] - when 'powerpc-darwin' then ['powerpc', 'darwin', nil ] - when /powerpc-darwin(\d)/ then ['powerpc', 'darwin', $1 ] - when /sparc-solaris2.8/ then ['sparc', 'solaris', '2.8' ] - when /universal-darwin(\d)/ then ['universal', 'darwin', $1 ] + when /^i686-darwin(\d)/ then ["x86", "darwin", $1 ] + when /^i\d86-linux/ then ["x86", "linux", nil ] + when "java", "jruby" then [nil, "java", nil ] + when /^dalvik(\d+)?$/ then [nil, "dalvik", $1 ] + when /dotnet(\-(\d+\.\d+))?/ then ["universal","dotnet", $2 ] + when /mswin32(\_(\d+))?/ then ["x86", "mswin32", $2 ] + when /mswin64(\_(\d+))?/ then ["x64", "mswin64", $2 ] + when "powerpc-darwin" then ["powerpc", "darwin", nil ] + when /powerpc-darwin(\d)/ then ["powerpc", "darwin", $1 ] + when /sparc-solaris2.8/ then ["sparc", "solaris", "2.8" ] + when /universal-darwin(\d)/ then ["universal", "darwin", $1 ] else other end @@ -210,11 +210,11 @@ class Gem::Platform # A pure-Ruby gem that may use Gem::Specification#extensions to build # binary files. - RUBY = 'ruby'.freeze + RUBY = "ruby".freeze ## # A platform-specific gem that is built for the packaging Ruby's platform. # This will be replaced with Gem::Platform::local. - CURRENT = 'current'.freeze + CURRENT = "current".freeze end diff --git a/lib/rubygems/psych_tree.rb b/lib/rubygems/psych_tree.rb index 6f399a289e..b90f9f7d1d 100644 --- a/lib/rubygems/psych_tree.rb +++ b/lib/rubygems/psych_tree.rb @@ -7,7 +7,7 @@ module Gem end unless respond_to? :create def visit_String(str) - return super unless str == '=' # or whatever you want + return super unless str == "=" # or whatever you want quote = Psych::Nodes::Scalar::SINGLE_QUOTED @emitter.scalar str, nil, nil, false, true, quote diff --git a/lib/rubygems/query_utils.rb b/lib/rubygems/query_utils.rb index e0c71c43cb..4601d9374c 100644 --- a/lib/rubygems/query_utils.rb +++ b/lib/rubygems/query_utils.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -require_relative 'local_remote_options' -require_relative 'spec_fetcher' -require_relative 'version_option' -require_relative 'text' +require_relative "local_remote_options" +require_relative "spec_fetcher" +require_relative "version_option" +require_relative "text" module Gem::QueryUtils @@ -12,41 +12,41 @@ module Gem::QueryUtils include Gem::VersionOption def add_query_options - add_option('-i', '--[no-]installed', - 'Check for installed gem') do |value, options| + add_option("-i", "--[no-]installed", + "Check for installed gem") do |value, options| options[:installed] = value end - add_option('-I', 'Equivalent to --no-installed') do |value, options| + add_option("-I", "Equivalent to --no-installed") do |value, options| options[:installed] = false end add_version_option command, "for use with --installed" - add_option('-d', '--[no-]details', - 'Display detailed information of gem(s)') do |value, options| + add_option("-d", "--[no-]details", + "Display detailed information of gem(s)") do |value, options| options[:details] = value end - add_option('--[no-]versions', - 'Display only gem names') do |value, options| + add_option("--[no-]versions", + "Display only gem names") do |value, options| options[:versions] = value options[:details] = false unless value end - add_option('-a', '--all', - 'Display all gem versions') do |value, options| + add_option("-a", "--all", + "Display all gem versions") do |value, options| options[:all] = value end - add_option('-e', '--exact', - 'Name of gem(s) to query on matches the', - 'provided STRING') do |value, options| + add_option("-e", "--exact", + "Name of gem(s) to query on matches the", + "provided STRING") do |value, options| options[:exact] = value end - add_option('--[no-]prerelease', - 'Display prerelease versions') do |value, options| + add_option("--[no-]prerelease", + "Display prerelease versions") do |value, options| options[:prerelease] = value end @@ -257,7 +257,7 @@ module Gem::QueryUtils if pls != [Gem::Platform::RUBY] platform_list = [pls.delete(Gem::Platform::RUBY), *pls.sort].compact - out = platform_list.unshift(out).join(' ') + out = platform_list.unshift(out).join(" ") end out @@ -284,7 +284,7 @@ module Gem::QueryUtils def spec_authors(entry, spec) authors = "Author#{spec.authors.length > 1 ? 's' : ''}: ".dup - authors << spec.authors.join(', ') + authors << spec.authors.join(", ") entry << format_text(authors, 68, 4) end @@ -298,7 +298,7 @@ module Gem::QueryUtils return if spec.license.nil? or spec.license.empty? licenses = "License#{spec.licenses.length > 1 ? 's' : ''}: ".dup - licenses << spec.licenses.join(', ') + licenses << spec.licenses.join(", ") entry << "\n" << format_text(licenses, 68, 4) end @@ -306,15 +306,15 @@ module Gem::QueryUtils return unless spec.loaded_from if specs.length == 1 - default = spec.default_gem? ? ' (default)' : nil + default = spec.default_gem? ? " (default)" : nil entry << "\n" << " Installed at#{default}: #{spec.base_dir}" else - label = 'Installed at' + label = "Installed at" specs.each do |s| version = s.version.to_s - version << ', default' if s.default_gem? + version << ", default" if s.default_gem? entry << "\n" << " #{label} (#{version}): #{s.base_dir}" - label = ' ' * label.length + label = " " * label.length end end end @@ -327,7 +327,7 @@ module Gem::QueryUtils return unless non_ruby if platforms.length == 1 - title = platforms.values.length == 1 ? 'Platform' : 'Platforms' + title = platforms.values.length == 1 ? "Platform" : "Platforms" entry << " #{title}: #{platforms.values.sort.join(', ')}\n" else entry << " Platforms:\n" @@ -336,7 +336,7 @@ module Gem::QueryUtils sorted_platforms.each do |version, pls| label = " #{version}: " - data = format_text pls.sort.join(', '), 68, label.length + data = format_text pls.sort.join(", "), 68, label.length data[0, label.length] = label entry << data << "\n" end diff --git a/lib/rubygems/rdoc.rb b/lib/rubygems/rdoc.rb index ac5e8f0822..769ec61d1e 100644 --- a/lib/rubygems/rdoc.rb +++ b/lib/rubygems/rdoc.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true -require_relative '../rubygems' +require_relative "../rubygems" begin - require 'rdoc/rubygems_hook' + require "rdoc/rubygems_hook" module Gem RDoc = ::RDoc::RubygemsHook end diff --git a/lib/rubygems/remote_fetcher.rb b/lib/rubygems/remote_fetcher.rb index b8f9f90cee..d028739861 100644 --- a/lib/rubygems/remote_fetcher.rb +++ b/lib/rubygems/remote_fetcher.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require_relative '../rubygems' -require_relative 'request' -require_relative 'request/connection_pools' -require_relative 's3_uri_signer' -require_relative 'uri_formatter' -require_relative 'uri' -require_relative 'user_interaction' +require_relative "../rubygems" +require_relative "request" +require_relative "request/connection_pools" +require_relative "s3_uri_signer" +require_relative "uri_formatter" +require_relative "uri" +require_relative "user_interaction" ## # RemoteFetcher handles the details of fetching gems and gem information from @@ -72,10 +72,10 @@ class Gem::RemoteFetcher # fetching the gem. def initialize(proxy=nil, dns=nil, headers={}) - require_relative 'core_ext/tcpsocket_init' if Gem.configuration.ipv4_fallback_enabled - require 'net/http' - require 'stringio' - require 'uri' + require_relative "core_ext/tcpsocket_init" if Gem.configuration.ipv4_fallback_enabled + require "net/http" + require "stringio" + require "uri" Socket.do_not_reverse_lookup = true @@ -136,7 +136,7 @@ class Gem::RemoteFetcher # REFACTOR: split this up and dispatch on scheme (eg download_http) # REFACTOR: be sure to clean up fake fetcher when you do this... cleaner case scheme - when 'http', 'https', 's3' then + when "http", "https", "s3" then unless File.exist? local_gem_path begin verbose "Downloading gem #{gem_file_name}" @@ -156,12 +156,12 @@ class Gem::RemoteFetcher self.cache_update_path remote_gem_path, local_gem_path end end - when 'file' then + when "file" then begin path = source_uri.path - path = File.dirname(path) if File.extname(path) == '.gem' + path = File.dirname(path) if File.extname(path) == ".gem" - remote_gem_path = Gem::Util.correct_for_windows_path(File.join(path, 'gems', gem_file_name)) + remote_gem_path = Gem::Util.correct_for_windows_path(File.join(path, "gems", gem_file_name)) FileUtils.cp(remote_gem_path, local_gem_path) rescue Errno::EACCES @@ -171,7 +171,7 @@ class Gem::RemoteFetcher verbose "Using local gem #{local_gem_path}" when nil then # TODO test for local overriding cache source_path = if Gem.win_platform? && source_uri.scheme && - !source_uri.path.include?(':') + !source_uri.path.include?(":") "#{source_uri.scheme}:#{source_uri.path}" else source_uri.path @@ -216,9 +216,9 @@ class Gem::RemoteFetcher head ? response : response.body when Net::HTTPMovedPermanently, Net::HTTPFound, Net::HTTPSeeOther, Net::HTTPTemporaryRedirect then - raise FetchError.new('too many redirects', uri) if depth > 10 + raise FetchError.new("too many redirects", uri) if depth > 10 - unless location = response['Location'] + unless location = response["Location"] raise FetchError.new("redirecting but no redirect location was given", uri) end location = Gem::Uri.new location @@ -312,7 +312,7 @@ class Gem::RemoteFetcher end def https?(uri) - uri.scheme.downcase == 'https' + uri.scheme.downcase == "https" end def close_all diff --git a/lib/rubygems/request.rb b/lib/rubygems/request.rb index 6d6c2d8de8..d15ba91209 100644 --- a/lib/rubygems/request.rb +++ b/lib/rubygems/request.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'net/http' -require_relative 'user_interaction' +require "net/http" +require_relative "user_interaction" class Gem::Request extend Gem::UserInteraction @@ -44,7 +44,7 @@ class Gem::Request end def self.configure_connection_for_https(connection, cert_files) - raise Gem::Exception.new('OpenSSL is not available. Install OpenSSL and rebuild Ruby (preferred) or use non-HTTPS sources') unless Gem::HAVE_OPENSSL + raise Gem::Exception.new("OpenSSL is not available. Install OpenSSL and rebuild Ruby (preferred) or use non-HTTPS sources") unless Gem::HAVE_OPENSSL connection.use_ssl = true connection.verify_mode = @@ -96,10 +96,10 @@ class Gem::Request return unless cert case error_number when OpenSSL::X509::V_ERR_CERT_HAS_EXPIRED then - require 'time' + require "time" "Certificate #{cert.subject} expired at #{cert.not_after.iso8601}" when OpenSSL::X509::V_ERR_CERT_NOT_YET_VALID then - require 'time' + require "time" "Certificate #{cert.subject} not valid until #{cert.not_before.iso8601}" when OpenSSL::X509::V_ERR_CERT_REJECTED then "Certificate #{cert.subject} is rejected" @@ -140,13 +140,13 @@ class Gem::Request Gem::UriFormatter.new(@uri.password).unescape end - request.add_field 'User-Agent', @user_agent - request.add_field 'Connection', 'keep-alive' - request.add_field 'Keep-Alive', '30' + request.add_field "User-Agent", @user_agent + request.add_field "Connection", "keep-alive" + request.add_field "Keep-Alive", "30" if @last_modified - require 'time' - request.add_field 'If-Modified-Since', @last_modified.httpdate + require "time" + request.add_field "If-Modified-Since", @last_modified.httpdate end yield request if block_given? @@ -158,7 +158,7 @@ class Gem::Request # Returns a proxy URI for the given +scheme+ if one is set in the # environment variables. - def self.get_proxy_from_env(scheme = 'http') + def self.get_proxy_from_env(scheme = "http") _scheme = scheme.downcase _SCHEME = scheme.upcase env_proxy = ENV["#{_scheme}_proxy"] || ENV["#{_SCHEME}_PROXY"] @@ -166,8 +166,8 @@ class Gem::Request no_env_proxy = env_proxy.nil? || env_proxy.empty? if no_env_proxy - return (_scheme == 'https' || _scheme == 'http') ? - :no_proxy : get_proxy_from_env('http') + return (_scheme == "https" || _scheme == "http") ? + :no_proxy : get_proxy_from_env("http") end require "uri" @@ -229,14 +229,14 @@ class Gem::Request reset connection - raise Gem::RemoteFetcher::FetchError.new('too many bad responses', @uri) if bad_response + raise Gem::RemoteFetcher::FetchError.new("too many bad responses", @uri) if bad_response bad_response = true retry rescue Net::HTTPFatalError verbose "fatal error" - raise Gem::RemoteFetcher::FetchError.new('fatal error', @uri) + raise Gem::RemoteFetcher::FetchError.new("fatal error", @uri) # HACK work around EOFError bug in Net::HTTP # NOTE Errno::ECONNABORTED raised a lot on Windows, and make impossible # to install gems. @@ -246,7 +246,7 @@ class Gem::Request requests = @requests[connection.object_id] verbose "connection reset after #{requests} requests, retrying" - raise Gem::RemoteFetcher::FetchError.new('too many connection resets', @uri) if retried + raise Gem::RemoteFetcher::FetchError.new("too many connection resets", @uri) if retried reset connection @@ -273,7 +273,7 @@ class Gem::Request ua = "RubyGems/#{Gem::VERSION} #{Gem::Platform.local}".dup ruby_version = RUBY_VERSION - ruby_version += 'dev' if RUBY_PATCHLEVEL == -1 + ruby_version += "dev" if RUBY_PATCHLEVEL == -1 ua << " Ruby/#{ruby_version} (#{RUBY_RELEASE_DATE}" if RUBY_PATCHLEVEL >= 0 @@ -283,12 +283,12 @@ class Gem::Request end ua << ")" - ua << " #{RUBY_ENGINE}" if RUBY_ENGINE != 'ruby' + ua << " #{RUBY_ENGINE}" if RUBY_ENGINE != "ruby" ua end end -require_relative 'request/http_pool' -require_relative 'request/https_pool' -require_relative 'request/connection_pools' +require_relative "request/http_pool" +require_relative "request/https_pool" +require_relative "request/connection_pools" diff --git a/lib/rubygems/request/connection_pools.rb b/lib/rubygems/request/connection_pools.rb index a4c2929b38..a283267674 100644 --- a/lib/rubygems/request/connection_pools.rb +++ b/lib/rubygems/request/connection_pools.rb @@ -37,7 +37,7 @@ class Gem::Request::ConnectionPools # :nodoc: # Returns list of no_proxy entries (if any) from the environment def get_no_proxy_from_env - env_no_proxy = ENV['no_proxy'] || ENV['NO_PROXY'] + env_no_proxy = ENV["no_proxy"] || ENV["NO_PROXY"] return [] if env_no_proxy.nil? or env_no_proxy.empty? @@ -45,7 +45,7 @@ class Gem::Request::ConnectionPools # :nodoc: end def https?(uri) - uri.scheme.downcase == 'https' + uri.scheme.downcase == "https" end def no_proxy?(host, env_no_proxy) diff --git a/lib/rubygems/request_set.rb b/lib/rubygems/request_set.rb index 01b01599a8..df215e4af3 100644 --- a/lib/rubygems/request_set.rb +++ b/lib/rubygems/request_set.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require_relative 'tsort' +require_relative "tsort" ## # A RequestSet groups a request to activate a set of dependencies. @@ -254,7 +254,7 @@ class Gem::RequestSet end def install_into(dir, force = true, options = {}) - gem_home, ENV['GEM_HOME'] = ENV['GEM_HOME'], dir + gem_home, ENV["GEM_HOME"] = ENV["GEM_HOME"], dir existing = force ? [] : specs_in(dir) existing.delete_if {|s| @always_install.include? s } @@ -287,7 +287,7 @@ class Gem::RequestSet installed ensure - ENV['GEM_HOME'] = gem_home + ENV["GEM_HOME"] = gem_home end ## @@ -337,32 +337,32 @@ class Gem::RequestSet end def pretty_print(q) # :nodoc: - q.group 2, '[RequestSet:', ']' do + q.group 2, "[RequestSet:", "]" do q.breakable if @remote - q.text 'remote' + q.text "remote" q.breakable end if @prerelease - q.text 'prerelease' + q.text "prerelease" q.breakable end if @development_shallow - q.text 'shallow development' + q.text "shallow development" q.breakable elsif @development - q.text 'development' + q.text "development" q.breakable end if @soft_missing - q.text 'soft missing' + q.text "soft missing" end - q.group 2, '[dependencies:', ']' do + q.group 2, "[dependencies:", "]" do q.breakable @dependencies.map do |dep| q.text dep.to_s @@ -371,7 +371,7 @@ class Gem::RequestSet end q.breakable - q.text 'sets:' + q.text "sets:" q.breakable q.pp @sets.map {|set| set.class } @@ -461,6 +461,6 @@ class Gem::RequestSet end end -require_relative 'request_set/gem_dependency_api' -require_relative 'request_set/lockfile' -require_relative 'request_set/lockfile/tokenizer' +require_relative "request_set/gem_dependency_api" +require_relative "request_set/lockfile" +require_relative "request_set/lockfile/tokenizer" diff --git a/lib/rubygems/request_set/gem_dependency_api.rb b/lib/rubygems/request_set/gem_dependency_api.rb index 7188b07346..568d9f952f 100644 --- a/lib/rubygems/request_set/gem_dependency_api.rb +++ b/lib/rubygems/request_set/gem_dependency_api.rb @@ -50,10 +50,10 @@ class Gem::RequestSet::GemDependencyAPI :ruby_21 => %w[ruby rbx maglev truffleruby], }.freeze - mswin = Gem::Platform.new 'x86-mswin32' - mswin64 = Gem::Platform.new 'x64-mswin64' - x86_mingw = Gem::Platform.new 'x86-mingw32' - x64_mingw = Gem::Platform.new 'x64-mingw32' + mswin = Gem::Platform.new "x86-mswin32" + mswin64 = Gem::Platform.new "x64-mswin64" + x86_mingw = Gem::Platform.new "x86-mingw32" + x64_mingw = Gem::Platform.new "x64-mingw32" PLATFORM_MAP = { # :nodoc: :jruby => Gem::Platform::RUBY, @@ -91,11 +91,11 @@ class Gem::RequestSet::GemDependencyAPI :x64_mingw_21 => x64_mingw, }.freeze - gt_eq_0 = Gem::Requirement.new '>= 0' - tilde_gt_1_8_0 = Gem::Requirement.new '~> 1.8.0' - tilde_gt_1_9_0 = Gem::Requirement.new '~> 1.9.0' - tilde_gt_2_0_0 = Gem::Requirement.new '~> 2.0.0' - tilde_gt_2_1_0 = Gem::Requirement.new '~> 2.1.0' + gt_eq_0 = Gem::Requirement.new ">= 0" + tilde_gt_1_8_0 = Gem::Requirement.new "~> 1.8.0" + tilde_gt_1_9_0 = Gem::Requirement.new "~> 1.9.0" + tilde_gt_2_0_0 = Gem::Requirement.new "~> 2.0.0" + tilde_gt_2_1_0 = Gem::Requirement.new "~> 2.1.0" VERSION_MAP = { # :nodoc: :jruby => gt_eq_0, @@ -435,7 +435,7 @@ Gem dependencies file #{@path} requires #{name} more than once. reference ||= ref reference ||= branch reference ||= tag - reference ||= 'master' + reference ||= "master" if ref && branch warn <<-WARNING @@ -637,8 +637,8 @@ Gem dependencies file #{@path} includes git reference for both ref/branch and ta # :development. Only one group may be specified. def gemspec(options = {}) - name = options.delete(:name) || '{,*}' - path = options.delete(:path) || '.' + name = options.delete(:name) || "{,*}" + path = options.delete(:path) || "." development_group = options.delete(:development_group) || :development spec = find_gemspec name, path @@ -697,11 +697,11 @@ Gem dependencies file #{@path} includes git reference for both ref/branch and ta def pin_gem_source(name, type = :default, source = nil) source_description = case type - when :default then '(default)' + when :default then "(default)" when :path then "path: #{source}" when :git then "git: #{source}" when :source then "source: #{source}" - else '(unknown)' + else "(unknown)" end raise ArgumentError, @@ -788,7 +788,7 @@ Gem dependencies file #{@path} includes git reference for both ref/branch and ta engine_version = options[:engine_version] raise ArgumentError, - 'You must specify engine_version along with the Ruby engine' if + "You must specify engine_version along with the Ruby engine" if engine and not engine_version return true if @installing diff --git a/lib/rubygems/request_set/lockfile.rb b/lib/rubygems/request_set/lockfile.rb index 684d3fc7fe..3ba202f661 100644 --- a/lib/rubygems/request_set/lockfile.rb +++ b/lib/rubygems/request_set/lockfile.rb @@ -76,7 +76,7 @@ class Gem::RequestSet::Lockfile @gem_deps_file = File.expand_path(gem_deps_file) @gem_deps_dir = File.dirname(@gem_deps_file) - if RUBY_VERSION < '2.7' + if RUBY_VERSION < "2.7" @gem_deps_file.untaint unless gem_deps_file.tainted? end @@ -106,7 +106,7 @@ class Gem::RequestSet::Lockfile out << " specs:" requests.sort_by {|request| request.name }.each do |request| - next if request.spec.name == 'bundler' + next if request.spec.name == "bundler" platform = "-#{request.spec.platform}" unless Gem::Platform::RUBY == request.spec.platform @@ -156,7 +156,7 @@ class Gem::RequestSet::Lockfile if dest.index(base) == 0 offset = dest[base.size + 1..-1] - return '.' unless offset + return "." unless offset offset else @@ -224,7 +224,7 @@ class Gem::RequestSet::Lockfile def write content = to_s - File.open "#{@gem_deps_file}.lock", 'w' do |io| + File.open "#{@gem_deps_file}.lock", "w" do |io| io.write content end end @@ -236,4 +236,4 @@ class Gem::RequestSet::Lockfile end end -require_relative 'lockfile/tokenizer' +require_relative "lockfile/tokenizer" diff --git a/lib/rubygems/request_set/lockfile/parser.rb b/lib/rubygems/request_set/lockfile/parser.rb index 8c12b435af..376d37f9e2 100644 --- a/lib/rubygems/request_set/lockfile/parser.rb +++ b/lib/rubygems/request_set/lockfile/parser.rb @@ -19,15 +19,15 @@ class Gem::RequestSet::Lockfile::Parser @tokens.skip :newline case token.value - when 'DEPENDENCIES' then + when "DEPENDENCIES" then parse_DEPENDENCIES - when 'GIT' then + when "GIT" then parse_GIT - when 'GEM' then + when "GEM" then parse_GEM - when 'PATH' then + when "PATH" then parse_PATH - when 'PLATFORMS' then + when "PLATFORMS" then parse_PLATFORMS else token = get until @tokens.empty? or peek.first == :section @@ -110,8 +110,8 @@ class Gem::RequestSet::Lockfile::Parser def parse_GEM # :nodoc: sources = [] - while [:entry, 'remote'] == peek.first(2) do - get :entry, 'remote' + while [:entry, "remote"] == peek.first(2) do + get :entry, "remote" data = get(:text).value skip :newline @@ -120,7 +120,7 @@ class Gem::RequestSet::Lockfile::Parser sources << Gem::Source.new(Gem::DEFAULT_HOST) if sources.empty? - get :entry, 'specs' + get :entry, "specs" skip :newline @@ -145,7 +145,7 @@ class Gem::RequestSet::Lockfile::Parser data = token.value if type == :text and column == 4 - version, platform = data.split '-', 2 + version, platform = data.split "-", 2 platform = platform ? Gem::Platform.new(platform) : Gem::Platform::RUBY @@ -171,12 +171,12 @@ class Gem::RequestSet::Lockfile::Parser end def parse_GIT # :nodoc: - get :entry, 'remote' + get :entry, "remote" repository = get(:text).value skip :newline - get :entry, 'revision' + get :entry, "revision" revision = get(:text).value skip :newline @@ -190,7 +190,7 @@ class Gem::RequestSet::Lockfile::Parser skip :newline end - get :entry, 'specs' + get :entry, "specs" skip :newline @@ -234,12 +234,12 @@ class Gem::RequestSet::Lockfile::Parser end def parse_PATH # :nodoc: - get :entry, 'remote' + get :entry, "remote" directory = get(:text).value skip :newline - get :entry, 'specs' + get :entry, "specs" skip :newline diff --git a/lib/rubygems/request_set/lockfile/tokenizer.rb b/lib/rubygems/request_set/lockfile/tokenizer.rb index cb8030c143..79c573a02d 100644 --- a/lib/rubygems/request_set/lockfile/tokenizer.rb +++ b/lib/rubygems/request_set/lockfile/tokenizer.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require_relative 'parser' +require_relative "parser" class Gem::RequestSet::Lockfile::Tokenizer Token = Struct.new :type, :value, :column, :line @@ -57,7 +57,7 @@ class Gem::RequestSet::Lockfile::Tokenizer private def tokenize(input) - require 'strscan' + require "strscan" s = StringScanner.new input until s.eos? do diff --git a/lib/rubygems/requirement.rb b/lib/rubygems/requirement.rb index 9edd6aa7d3..12bf371f4e 100644 --- a/lib/rubygems/requirement.rb +++ b/lib/rubygems/requirement.rb @@ -61,7 +61,7 @@ class Gem::Requirement input when Gem::Version, Array then new input - when '!' then + when "!" then source_set else if input.respond_to? :to_str @@ -73,11 +73,11 @@ class Gem::Requirement end def self.default - new '>= 0' + new ">= 0" end def self.default_prerelease - new '>= 0.a' + new ">= 0.a" end ### @@ -218,7 +218,7 @@ class Gem::Requirement end def encode_with(coder) # :nodoc: - coder.add 'requirements', @requirements + coder.add "requirements", @requirements end ## @@ -230,7 +230,7 @@ class Gem::Requirement end def pretty_print(q) # :nodoc: - q.group 1, 'Gem::Requirement.new(', ')' do + q.group 1, "Gem::Requirement.new(", ")" do q.pp as_list end end diff --git a/lib/rubygems/resolver.rb b/lib/rubygems/resolver.rb index 51a11fed47..097e8243ee 100644 --- a/lib/rubygems/resolver.rb +++ b/lib/rubygems/resolver.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require_relative 'dependency' -require_relative 'exceptions' -require_relative 'util/list' +require_relative "dependency" +require_relative "exceptions" +require_relative "util/list" ## # Given a set of Gem::Dependency objects as +needed+ and a way to query the @@ -10,14 +10,14 @@ require_relative 'util/list' # all the requirements. class Gem::Resolver - require_relative 'resolver/molinillo' + require_relative "resolver/molinillo" ## # If the DEBUG_RESOLVER environment variable is set then debugging mode is # enabled for the resolver. This will display information about the state # of the resolver while a set of dependencies is being resolved. - DEBUG_RESOLVER = !ENV['DEBUG_RESOLVER'].nil? + DEBUG_RESOLVER = !ENV["DEBUG_RESOLVER"].nil? ## # Set to true if all development dependencies should be considered. @@ -74,7 +74,7 @@ class Gem::Resolver case sets.length when 0 then - raise ArgumentError, 'one set in the composition must be non-nil' + raise ArgumentError, "one set in the composition must be non-nil" when 1 then sets.first else @@ -124,7 +124,7 @@ class Gem::Resolver data = yield $stderr.printf "%10s (%d entries)\n", stage.to_s.upcase, data.size unless data.empty? - require 'pp' + require "pp" PP.pp data, $stderr end end @@ -173,7 +173,7 @@ class Gem::Resolver include Molinillo::UI def output - @output ||= debug? ? $stdout : File.open(IO::NULL, 'w') + @output ||= debug? ? $stdout : File.open(IO::NULL, "w") end def debug? @@ -318,30 +318,30 @@ class Gem::Resolver private :amount_constrained end -require_relative 'resolver/activation_request' -require_relative 'resolver/conflict' -require_relative 'resolver/dependency_request' -require_relative 'resolver/requirement_list' -require_relative 'resolver/stats' - -require_relative 'resolver/set' -require_relative 'resolver/api_set' -require_relative 'resolver/composed_set' -require_relative 'resolver/best_set' -require_relative 'resolver/current_set' -require_relative 'resolver/git_set' -require_relative 'resolver/index_set' -require_relative 'resolver/installer_set' -require_relative 'resolver/lock_set' -require_relative 'resolver/vendor_set' -require_relative 'resolver/source_set' - -require_relative 'resolver/specification' -require_relative 'resolver/spec_specification' -require_relative 'resolver/api_specification' -require_relative 'resolver/git_specification' -require_relative 'resolver/index_specification' -require_relative 'resolver/installed_specification' -require_relative 'resolver/local_specification' -require_relative 'resolver/lock_specification' -require_relative 'resolver/vendor_specification' +require_relative "resolver/activation_request" +require_relative "resolver/conflict" +require_relative "resolver/dependency_request" +require_relative "resolver/requirement_list" +require_relative "resolver/stats" + +require_relative "resolver/set" +require_relative "resolver/api_set" +require_relative "resolver/composed_set" +require_relative "resolver/best_set" +require_relative "resolver/current_set" +require_relative "resolver/git_set" +require_relative "resolver/index_set" +require_relative "resolver/installer_set" +require_relative "resolver/lock_set" +require_relative "resolver/vendor_set" +require_relative "resolver/source_set" + +require_relative "resolver/specification" +require_relative "resolver/spec_specification" +require_relative "resolver/api_specification" +require_relative "resolver/git_specification" +require_relative "resolver/index_specification" +require_relative "resolver/installed_specification" +require_relative "resolver/local_specification" +require_relative "resolver/lock_specification" +require_relative "resolver/vendor_specification" diff --git a/lib/rubygems/resolver/activation_request.rb b/lib/rubygems/resolver/activation_request.rb index ae35681db9..27877e0f4b 100644 --- a/lib/rubygems/resolver/activation_request.rb +++ b/lib/rubygems/resolver/activation_request.rb @@ -93,7 +93,7 @@ class Gem::Resolver::ActivationRequest end def inspect # :nodoc: - '#<%s for %p from %s>' % [ + "#<%s for %p from %s>" % [ self.class, @spec, @request ] end @@ -130,12 +130,12 @@ class Gem::Resolver::ActivationRequest end def pretty_print(q) # :nodoc: - q.group 2, '[Activation request', ']' do + q.group 2, "[Activation request", "]" do q.breakable q.pp @spec q.breakable - q.text ' for ' + q.text " for " q.pp @request end end diff --git a/lib/rubygems/resolver/api_set.rb b/lib/rubygems/resolver/api_set.rb index 21c9b8920c..f2bef54a9c 100644 --- a/lib/rubygems/resolver/api_set.rb +++ b/lib/rubygems/resolver/api_set.rb @@ -26,13 +26,13 @@ class Gem::Resolver::APISet < Gem::Resolver::Set # API URL +dep_uri+ which is described at # https://guides.rubygems.org/rubygems-org-api - def initialize(dep_uri = 'https://index.rubygems.org/info/') + def initialize(dep_uri = "https://index.rubygems.org/info/") super() dep_uri = URI dep_uri unless URI === dep_uri @dep_uri = dep_uri - @uri = dep_uri + '..' + @uri = dep_uri + ".." @data = Hash.new {|h,k| h[k] = [] } @source = Gem::Source.new @uri @@ -83,12 +83,12 @@ class Gem::Resolver::APISet < Gem::Resolver::Set end def pretty_print(q) # :nodoc: - q.group 2, '[APISet', ']' do + q.group 2, "[APISet", "]" do q.breakable q.text "URI: #{@dep_uri}" q.breakable - q.text 'gem names:' + q.text "gem names:" q.pp @data.keys end end diff --git a/lib/rubygems/resolver/api_specification.rb b/lib/rubygems/resolver/api_specification.rb index b5aa0b71d4..7af4d9cff3 100644 --- a/lib/rubygems/resolver/api_specification.rb +++ b/lib/rubygems/resolver/api_specification.rb @@ -62,7 +62,7 @@ class Gem::Resolver::APISpecification < Gem::Resolver::Specification end def pretty_print(q) # :nodoc: - q.group 2, '[APISpecification', ']' do + q.group 2, "[APISpecification", "]" do q.breakable q.text "name: #{name}" @@ -73,7 +73,7 @@ class Gem::Resolver::APISpecification < Gem::Resolver::Specification q.text "platform: #{platform}" q.breakable - q.text 'dependencies:' + q.text "dependencies:" q.breakable q.pp @dependencies diff --git a/lib/rubygems/resolver/best_set.rb b/lib/rubygems/resolver/best_set.rb index 300ea8015c..ab91ebca08 100644 --- a/lib/rubygems/resolver/best_set.rb +++ b/lib/rubygems/resolver/best_set.rb @@ -41,9 +41,9 @@ class Gem::Resolver::BestSet < Gem::Resolver::ComposedSet end def pretty_print(q) # :nodoc: - q.group 2, '[BestSet', ']' do + q.group 2, "[BestSet", "]" do q.breakable - q.text 'sets:' + q.text "sets:" q.breakable q.pp @sets diff --git a/lib/rubygems/resolver/conflict.rb b/lib/rubygems/resolver/conflict.rb index 4c4588d7e8..54a7ca4641 100644 --- a/lib/rubygems/resolver/conflict.rb +++ b/lib/rubygems/resolver/conflict.rb @@ -65,7 +65,7 @@ class Gem::Resolver::Conflict matching = matching % [ dependency, - alternates.join(', '), + alternates.join(", "), ] end @@ -97,21 +97,21 @@ class Gem::Resolver::Conflict end def pretty_print(q) # :nodoc: - q.group 2, '[Dependency conflict: ', ']' do + q.group 2, "[Dependency conflict: ", "]" do q.breakable - q.text 'activated ' + q.text "activated " q.pp @activated q.breakable - q.text ' dependency ' + q.text " dependency " q.pp @dependency q.breakable if @dependency == @failed_dep - q.text ' failed' + q.text " failed" else - q.text ' failed dependency ' + q.text " failed dependency " q.pp @failed_dep end end @@ -139,7 +139,7 @@ class Gem::Resolver::Conflict end end - path = ['user request (gem command or Gemfile)'] if path.empty? + path = ["user request (gem command or Gemfile)"] if path.empty? path end diff --git a/lib/rubygems/resolver/dependency_request.rb b/lib/rubygems/resolver/dependency_request.rb index 356aadb3b2..70a61cbc25 100644 --- a/lib/rubygems/resolver/dependency_request.rb +++ b/lib/rubygems/resolver/dependency_request.rb @@ -95,12 +95,12 @@ class Gem::Resolver::DependencyRequest end def pretty_print(q) # :nodoc: - q.group 2, '[Dependency request ', ']' do + q.group 2, "[Dependency request ", "]" do q.breakable q.text @dependency.to_s q.breakable - q.text ' requested by ' + q.text " requested by " q.pp @requester end end diff --git a/lib/rubygems/resolver/git_set.rb b/lib/rubygems/resolver/git_set.rb index eac51f15ad..f010273a8f 100644 --- a/lib/rubygems/resolver/git_set.rb +++ b/lib/rubygems/resolver/git_set.rb @@ -35,7 +35,7 @@ class Gem::Resolver::GitSet < Gem::Resolver::Set def initialize # :nodoc: super() - @git = ENV['git'] || 'git' + @git = ENV["git"] || "git" @need_submodules = {} @repositories = {} @root_dir = Gem.dir @@ -104,7 +104,7 @@ class Gem::Resolver::GitSet < Gem::Resolver::Set end def pretty_print(q) # :nodoc: - q.group 2, '[GitSet', ']' do + q.group 2, "[GitSet", "]" do next if @repositories.empty? q.breakable diff --git a/lib/rubygems/resolver/git_specification.rb b/lib/rubygems/resolver/git_specification.rb index ee47080ab4..d1e04737da 100644 --- a/lib/rubygems/resolver/git_specification.rb +++ b/lib/rubygems/resolver/git_specification.rb @@ -21,7 +21,7 @@ class Gem::Resolver::GitSpecification < Gem::Resolver::SpecSpecification # the executables. def install(options = {}) - require_relative '../installer' + require_relative "../installer" installer = Gem::Installer.for_spec spec, options @@ -35,7 +35,7 @@ class Gem::Resolver::GitSpecification < Gem::Resolver::SpecSpecification end def pretty_print(q) # :nodoc: - q.group 2, '[GitSpecification', ']' do + q.group 2, "[GitSpecification", "]" do q.breakable q.text "name: #{name}" @@ -43,7 +43,7 @@ class Gem::Resolver::GitSpecification < Gem::Resolver::SpecSpecification q.text "version: #{version}" q.breakable - q.text 'dependencies:' + q.text "dependencies:" q.breakable q.pp dependencies diff --git a/lib/rubygems/resolver/index_set.rb b/lib/rubygems/resolver/index_set.rb index 9390e34255..2344178314 100644 --- a/lib/rubygems/resolver/index_set.rb +++ b/lib/rubygems/resolver/index_set.rb @@ -53,14 +53,14 @@ class Gem::Resolver::IndexSet < Gem::Resolver::Set end def pretty_print(q) # :nodoc: - q.group 2, '[IndexSet', ']' do + q.group 2, "[IndexSet", "]" do q.breakable - q.text 'sources:' + q.text "sources:" q.breakable q.pp @f.sources q.breakable - q.text 'specs:' + q.text "specs:" q.breakable diff --git a/lib/rubygems/resolver/index_specification.rb b/lib/rubygems/resolver/index_specification.rb index 9ea76f40ba..e8c3b35f7e 100644 --- a/lib/rubygems/resolver/index_specification.rb +++ b/lib/rubygems/resolver/index_specification.rb @@ -66,11 +66,11 @@ class Gem::Resolver::IndexSpecification < Gem::Resolver::Specification end def inspect # :nodoc: - '#<%s %s source %s>' % [self.class, full_name, @source] + "#<%s %s source %s>" % [self.class, full_name, @source] end def pretty_print(q) # :nodoc: - q.group 2, '[Index specification', ']' do + q.group 2, "[Index specification", "]" do q.breakable q.text full_name @@ -80,7 +80,7 @@ class Gem::Resolver::IndexSpecification < Gem::Resolver::Specification end q.breakable - q.text 'source ' + q.text "source " q.pp @source end end diff --git a/lib/rubygems/resolver/installed_specification.rb b/lib/rubygems/resolver/installed_specification.rb index 167ba1439e..7c7ad8d85b 100644 --- a/lib/rubygems/resolver/installed_specification.rb +++ b/lib/rubygems/resolver/installed_specification.rb @@ -30,7 +30,7 @@ class Gem::Resolver::InstalledSpecification < Gem::Resolver::SpecSpecification end def pretty_print(q) # :nodoc: - q.group 2, '[InstalledSpecification', ']' do + q.group 2, "[InstalledSpecification", "]" do q.breakable q.text "name: #{name}" @@ -41,7 +41,7 @@ class Gem::Resolver::InstalledSpecification < Gem::Resolver::SpecSpecification q.text "platform: #{platform}" q.breakable - q.text 'dependencies:' + q.text "dependencies:" q.breakable q.pp spec.dependencies end diff --git a/lib/rubygems/resolver/installer_set.rb b/lib/rubygems/resolver/installer_set.rb index 45252ed241..15580d7095 100644 --- a/lib/rubygems/resolver/installer_set.rb +++ b/lib/rubygems/resolver/installer_set.rb @@ -190,7 +190,7 @@ class Gem::Resolver::InstallerSet < Gem::Resolver::Set def inspect # :nodoc: always_install = @always_install.map {|s| s.full_name } - '#<%s domain: %s specs: %p always install: %p>' % [ + "#<%s domain: %s specs: %p always install: %p>" % [ self.class, @domain, @specs.keys, always_install ] end @@ -219,16 +219,16 @@ class Gem::Resolver::InstallerSet < Gem::Resolver::Set end def pretty_print(q) # :nodoc: - q.group 2, '[InstallerSet', ']' do + q.group 2, "[InstallerSet", "]" do q.breakable q.text "domain: #{@domain}" q.breakable - q.text 'specs: ' + q.text "specs: " q.pp @specs.keys q.breakable - q.text 'always install: ' + q.text "always install: " q.pp @always_install end end diff --git a/lib/rubygems/resolver/local_specification.rb b/lib/rubygems/resolver/local_specification.rb index 9c69c4ab74..c27bab0f5a 100644 --- a/lib/rubygems/resolver/local_specification.rb +++ b/lib/rubygems/resolver/local_specification.rb @@ -17,7 +17,7 @@ class Gem::Resolver::LocalSpecification < Gem::Resolver::SpecSpecification end def pretty_print(q) # :nodoc: - q.group 2, '[LocalSpecification', ']' do + q.group 2, "[LocalSpecification", "]" do q.breakable q.text "name: #{name}" @@ -28,7 +28,7 @@ class Gem::Resolver::LocalSpecification < Gem::Resolver::SpecSpecification q.text "platform: #{platform}" q.breakable - q.text 'dependencies:' + q.text "dependencies:" q.breakable q.pp dependencies diff --git a/lib/rubygems/resolver/lock_set.rb b/lib/rubygems/resolver/lock_set.rb index eabf217aba..ff6c6c912f 100644 --- a/lib/rubygems/resolver/lock_set.rb +++ b/lib/rubygems/resolver/lock_set.rb @@ -63,15 +63,15 @@ class Gem::Resolver::LockSet < Gem::Resolver::Set end def pretty_print(q) # :nodoc: - q.group 2, '[LockSet', ']' do + q.group 2, "[LockSet", "]" do q.breakable - q.text 'source:' + q.text "source:" q.breakable q.pp @source q.breakable - q.text 'specs:' + q.text "specs:" q.breakable q.pp @specs.map {|spec| spec.full_name } diff --git a/lib/rubygems/resolver/lock_specification.rb b/lib/rubygems/resolver/lock_specification.rb index cdb8e4e425..4a30dcf849 100644 --- a/lib/rubygems/resolver/lock_specification.rb +++ b/lib/rubygems/resolver/lock_specification.rb @@ -29,7 +29,7 @@ class Gem::Resolver::LockSpecification < Gem::Resolver::Specification def install(options = {}) destination = options[:install_dir] || Gem.dir - if File.exist? File.join(destination, 'specifications', spec.spec_name) + if File.exist? File.join(destination, "specifications", spec.spec_name) yield nil return end @@ -45,7 +45,7 @@ class Gem::Resolver::LockSpecification < Gem::Resolver::Specification end def pretty_print(q) # :nodoc: - q.group 2, '[LockSpecification', ']' do + q.group 2, "[LockSpecification", "]" do q.breakable q.text "name: #{@name}" @@ -59,7 +59,7 @@ class Gem::Resolver::LockSpecification < Gem::Resolver::Specification unless @dependencies.empty? q.breakable - q.text 'dependencies:' + q.text "dependencies:" q.breakable q.pp @dependencies end diff --git a/lib/rubygems/resolver/molinillo.rb b/lib/rubygems/resolver/molinillo.rb index 12ca740e5a..e154342571 100644 --- a/lib/rubygems/resolver/molinillo.rb +++ b/lib/rubygems/resolver/molinillo.rb @@ -1,2 +1,2 @@ # frozen_string_literal: true -require_relative 'molinillo/lib/molinillo' +require_relative "molinillo/lib/molinillo" diff --git a/lib/rubygems/resolver/specification.rb b/lib/rubygems/resolver/specification.rb index dfcb7eb057..3da803cab5 100644 --- a/lib/rubygems/resolver/specification.rb +++ b/lib/rubygems/resolver/specification.rb @@ -93,7 +93,7 @@ class Gem::Resolver::Specification # specification. def install(options = {}) - require_relative '../installer' + require_relative "../installer" gem = download options diff --git a/lib/rubygems/resolver/vendor_set.rb b/lib/rubygems/resolver/vendor_set.rb index 48c640d8c9..6c0ef2a1a1 100644 --- a/lib/rubygems/resolver/vendor_set.rb +++ b/lib/rubygems/resolver/vendor_set.rb @@ -69,7 +69,7 @@ class Gem::Resolver::VendorSet < Gem::Resolver::Set end def pretty_print(q) # :nodoc: - q.group 2, '[VendorSet', ']' do + q.group 2, "[VendorSet", "]" do next if @directories.empty? q.breakable diff --git a/lib/rubygems/s3_uri_signer.rb b/lib/rubygems/s3_uri_signer.rb index 4d1deee997..5522753af5 100644 --- a/lib/rubygems/s3_uri_signer.rb +++ b/lib/rubygems/s3_uri_signer.rb @@ -1,4 +1,4 @@ -require_relative 'openssl' +require_relative "openssl" ## # S3URISigner implements AWS SigV4 for S3 Source to avoid a dependency on the aws-sdk-* gems @@ -138,14 +138,14 @@ class Gem::S3URISigner end def ec2_metadata_credentials_json - require 'net/http' - require_relative 'request' - require_relative 'request/connection_pools' - require 'json' + require "net/http" + require_relative "request" + require_relative "request/connection_pools" + require "json" iam_info = ec2_metadata_request(EC2_IAM_INFO) # Expected format: arn:aws:iam::<id>:instance-profile/<role_name> - role_name = iam_info['InstanceProfileArn'].split('/').last + role_name = iam_info["InstanceProfileArn"].split("/").last ec2_metadata_request(EC2_IAM_SECURITY_CREDENTIALS + role_name) end diff --git a/lib/rubygems/safe_yaml.rb b/lib/rubygems/safe_yaml.rb index 81f99ee26e..5a98505598 100644 --- a/lib/rubygems/safe_yaml.rb +++ b/lib/rubygems/safe_yaml.rb @@ -26,7 +26,7 @@ module Gem if ::Psych.respond_to? :safe_load def self.safe_load(input) - if Gem::Version.new(Psych::VERSION) >= Gem::Version.new('3.1.0.pre1') + if Gem::Version.new(Psych::VERSION) >= Gem::Version.new("3.1.0.pre1") ::Psych.safe_load(input, permitted_classes: PERMITTED_CLASSES, permitted_symbols: PERMITTED_SYMBOLS, aliases: true) else ::Psych.safe_load(input, PERMITTED_CLASSES, PERMITTED_SYMBOLS, true) @@ -34,7 +34,7 @@ module Gem end def self.load(input) - if Gem::Version.new(Psych::VERSION) >= Gem::Version.new('3.1.0.pre1') + if Gem::Version.new(Psych::VERSION) >= Gem::Version.new("3.1.0.pre1") ::Psych.safe_load(input, permitted_classes: [::Symbol]) else ::Psych.safe_load(input, [::Symbol]) diff --git a/lib/rubygems/security.rb b/lib/rubygems/security.rb index fc23c1c481..4eb4023055 100644 --- a/lib/rubygems/security.rb +++ b/lib/rubygems/security.rb @@ -5,8 +5,8 @@ # See LICENSE.txt for permissions. #++ -require_relative 'exceptions' -require_relative 'openssl' +require_relative "exceptions" +require_relative "openssl" ## # = Signing gems @@ -334,7 +334,7 @@ module Gem::Security ## # Used internally to select the signing digest from all computed digests - DIGEST_NAME = 'SHA256' # :nodoc: + DIGEST_NAME = "SHA256" # :nodoc: ## # Length of keys created by RSA and DSA keys @@ -344,18 +344,18 @@ module Gem::Security ## # Default algorithm to use when building a key pair - DEFAULT_KEY_ALGORITHM = 'RSA' + DEFAULT_KEY_ALGORITHM = "RSA" ## # Named curve used for Elliptic Curve - EC_NAME = 'secp384r1' + EC_NAME = "secp384r1" ## # Cipher used to encrypt the key pair used to sign gems. # Must be in the list returned by OpenSSL::Cipher.ciphers - KEY_CIPHER = OpenSSL::Cipher.new('AES-256-CBC') if defined?(OpenSSL::Cipher) + KEY_CIPHER = OpenSSL::Cipher.new("AES-256-CBC") if defined?(OpenSSL::Cipher) ## # One day in seconds @@ -376,10 +376,10 @@ module Gem::Security # * The certificate contains a subject key identifier EXTENSIONS = { - 'basicConstraints' => 'CA:FALSE', - 'keyUsage' => - 'keyEncipherment,dataEncipherment,digitalSignature', - 'subjectKeyIdentifier' => 'hash', + "basicConstraints" => "CA:FALSE", + "keyUsage" => + "keyEncipherment,dataEncipherment,digitalSignature", + "subjectKeyIdentifier" => "hash", }.freeze def self.alt_name_or_x509_entry(certificate, x509_entry) @@ -473,7 +473,7 @@ module Gem::Security OpenSSL::Digest.new(algorithm) end else - require 'digest' + require "digest" def self.create_digest(algorithm = DIGEST_NAME) Digest.const_get(algorithm).new @@ -487,11 +487,11 @@ module Gem::Security def self.create_key(algorithm) if defined?(OpenSSL::PKey) case algorithm.downcase - when 'dsa' + when "dsa" OpenSSL::PKey::DSA.new(RSA_DSA_KEY_LENGTH) - when 'rsa' + when "rsa" OpenSSL::PKey::RSA.new(RSA_DSA_KEY_LENGTH) - when 'ec' + when "ec" if RUBY_VERSION >= "2.4.0" OpenSSL::PKey::EC.generate(EC_NAME) else @@ -510,11 +510,11 @@ module Gem::Security # Turns +email_address+ into an OpenSSL::X509::Name def self.email_to_name(email_address) - email_address = email_address.gsub(/[^\[email protected]]+/i, '_') + email_address = email_address.gsub(/[^\[email protected]]+/i, "_") - cn, dcs = email_address.split '@' + cn, dcs = email_address.split "@" - dcs = dcs.split '.' + dcs = dcs.split "." OpenSSL::X509::Name.new([ ["CN", cn], @@ -571,17 +571,17 @@ module Gem::Security signee_key = certificate.public_key alt_name = certificate.extensions.find do |extension| - extension.oid == 'subjectAltName' + extension.oid == "subjectAltName" end - extensions = extensions.merge 'subjectAltName' => alt_name.value if + extensions = extensions.merge "subjectAltName" => alt_name.value if alt_name issuer_alt_name = signing_cert.extensions.find do |extension| - extension.oid == 'subjectAltName' + extension.oid == "subjectAltName" end - extensions = extensions.merge 'issuerAltName' => issuer_alt_name.value if + extensions = extensions.merge "issuerAltName" => issuer_alt_name.value if issuer_alt_name signed = create_cert signee_subject, signee_key, age, extensions, serial @@ -597,7 +597,7 @@ module Gem::Security def self.trust_dir return @trust_dir if @trust_dir - dir = File.join Gem.user_home, '.gem', 'trust' + dir = File.join Gem.user_home, ".gem", "trust" @trust_dir ||= Gem::Security::TrustDir.new dir end @@ -617,7 +617,7 @@ module Gem::Security def self.write(pemmable, path, permissions = 0600, passphrase = nil, cipher = KEY_CIPHER) path = File.expand_path path - File.open path, 'wb', permissions do |io| + File.open path, "wb", permissions do |io| if passphrase and cipher io.write pemmable.to_pem cipher, passphrase else @@ -633,9 +633,9 @@ module Gem::Security end if Gem::HAVE_OPENSSL - require_relative 'security/policy' - require_relative 'security/policies' - require_relative 'security/trust_dir' + require_relative "security/policy" + require_relative "security/policies" + require_relative "security/trust_dir" end -require_relative 'security/signer' +require_relative "security/signer" diff --git a/lib/rubygems/security/policies.rb b/lib/rubygems/security/policies.rb index 8f6ad99316..b3f9070394 100644 --- a/lib/rubygems/security/policies.rb +++ b/lib/rubygems/security/policies.rb @@ -5,7 +5,7 @@ module Gem::Security # No security policy: all package signature checks are disabled. NoSecurity = Policy.new( - 'No Security', + "No Security", :verify_data => false, :verify_signer => false, :verify_chain => false, @@ -23,7 +23,7 @@ module Gem::Security # easily spoofed, and is not recommended. AlmostNoSecurity = Policy.new( - 'Almost No Security', + "Almost No Security", :verify_data => true, :verify_signer => false, :verify_chain => false, @@ -40,7 +40,7 @@ module Gem::Security # is not recommended. LowSecurity = Policy.new( - 'Low Security', + "Low Security", :verify_data => true, :verify_signer => true, :verify_chain => false, @@ -59,7 +59,7 @@ module Gem::Security # gem off as unsigned. MediumSecurity = Policy.new( - 'Medium Security', + "Medium Security", :verify_data => true, :verify_signer => true, :verify_chain => true, @@ -78,7 +78,7 @@ module Gem::Security # a reasonable guarantee that the contents of the gem have not been altered. HighSecurity = Policy.new( - 'High Security', + "High Security", :verify_data => true, :verify_signer => true, :verify_chain => true, @@ -91,7 +91,7 @@ module Gem::Security # Policy used to verify a certificate and key when signing a gem SigningPolicy = Policy.new( - 'Signing Policy', + "Signing Policy", :verify_data => false, :verify_signer => true, :verify_chain => true, @@ -104,11 +104,11 @@ module Gem::Security # Hash of configured security policies Policies = { - 'NoSecurity' => NoSecurity, - 'AlmostNoSecurity' => AlmostNoSecurity, - 'LowSecurity' => LowSecurity, - 'MediumSecurity' => MediumSecurity, - 'HighSecurity' => HighSecurity, + "NoSecurity" => NoSecurity, + "AlmostNoSecurity" => AlmostNoSecurity, + "LowSecurity" => LowSecurity, + "MediumSecurity" => MediumSecurity, + "HighSecurity" => HighSecurity, # SigningPolicy is not intended for use by `gem -P` so do not list it }.freeze diff --git a/lib/rubygems/security/policy.rb b/lib/rubygems/security/policy.rb index 06eae073f4..43588fd7f1 100644 --- a/lib/rubygems/security/policy.rb +++ b/lib/rubygems/security/policy.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require_relative '../user_interaction' +require_relative "../user_interaction" ## # A Gem::Security::Policy object encapsulates the settings for verifying @@ -53,8 +53,8 @@ class Gem::Security::Policy # and is valid for the given +time+. def check_chain(chain, time) - raise Gem::Security::Exception, 'missing signing chain' unless chain - raise Gem::Security::Exception, 'empty signing chain' if chain.empty? + raise Gem::Security::Exception, "missing signing chain" unless chain + raise Gem::Security::Exception, "empty signing chain" if chain.empty? begin chain.each_cons 2 do |issuer, cert| @@ -83,7 +83,7 @@ class Gem::Security::Policy # If the +issuer+ is +nil+ no verification is performed. def check_cert(signer, issuer, time) - raise Gem::Security::Exception, 'missing signing certificate' unless + raise Gem::Security::Exception, "missing signing certificate" unless signer message = "certificate #{signer.subject}" @@ -112,7 +112,7 @@ class Gem::Security::Policy unless signer and key return true unless @only_signed - raise Gem::Security::Exception, 'missing key or signature' + raise Gem::Security::Exception, "missing key or signature" end raise Gem::Security::Exception, @@ -127,11 +127,11 @@ class Gem::Security::Policy # +time+. def check_root(chain, time) - raise Gem::Security::Exception, 'missing signing chain' unless chain + raise Gem::Security::Exception, "missing signing chain" unless chain root = chain.first - raise Gem::Security::Exception, 'missing root certificate' unless root + raise Gem::Security::Exception, "missing root certificate" unless root raise Gem::Security::Exception, "root certificate #{root.subject} is not self-signed " + @@ -146,11 +146,11 @@ class Gem::Security::Policy # the digests of the two certificates match according to +digester+ def check_trust(chain, digester, trust_dir) - raise Gem::Security::Exception, 'missing signing chain' unless chain + raise Gem::Security::Exception, "missing signing chain" unless chain root = chain.first - raise Gem::Security::Exception, 'missing root certificate' unless root + raise Gem::Security::Exception, "missing root certificate" unless root path = Gem::Security.trust_dir.cert_path root @@ -182,7 +182,7 @@ class Gem::Security::Policy def subject(certificate) # :nodoc: certificate.extensions.each do |extension| - next unless extension.oid == 'subjectAltName' + next unless extension.oid == "subjectAltName" return extension.value end @@ -206,7 +206,7 @@ class Gem::Security::Policy # If +key+ is given it is used to validate the signing certificate. def verify(chain, key = nil, digests = {}, signatures = {}, - full_name = '(unknown)') + full_name = "(unknown)") if signatures.empty? if @only_signed raise Gem::Security::Exception, @@ -230,7 +230,7 @@ class Gem::Security::Policy end if @verify_data - raise Gem::Security::Exception, 'no digests provided (probable bug)' if + raise Gem::Security::Exception, "no digests provided (probable bug)" if signer_digests.nil? or signer_digests.empty? else signer_digests = {} diff --git a/lib/rubygems/security/signer.rb b/lib/rubygems/security/signer.rb index 968cf88973..b1308c4e42 100644 --- a/lib/rubygems/security/signer.rb +++ b/lib/rubygems/security/signer.rb @@ -42,7 +42,7 @@ class Gem::Security::Signer def self.re_sign_cert(expired_cert, expired_cert_path, private_key) return unless expired_cert.not_after < Time.now - expiry = expired_cert.not_after.strftime('%Y%m%d%H%M%S') + expiry = expired_cert.not_after.strftime("%Y%m%d%H%M%S") expired_cert_file = "#{File.basename(expired_cert_path)}.expired.#{expiry}" new_expired_cert_path = File.join(Gem.user_home, ".gem", expired_cert_file) @@ -105,7 +105,7 @@ class Gem::Security::Signer # this value is preferred, otherwise the subject is used. def extract_name(cert) # :nodoc: - subject_alt_name = cert.extensions.find {|e| 'subjectAltName' == e.oid } + subject_alt_name = cert.extensions.find {|e| "subjectAltName" == e.oid } if subject_alt_name /\Aemail:/ =~ subject_alt_name.value # rubocop:disable Performance/StartWith @@ -139,7 +139,7 @@ class Gem::Security::Signer def sign(data) return unless @key - raise Gem::Security::Exception, 'no certs provided' if @cert_chain.empty? + raise Gem::Security::Exception, "no certs provided" if @cert_chain.empty? if @cert_chain.length == 1 and @cert_chain.last.not_after < Time.now alert("Your certificate has expired, trying to re-sign it...") @@ -182,7 +182,7 @@ class Gem::Security::Signer return unless disk_key if disk_key.to_pem == @key.to_pem && disk_cert == old_cert.to_pem - expiry = old_cert.not_after.strftime('%Y%m%d%H%M%S') + expiry = old_cert.not_after.strftime("%Y%m%d%H%M%S") old_cert_file = "gem-public_cert.pem.expired.#{expiry}" old_cert_path = File.join(Gem.user_home, ".gem", old_cert_file) diff --git a/lib/rubygems/security/trust_dir.rb b/lib/rubygems/security/trust_dir.rb index 456947274c..a6882c66e7 100644 --- a/lib/rubygems/security/trust_dir.rb +++ b/lib/rubygems/security/trust_dir.rb @@ -41,7 +41,7 @@ class Gem::Security::TrustDir def each_certificate return enum_for __method__ unless block_given? - glob = File.join @dir, '*.pem' + glob = File.join @dir, "*.pem" Dir[glob].each do |certificate_file| begin @@ -92,7 +92,7 @@ class Gem::Security::TrustDir destination = cert_path certificate - File.open destination, 'wb', 0600 do |io| + File.open destination, "wb", 0600 do |io| io.write certificate.to_pem io.chmod(@permissions[:trusted_cert]) end @@ -104,7 +104,7 @@ class Gem::Security::TrustDir # permissions. def verify - require 'fileutils' + require "fileutils" if File.exist? @dir raise Gem::Security::Exception, "trust directory #{@dir} is not a directory" unless diff --git a/lib/rubygems/security_option.rb b/lib/rubygems/security_option.rb index a4c570ded5..ab3898bf11 100644 --- a/lib/rubygems/security_option.rb +++ b/lib/rubygems/security_option.rb @@ -5,7 +5,7 @@ # See LICENSE.txt for permissions. #++ -require_relative '../rubygems' +require_relative "../rubygems" # forward-declare @@ -20,9 +20,9 @@ end module Gem::SecurityOption def add_security_option Gem::OptionParser.accept Gem::Security::Policy do |value| - require_relative 'security' + require_relative "security" - raise Gem::OptionParser::InvalidArgument, 'OpenSSL not installed' unless + raise Gem::OptionParser::InvalidArgument, "OpenSSL not installed" unless defined?(Gem::Security::HighSecurity) policy = Gem::Security::Policies[value] @@ -33,9 +33,9 @@ module Gem::SecurityOption policy end - add_option(:"Install/Update", '-P', '--trust-policy POLICY', + add_option(:"Install/Update", "-P", "--trust-policy POLICY", Gem::Security::Policy, - 'Specify gem trust policy') do |value, options| + "Specify gem trust policy") do |value, options| options[:security_policy] = value end end diff --git a/lib/rubygems/source.rb b/lib/rubygems/source.rb index 5f49a0d216..7c3b678645 100644 --- a/lib/rubygems/source.rb +++ b/lib/rubygems/source.rb @@ -12,9 +12,9 @@ class Gem::Source include Gem::Text FILES = { # :nodoc: - :released => 'specs', - :latest => 'latest_specs', - :prerelease => 'prerelease_specs', + :released => "specs", + :latest => "latest_specs", + :prerelease => "prerelease_specs", }.freeze ## @@ -71,7 +71,7 @@ class Gem::Source # Returns a Set that can fetch specifications from this source. def dependency_resolver_set # :nodoc: - return Gem::Resolver::IndexSet.new self if 'file' == uri.scheme + return Gem::Resolver::IndexSet.new self if "file" == uri.scheme fetch_uri = if uri.host == "rubygems.org" index_uri = uri.dup @@ -141,7 +141,7 @@ class Gem::Source return spec if spec end - source_uri.path << '.rz' + source_uri.path << ".rz" spec = fetcher.fetch_path source_uri spec = Gem::Util.inflate spec @@ -150,7 +150,7 @@ class Gem::Source require "fileutils" FileUtils.mkdir_p cache_dir - File.open local_spec, 'wb' do |io| + File.open local_spec, "wb" do |io| io.write spec end end @@ -209,13 +209,13 @@ class Gem::Source end def pretty_print(q) # :nodoc: - q.group 2, '[Remote:', ']' do + q.group 2, "[Remote:", "]" do q.breakable q.text @uri.to_s if api = uri q.breakable - q.text 'API URI: ' + q.text "API URI: " q.text api.to_s end end @@ -229,13 +229,13 @@ class Gem::Source private def enforce_trailing_slash(uri) - uri.merge(uri.path.gsub(/\/+$/, '') + '/') + uri.merge(uri.path.gsub(/\/+$/, "") + "/") end end -require_relative 'source/git' -require_relative 'source/installed' -require_relative 'source/specific_file' -require_relative 'source/local' -require_relative 'source/lock' -require_relative 'source/vendor' +require_relative "source/git" +require_relative "source/installed" +require_relative "source/specific_file" +require_relative "source/local" +require_relative "source/lock" +require_relative "source/vendor" diff --git a/lib/rubygems/source/git.rb b/lib/rubygems/source/git.rb index 1d964eb59a..22355adcfa 100644 --- a/lib/rubygems/source/git.rb +++ b/lib/rubygems/source/git.rb @@ -58,7 +58,7 @@ class Gem::Source::Git < Gem::Source @remote = true @root_dir = Gem.dir - @git = ENV['git'] || 'git' + @git = ENV["git"] || "git" end def <=>(other) @@ -92,18 +92,18 @@ class Gem::Source::Git < Gem::Source return false unless File.exist? repo_cache_dir unless File.exist? install_dir - system @git, 'clone', '--quiet', '--no-checkout', + system @git, "clone", "--quiet", "--no-checkout", repo_cache_dir, install_dir end Dir.chdir install_dir do - system @git, 'fetch', '--quiet', '--force', '--tags', install_dir + system @git, "fetch", "--quiet", "--force", "--tags", install_dir - success = system @git, 'reset', '--quiet', '--hard', rev_parse + success = system @git, "reset", "--quiet", "--hard", rev_parse if @need_submodules require "open3" - _, status = Open3.capture2e(@git, 'submodule', 'update', '--quiet', '--init', '--recursive') + _, status = Open3.capture2e(@git, "submodule", "update", "--quiet", "--init", "--recursive") success &&= status.success? end @@ -120,11 +120,11 @@ class Gem::Source::Git < Gem::Source if File.exist? repo_cache_dir Dir.chdir repo_cache_dir do - system @git, 'fetch', '--quiet', '--force', '--tags', - @repository, 'refs/heads/*:refs/heads/*' + system @git, "fetch", "--quiet", "--force", "--tags", + @repository, "refs/heads/*:refs/heads/*" end else - system @git, 'clone', '--quiet', '--bare', '--no-hardlinks', + system @git, "clone", "--quiet", "--bare", "--no-hardlinks", @repository, repo_cache_dir end end @@ -133,7 +133,7 @@ class Gem::Source::Git < Gem::Source # Directory where git gems get unpacked and so-forth. def base_dir # :nodoc: - File.join @root_dir, 'bundler' + File.join @root_dir, "bundler" end ## @@ -155,11 +155,11 @@ class Gem::Source::Git < Gem::Source def install_dir # :nodoc: return unless File.exist? repo_cache_dir - File.join base_dir, 'gems', "#{@name}-#{dir_shortref}" + File.join base_dir, "gems", "#{@name}-#{dir_shortref}" end def pretty_print(q) # :nodoc: - q.group 2, '[Git: ', ']' do + q.group 2, "[Git: ", "]" do q.breakable q.text @repository @@ -172,7 +172,7 @@ class Gem::Source::Git < Gem::Source # The directory where the git gem's repository will be cached. def repo_cache_dir # :nodoc: - File.join @root_dir, 'cache', 'bundler', 'git', "#{@name}-#{uri_hash}" + File.join @root_dir, "cache", "bundler", "git", "#{@name}-#{uri_hash}" end ## @@ -182,7 +182,7 @@ class Gem::Source::Git < Gem::Source hash = nil Dir.chdir repo_cache_dir do - hash = Gem::Util.popen(@git, 'rev-parse', @reference).strip + hash = Gem::Util.popen(@git, "rev-parse", @reference).strip end raise Gem::Exception, @@ -201,7 +201,7 @@ class Gem::Source::Git < Gem::Source return [] unless install_dir Dir.chdir install_dir do - Dir['{,*,*/*}.gemspec'].map do |spec_file| + Dir["{,*,*/*}.gemspec"].map do |spec_file| directory = File.dirname spec_file file = File.basename spec_file @@ -211,7 +211,7 @@ class Gem::Source::Git < Gem::Source spec.base_dir = base_dir spec.extension_dir = - File.join base_dir, 'extensions', Gem::Platform.local.to_s, + File.join base_dir, "extensions", Gem::Platform.local.to_s, Gem.extension_api_version, "#{name}-#{dir_shortref}" spec.full_gem_path = File.dirname spec.loaded_from if spec @@ -226,11 +226,11 @@ class Gem::Source::Git < Gem::Source # A hash for the git gem based on the git repository URI. def uri_hash # :nodoc: - require_relative '../openssl' + require_relative "../openssl" normalized = if @repository =~ %r{^\w+://(\w+@)?} - uri = URI(@repository).normalize.to_s.sub %r{/$},'' + uri = URI(@repository).normalize.to_s.sub %r{/$},"" uri.sub(/\A(\w+)/) { $1.downcase } else @repository diff --git a/lib/rubygems/source/installed.rb b/lib/rubygems/source/installed.rb index 7e1dd7af5a..786faab3e3 100644 --- a/lib/rubygems/source/installed.rb +++ b/lib/rubygems/source/installed.rb @@ -33,6 +33,6 @@ class Gem::Source::Installed < Gem::Source end def pretty_print(q) # :nodoc: - q.text '[Installed]' + q.text "[Installed]" end end diff --git a/lib/rubygems/source/local.rb b/lib/rubygems/source/local.rb index 078b06203f..ec1a594238 100644 --- a/lib/rubygems/source/local.rb +++ b/lib/rubygems/source/local.rb @@ -29,7 +29,7 @@ class Gem::Source::Local < Gem::Source end def inspect # :nodoc: - keys = @specs ? @specs.keys.sort : 'NOT LOADED' + keys = @specs ? @specs.keys.sort : "NOT LOADED" "#<%s specs: %p>" % [self.class, keys] end @@ -121,7 +121,7 @@ class Gem::Source::Local < Gem::Source end def pretty_print(q) # :nodoc: - q.group 2, '[Local gems:', ']' do + q.group 2, "[Local gems:", "]" do q.breakable q.seplist @specs.keys do |v| q.text v.full_name diff --git a/lib/rubygems/source/specific_file.rb b/lib/rubygems/source/specific_file.rb index 24db1440dd..552aeba50f 100644 --- a/lib/rubygems/source/specific_file.rb +++ b/lib/rubygems/source/specific_file.rb @@ -42,7 +42,7 @@ class Gem::Source::SpecificFile < Gem::Source end def pretty_print(q) # :nodoc: - q.group 2, '[SpecificFile:', ']' do + q.group 2, "[SpecificFile:", "]" do q.breakable q.text @path end diff --git a/lib/rubygems/spec_fetcher.rb b/lib/rubygems/spec_fetcher.rb index 4033e2efa3..43e7e05b63 100644 --- a/lib/rubygems/spec_fetcher.rb +++ b/lib/rubygems/spec_fetcher.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -require_relative 'remote_fetcher' -require_relative 'user_interaction' -require_relative 'errors' -require_relative 'text' -require_relative 'name_tuple' +require_relative "remote_fetcher" +require_relative "user_interaction" +require_relative "errors" +require_relative "text" +require_relative "name_tuple" ## # SpecFetcher handles metadata updates from remote gem repositories. @@ -171,19 +171,19 @@ class Gem::SpecFetcher # alternative gem names. def suggest_gems_from_name(gem_name, type = :latest, num_results = 5) - gem_name = gem_name.downcase.tr('_-', '') + gem_name = gem_name.downcase.tr("_-", "") max = gem_name.size / 2 names = available_specs(type).first.values.flatten(1) matches = names.map do |n| next unless n.match_platform? - [n.name, 0] if n.name.downcase.tr('_-', '').include?(gem_name) + [n.name, 0] if n.name.downcase.tr("_-", "").include?(gem_name) end.compact if matches.length < num_results matches += names.map do |n| next unless n.match_platform? - distance = levenshtein_distance gem_name, n.name.downcase.tr('_-', '') + distance = levenshtein_distance gem_name, n.name.downcase.tr("_-", "") next if distance >= max return [n.name] if distance == 0 [n.name, distance] diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb index a8e52e58d5..f2e2740026 100644 --- a/lib/rubygems/specification.rb +++ b/lib/rubygems/specification.rb @@ -6,11 +6,11 @@ # See LICENSE.txt for permissions. #++ -require_relative 'deprecate' -require_relative 'basic_specification' -require_relative 'stub_specification' -require_relative 'platform' -require_relative 'util/list' +require_relative "deprecate" +require_relative "basic_specification" +require_relative "stub_specification" +require_relative "platform" +require_relative "util/list" ## # The Specification class contains the information for a gem. Typically @@ -74,20 +74,20 @@ class Gem::Specification < Gem::BasicSpecification # key should be equal to the CURRENT_SPECIFICATION_VERSION. SPECIFICATION_VERSION_HISTORY = { # :nodoc: - -1 => ['(RubyGems versions up to and including 0.7 did not have versioned specifications)'], + -1 => ["(RubyGems versions up to and including 0.7 did not have versioned specifications)"], 1 => [ 'Deprecated "test_suite_file" in favor of the new, but equivalent, "test_files"', '"test_file=x" is a shortcut for "test_files=[x]"', ], 2 => [ 'Added "required_rubygems_version"', - 'Now forward-compatible with future versions', + "Now forward-compatible with future versions", ], 3 => [ - 'Added Fixnum validation to the specification_version', + "Added Fixnum validation to the specification_version", ], 4 => [ - 'Added sandboxed freeform metadata to the specification version.', + "Added sandboxed freeform metadata to the specification version.", ], }.freeze @@ -126,7 +126,7 @@ class Gem::Specification < Gem::BasicSpecification @@default_value = { :authors => [], :autorequire => nil, - :bindir => 'bin', + :bindir => "bin", :cert_chain => [], :date => nil, :dependencies => [], @@ -143,7 +143,7 @@ class Gem::Specification < Gem::BasicSpecification :platform => Gem::Platform::RUBY, :post_install_message => nil, :rdoc_options => [], - :require_paths => ['lib'], + :require_paths => ["lib"], :required_ruby_version => Gem::Requirement.default, :required_rubygems_version => Gem::Requirement.default, :requirements => [], @@ -489,12 +489,12 @@ class Gem::Specification < Gem::BasicSpecification # legacy constants when nil, Gem::Platform::RUBY then @new_platform = Gem::Platform::RUBY - when 'mswin32' then # was Gem::Platform::WIN32 - @new_platform = Gem::Platform.new 'x86-mswin32' - when 'i586-linux' then # was Gem::Platform::LINUX_586 - @new_platform = Gem::Platform.new 'x86-linux' - when 'powerpc-darwin' then # was Gem::Platform::DARWIN - @new_platform = Gem::Platform.new 'ppc-darwin' + when "mswin32" then # was Gem::Platform::WIN32 + @new_platform = Gem::Platform.new "x86-mswin32" + when "i586-linux" then # was Gem::Platform::LINUX_586 + @new_platform = Gem::Platform.new "x86-linux" + when "powerpc-darwin" then # was Gem::Platform::DARWIN + @new_platform = Gem::Platform.new "ppc-darwin" else @new_platform = Gem::Platform.new platform end @@ -1149,7 +1149,7 @@ class Gem::Specification < Gem::BasicSpecification file = file.dup.tap(&Gem::UNTAINT) return unless File.file?(file) - code = Gem.open_file(file, 'r:UTF-8:-', &:read) + code = Gem.open_file(file, "r:UTF-8:-", &:read) code.tap(&Gem::UNTAINT) @@ -1390,7 +1390,7 @@ class Gem::Specification < Gem::BasicSpecification @required_rubygems_version, @original_platform, @dependencies, - '', # rubyforge_project + "", # rubyforge_project @email, @authors, @description, @@ -1608,7 +1608,7 @@ class Gem::Specification < Gem::BasicSpecification return if default_gem? return if File.exist? gem_build_complete_path return if !File.writable?(base_dir) - return if !File.exist?(File.join(base_dir, 'extensions')) + return if !File.exist?(File.join(base_dir, "extensions")) begin # We need to require things in $LOAD_PATH without looking for the @@ -1616,9 +1616,9 @@ class Gem::Specification < Gem::BasicSpecification unresolved_deps = Gem::Specification.unresolved_deps.dup Gem::Specification.unresolved_deps.clear - require_relative 'config_file' - require_relative 'ext' - require_relative 'user_interaction' + require_relative "config_file" + require_relative "ext" + require_relative "user_interaction" ui = Gem::SilentUI.new Gem::DefaultUserInteraction.use_ui ui do @@ -1837,7 +1837,7 @@ class Gem::Specification < Gem::BasicSpecification # spec.doc_dir 'ri' # => "/path/to/gem_repo/doc/a-1/ri" def doc_dir(type = nil) - @doc_dir ||= File.join base_dir, 'doc', full_name + @doc_dir ||= File.join base_dir, "doc", full_name if type File.join @doc_dir, type @@ -1849,17 +1849,17 @@ class Gem::Specification < Gem::BasicSpecification def encode_with(coder) # :nodoc: mark_version - coder.add 'name', @name - coder.add 'version', @version + coder.add "name", @name + coder.add "version", @version platform = case @original_platform - when nil, '' then - 'ruby' + when nil, "" then + "ruby" when String then @original_platform else @original_platform.to_s end - coder.add 'platform', platform + coder.add "platform", platform attributes = @@attributes.map(&:to_s) - %w[name version platform] attributes.each do |name| @@ -2229,7 +2229,7 @@ class Gem::Specification < Gem::BasicSpecification end def pretty_print(q) # :nodoc: - q.group 2, 'Gem::Specification.new do |s|', 'end' do + q.group 2, "Gem::Specification.new do |s|", "end" do q.breakable attributes = @@attributes - [:name, :version] @@ -2324,7 +2324,7 @@ class Gem::Specification < Gem::BasicSpecification # Returns the full path to this spec's ri directory. def ri_dir - @ri_dir ||= File.join base_dir, 'ri', full_name + @ri_dir ||= File.join base_dir, "ri", full_name end ## @@ -2334,13 +2334,13 @@ class Gem::Specification < Gem::BasicSpecification def ruby_code(obj) case obj when String then obj.dump + ".freeze" - when Array then '[' + obj.map {|x| ruby_code x }.join(", ") + ']' + when Array then "[" + obj.map {|x| ruby_code x }.join(", ") + "]" when Hash then seg = obj.keys.sort.map {|k| "#{k.to_s.dump} => #{obj[k].to_s.dump}" } "{ #{seg.join(', ')} }" when Gem::Version then obj.to_s.dump - when DateLike then obj.strftime('%Y-%m-%d').dump - when Time then obj.strftime('%Y-%m-%d').dump + when DateLike then obj.strftime("%Y-%m-%d").dump + when Time then obj.strftime("%Y-%m-%d").dump when Numeric then obj.inspect when true, false, nil then obj.inspect when Gem::Platform then "Gem::Platform.new(#{obj.to_a.inspect})" @@ -2562,14 +2562,14 @@ class Gem::Specification < Gem::BasicSpecification # back, we have to check again here to make sure that our # psych code was properly loaded, and load it if not. unless Gem.const_defined?(:NoAliasYAMLTree) - require_relative 'psych_tree' + require_relative "psych_tree" end builder = Gem::NoAliasYAMLTree.create builder << self ast = builder.tree - require 'stringio' + require "stringio" io = StringIO.new io.set_encoding Encoding::UTF_8 @@ -2656,7 +2656,7 @@ class Gem::Specification < Gem::BasicSpecification # skip to set required_ruby_version when pre-released rubygems. # It caused to raise CircularDependencyError if @version.prerelease? && (@name.nil? || @name.strip != "rubygems") - self.required_rubygems_version = '> 1.3.1' + self.required_rubygems_version = "> 1.3.1" end invalidate_memoized_attributes diff --git a/lib/rubygems/specification_policy.rb b/lib/rubygems/specification_policy.rb index 8b5d01dda2..332189ae9f 100644 --- a/lib/rubygems/specification_policy.rb +++ b/lib/rubygems/specification_policy.rb @@ -1,4 +1,4 @@ -require_relative 'user_interaction' +require_relative "user_interaction" class Gem::SpecificationPolicy include Gem::UserInteraction @@ -120,7 +120,7 @@ class Gem::SpecificationPolicy metadata = @specification.metadata unless Hash === metadata - error 'metadata must be a hash' + error "metadata must be a hash" end metadata.each do |key, value| @@ -188,7 +188,7 @@ duplicate dependency on #{dep}, (#{prev.requirement}) use: prerelease_dep && [email protected]? open_ended = dep.requirement.requirements.all? do |op, version| - not version.prerelease? and (op == '>' or op == '>=') + not version.prerelease? and (op == ">" or op == ">=") end if open_ended @@ -198,12 +198,12 @@ duplicate dependency on #{dep}, (#{prev.requirement}) use: base = segments.first 2 - recommendation = if (op == '>' || op == '>=') && segments == [0] + recommendation = if (op == ">" || op == ">=") && segments == [0] " use a bounded requirement, such as '~> x.y'" else - bugfix = if op == '>' + bugfix = if op == ">" ", '> #{dep_version}'" - elsif op == '>=' and base != segments + elsif op == ">=" and base != segments ", '>= #{dep_version}'" end @@ -286,7 +286,7 @@ duplicate dependency on #{dep}, (#{prev.requirement}) use: def validate_require_paths return unless @specification.raw_require_paths.empty? - error 'specification must have at least one require_path' + error "specification must have at least one require_path" end def validate_non_files @@ -310,7 +310,7 @@ duplicate dependency on #{dep}, (#{prev.requirement}) use: def validate_specification_version return if @specification.specification_version.is_a?(Integer) - error 'specification_version must be an Integer (did you mean version?)' + error "specification_version must be an Integer (did you mean version?)" end def validate_platform @@ -380,7 +380,7 @@ http://spdx.org/licenses or '#{Gem::Licenses::NONSTANDARD}' for a nonstandard li WARNING end - LAZY = '"FIxxxXME" or "TOxxxDO"'.gsub(/xxx/, '') + LAZY = '"FIxxxXME" or "TOxxxDO"'.gsub(/xxx/, "") LAZY_PATTERN = /\AFI XME|\ATO DO/x.freeze HOMEPAGE_URI_PATTERN = /\A[a-z][a-z\d+.-]*:/i.freeze @@ -405,7 +405,7 @@ http://spdx.org/licenses or '#{Gem::Licenses::NONSTANDARD}' for a nonstandard li # Make sure a homepage is valid HTTP/HTTPS URI if homepage and not homepage.empty? - require 'uri' + require "uri" begin homepage_uri = URI.parse(homepage) unless [URI::HTTP, URI::HTTPS].member? homepage_uri.class @@ -445,7 +445,7 @@ http://spdx.org/licenses or '#{Gem::Licenses::NONSTANDARD}' for a nonstandard li def validate_shebang_line_in(executable) executable_path = File.join(@specification.bindir, executable) - return if File.read(executable_path, 2) == '#!' + return if File.read(executable_path, 2) == "#!" warning "#{executable_path} is missing #! line" end @@ -457,11 +457,11 @@ http://spdx.org/licenses or '#{Gem::Licenses::NONSTANDARD}' for a nonstandard li end def validate_extensions # :nodoc: - require_relative 'ext' + require_relative "ext" builder = Gem::Ext::Builder.new(@specification) rake_extension = @specification.extensions.any? {|s| builder.builder_for(s) == Gem::Ext::RakeBuilder } - rake_dependency = @specification.dependencies.any? {|d| d.name == 'rake' } + rake_dependency = @specification.dependencies.any? {|d| d.name == "rake" } warning <<-WARNING if rake_extension && !rake_dependency You have specified rake based extension, but rake is not added as dependency. It is recommended to add rake as a dependency in gemspec since there's no guarantee rake will be already installed. diff --git a/lib/rubygems/stub_specification.rb b/lib/rubygems/stub_specification.rb index b1dd7397ae..33b4f45b0a 100644 --- a/lib/rubygems/stub_specification.rb +++ b/lib/rubygems/stub_specification.rb @@ -9,7 +9,7 @@ class Gem::StubSpecification < Gem::BasicSpecification PREFIX = "# stub: ".freeze # :nodoc: - OPEN_MODE = 'r:UTF-8:-'.freeze + OPEN_MODE = "r:UTF-8:-".freeze class StubLine # :nodoc: all attr_reader :name, :version, :platform, :require_paths, :extensions, @@ -19,9 +19,9 @@ class Gem::StubSpecification < Gem::BasicSpecification # These are common require paths. REQUIRE_PATHS = { # :nodoc: - 'lib' => 'lib'.freeze, - 'test' => 'test'.freeze, - 'ext' => 'ext'.freeze, + "lib" => "lib".freeze, + "test" => "test".freeze, + "ext" => "ext".freeze, }.freeze # These are common require path lists. This hash is used to optimize @@ -29,7 +29,7 @@ class Gem::StubSpecification < Gem::BasicSpecification # in their require paths, so lets take advantage of that by pre-allocating # a require path list for that case. REQUIRE_PATH_LIST = { # :nodoc: - 'lib' => ['lib'].freeze, + "lib" => ["lib"].freeze, }.freeze def initialize(data, extensions) diff --git a/lib/rubygems/tsort.rb b/lib/rubygems/tsort.rb index ebe7c3364b..60ebe22e81 100644 --- a/lib/rubygems/tsort.rb +++ b/lib/rubygems/tsort.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -require_relative 'tsort/lib/tsort' +require_relative "tsort/lib/tsort" diff --git a/lib/rubygems/uninstaller.rb b/lib/rubygems/uninstaller.rb index a36c5cbe2b..1ae301a44d 100644 --- a/lib/rubygems/uninstaller.rb +++ b/lib/rubygems/uninstaller.rb @@ -5,12 +5,12 @@ # See LICENSE.txt for permissions. #++ -require 'fileutils' -require_relative '../rubygems' -require_relative 'installer_uninstaller_utils' -require_relative 'dependency_list' -require_relative 'rdoc' -require_relative 'user_interaction' +require "fileutils" +require_relative "../rubygems" +require_relative "installer_uninstaller_utils" +require_relative "dependency_list" +require_relative "rdoc" +require_relative "user_interaction" ## # An Uninstaller. @@ -302,8 +302,8 @@ class Gem::Uninstaller # Is +spec+ in +gem_dir+? def path_ok?(gem_dir, spec) - full_path = File.join gem_dir, 'gems', spec.full_name - original_path = File.join gem_dir, 'gems', spec.original_name + full_path = File.join gem_dir, "gems", spec.full_name + original_path = File.join gem_dir, "gems", spec.original_name full_path == spec.full_gem_path || original_path == spec.full_gem_path end @@ -332,10 +332,10 @@ class Gem::Uninstaller # Asks if it is OK to remove +spec+. Returns true if it is OK. def ask_if_ok(spec) # :nodoc: - msg = [''] - msg << 'You have requested to uninstall the gem:' + msg = [""] + msg << "You have requested to uninstall the gem:" msg << "\t#{spec.full_name}" - msg << '' + msg << "" siblings = Gem::Specification.select do |s| s.name == spec.name && s.full_name != spec.full_name @@ -347,8 +347,8 @@ class Gem::Uninstaller end end - msg << 'If you remove this gem, these dependencies will not be met.' - msg << 'Continue with Uninstall?' + msg << "If you remove this gem, these dependencies will not be met." + msg << "Continue with Uninstall?" return ask_yes_no(msg.join("\n"), false) end @@ -360,7 +360,7 @@ class Gem::Uninstaller # of what it did for us to find rather than trying to recreate # it again. if @format_executable - require_relative 'installer' + require_relative "installer" Gem::Installer.exec_format % File.basename(filename) else filename diff --git a/lib/rubygems/uri.rb b/lib/rubygems/uri.rb index 6acb9041f9..4b5d035aa0 100644 --- a/lib/rubygems/uri.rb +++ b/lib/rubygems/uri.rb @@ -66,7 +66,7 @@ class Gem::Uri def redact_credentials_from(text) return text unless valid_uri? && password? && text.include?(to_s) - text.sub(password, 'REDACTED') + text.sub(password, "REDACTED") end def method_missing(method_name, *args, &blk) @@ -97,11 +97,11 @@ class Gem::Uri end def with_redacted_user - clone.tap {|uri| uri.user = 'REDACTED' } + clone.tap {|uri| uri.user = "REDACTED" } end def with_redacted_password - clone.tap {|uri| uri.password = 'REDACTED' } + clone.tap {|uri| uri.password = "REDACTED" } end def valid_uri? @@ -113,7 +113,7 @@ class Gem::Uri end def oauth_basic? - password == 'x-oauth-basic' + password == "x-oauth-basic" end def token? diff --git a/lib/rubygems/uri_formatter.rb b/lib/rubygems/uri_formatter.rb index 3bda896875..3f1d02d774 100644 --- a/lib/rubygems/uri_formatter.rb +++ b/lib/rubygems/uri_formatter.rb @@ -17,7 +17,7 @@ class Gem::UriFormatter # Creates a new URI formatter for +uri+. def initialize(uri) - require 'cgi' + require "cgi" @uri = uri end diff --git a/lib/rubygems/user_interaction.rb b/lib/rubygems/user_interaction.rb index c726fd21c1..4b0a7c60bb 100644 --- a/lib/rubygems/user_interaction.rb +++ b/lib/rubygems/user_interaction.rb @@ -5,8 +5,8 @@ # See LICENSE.txt for permissions. #++ -require_relative 'deprecate' -require_relative 'text' +require_relative "deprecate" +require_relative "text" ## # Module that defines the default UserInteraction. Any class including this @@ -148,7 +148,7 @@ module Gem::UserInteraction ## # Displays the given +statement+ on the standard output (or equivalent). - def say(statement = '') + def say(statement = "") ui.say statement end @@ -259,11 +259,11 @@ class Gem::StreamUI default_answer = case default when nil - 'yn' + "yn" when true - 'Yn' + "Yn" else - 'yN' + "yN" end result = nil @@ -312,7 +312,7 @@ class Gem::StreamUI def require_io_console @require_io_console ||= begin begin - require 'io/console' + require "io/console" rescue LoadError end true @@ -472,7 +472,7 @@ class Gem::StreamUI # and the +terminal_message+ when it is complete. def initialize(out_stream, size, initial_message, - terminal_message = 'complete') + terminal_message = "complete") @out = out_stream @total = size @count = 0 diff --git a/lib/rubygems/util.rb b/lib/rubygems/util.rb index 9fd78ab2bc..356c46a5a1 100644 --- a/lib/rubygems/util.rb +++ b/lib/rubygems/util.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require_relative 'deprecate' +require_relative "deprecate" ## # This module contains various utility methods as module methods. @@ -10,9 +10,9 @@ module Gem::Util # Zlib::GzipReader wrapper that unzips +data+. def self.gunzip(data) - require 'zlib' - require 'stringio' - data = StringIO.new(data, 'r') + require "zlib" + require "stringio" + data = StringIO.new(data, "r") gzip_reader = begin Zlib::GzipReader.new(data) @@ -29,9 +29,9 @@ module Gem::Util # Zlib::GzipWriter wrapper that zips +data+. def self.gzip(data) - require 'zlib' - require 'stringio' - zipped = StringIO.new(String.new, 'w') + require "zlib" + require "stringio" + zipped = StringIO.new(String.new, "w") zipped.set_encoding Encoding::BINARY Zlib::GzipWriter.wrap zipped do |io| @@ -45,7 +45,7 @@ module Gem::Util # A Zlib::Inflate#inflate wrapper def self.inflate(data) - require 'zlib' + require "zlib" Zlib::Inflate.inflate data end @@ -86,7 +86,7 @@ module Gem::Util loop do Dir.chdir here, &block rescue Errno::EACCES - new_here = File.expand_path('..', here) + new_here = File.expand_path("..", here) return if new_here == here # toplevel here = new_here end @@ -109,7 +109,7 @@ module Gem::Util # comes with a leading slash. def self.correct_for_windows_path(path) - if path[0].chr == '/' && path[1].chr =~ /[a-z]/i && path[2].chr == ':' + if path[0].chr == "/" && path[1].chr =~ /[a-z]/i && path[2].chr == ":" path[1..-1] else path diff --git a/lib/rubygems/util/licenses.rb b/lib/rubygems/util/licenses.rb index 3f4178c6e0..96f47781c0 100644 --- a/lib/rubygems/util/licenses.rb +++ b/lib/rubygems/util/licenses.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require_relative '../text' +require_relative "../text" class Gem::Licenses extend Gem::Text - NONSTANDARD = 'Nonstandard'.freeze - LICENSE_REF = 'LicenseRef-.+'.freeze + NONSTANDARD = "Nonstandard".freeze + LICENSE_REF = "LicenseRef-.+".freeze # Software Package Data Exchange (SPDX) standard open-source software # license identifiers diff --git a/lib/rubygems/validator.rb b/lib/rubygems/validator.rb index 728595e778..60104a34d5 100644 --- a/lib/rubygems/validator.rb +++ b/lib/rubygems/validator.rb @@ -5,8 +5,8 @@ # See LICENSE.txt for permissions. #++ -require_relative 'package' -require_relative 'installer' +require_relative "package" +require_relative "installer" ## # Validator performs various gem file and gem database validation @@ -15,7 +15,7 @@ class Gem::Validator include Gem::UserInteraction def initialize # :nodoc: - require 'find' + require "find" end private @@ -110,11 +110,11 @@ class Gem::Validator begin next unless data # HACK `gem check -a mkrf` - source = File.join gem_directory, entry['path'] + source = File.join gem_directory, entry["path"] File.open source, Gem.binary_mode do |f| unless f.read == data - errors[gem_name][entry['path']] = "Modified from original" + errors[gem_name][entry["path"]] = "Modified from original" end end end diff --git a/lib/rubygems/version.rb b/lib/rubygems/version.rb index c57bf7d6d5..03ae5ca17e 100644 --- a/lib/rubygems/version.rb +++ b/lib/rubygems/version.rb @@ -276,7 +276,7 @@ class Gem::Version end def yaml_initialize(tag, map) # :nodoc: - @version = map['version'] + @version = map["version"] @segments = nil @hash = nil end @@ -286,7 +286,7 @@ class Gem::Version end def encode_with(coder) # :nodoc: - coder.add 'version', @version + coder.add "version", @version end ## @@ -311,7 +311,7 @@ class Gem::Version @@release[self] ||= if prerelease? segments = self.segments segments.pop while segments.any? {|s| String === s } - self.class.new segments.join('.') + self.class.new segments.join(".") else self end diff --git a/lib/rubygems/version_option.rb b/lib/rubygems/version_option.rb index 1db382fa7f..a487a0bc24 100644 --- a/lib/rubygems/version_option.rb +++ b/lib/rubygems/version_option.rb @@ -5,7 +5,7 @@ # See LICENSE.txt for permissions. #++ -require_relative '../rubygems' +require_relative "../rubygems" ## # Mixin methods for --version and --platform Gem::Command options. @@ -24,7 +24,7 @@ module Gem::VersionOption end end - add_option('--platform PLATFORM', Gem::Platform, + add_option("--platform PLATFORM", Gem::Platform, "Specify the platform of gem to #{task}", *wrap) do |value, options| unless options[:added_platform] @@ -55,7 +55,7 @@ module Gem::VersionOption Gem::Requirement.new(*value.split(/\s*,\s*/)) end - add_option('-v', '--version VERSION', Gem::Requirement, + add_option("-v", "--version VERSION", Gem::Requirement, "Specify version of gem to #{task}", *wrap) do |value, options| # Allow handling for multiple --version operators |