summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-10-22 00:27:02 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-10-22 00:27:02 +0000
commit615ac3593499f54fde4b1eb0fba66b6bd944821b (patch)
tree1f0b0e97ee3dd51798658d53cee7eec976a83a97 /lib
parentff31b35f6a66f3c1548e3356d506ff65a574be7f (diff)
Merge rubygems master branch from github.com/rubygems/rubygems.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65294 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/rubygems.rb12
-rw-r--r--lib/rubygems/bundler_version_finder.rb6
-rw-r--r--lib/rubygems/command.rb2
-rw-r--r--lib/rubygems/command_manager.rb4
-rw-r--r--lib/rubygems/commands/build_command.rb6
-rw-r--r--lib/rubygems/commands/cert_command.rb16
-rw-r--r--lib/rubygems/commands/help_command.rb8
-rw-r--r--lib/rubygems/commands/setup_command.rb6
-rw-r--r--lib/rubygems/commands/uninstall_command.rb2
-rw-r--r--lib/rubygems/commands/update_command.rb6
-rw-r--r--lib/rubygems/compatibility.rb2
-rw-r--r--lib/rubygems/config_file.rb25
-rw-r--r--lib/rubygems/defaults.rb8
-rw-r--r--lib/rubygems/dependency.rb2
-rw-r--r--lib/rubygems/doctor.rb2
-rw-r--r--lib/rubygems/ext/builder.rb15
-rw-r--r--lib/rubygems/ext/ext_conf_builder.rb2
-rw-r--r--lib/rubygems/ext/rake_builder.rb10
-rw-r--r--lib/rubygems/install_update_options.rb24
-rw-r--r--lib/rubygems/installer.rb2
-rw-r--r--lib/rubygems/package.rb19
-rw-r--r--lib/rubygems/package/tar_header.rb2
-rw-r--r--lib/rubygems/platform.rb4
-rw-r--r--lib/rubygems/remote_fetcher.rb30
-rw-r--r--lib/rubygems/request_set/gem_dependency_api.rb8
-rw-r--r--lib/rubygems/requirement.rb6
-rw-r--r--lib/rubygems/resolver/source_set.rb2
-rw-r--r--lib/rubygems/resolver/stats.rb2
-rw-r--r--lib/rubygems/safe_yaml.rb4
-rw-r--r--lib/rubygems/security.rb2
-rw-r--r--lib/rubygems/security/policies.rb2
-rw-r--r--lib/rubygems/security/policy.rb6
-rw-r--r--lib/rubygems/security/signer.rb26
-rw-r--r--lib/rubygems/security/trust_dir.rb2
-rw-r--r--lib/rubygems/server.rb10
-rw-r--r--lib/rubygems/source.rb29
-rw-r--r--lib/rubygems/spec_fetcher.rb6
-rw-r--r--lib/rubygems/specification.rb65
-rw-r--r--lib/rubygems/specification_policy.rb26
-rw-r--r--lib/rubygems/stub_specification.rb8
-rw-r--r--lib/rubygems/test_case.rb2
-rw-r--r--lib/rubygems/test_utilities.rb14
-rw-r--r--lib/rubygems/text.rb2
-rw-r--r--lib/rubygems/uninstaller.rb4
-rw-r--r--lib/rubygems/version.rb2
45 files changed, 212 insertions, 231 deletions
diff --git a/lib/rubygems.rb b/lib/rubygems.rb
index 9716464718..6557256469 100644
--- a/lib/rubygems.rb
+++ b/lib/rubygems.rb
@@ -9,7 +9,7 @@
require 'rbconfig'
module Gem
- VERSION = "3.0.0.beta1"
+ VERSION = "3.0.0.beta1".freeze
end
# Must be first since it unloads the prelude from 1.9.2
@@ -126,14 +126,14 @@ module Gem
/mingw/i,
/mswin/i,
/wince/i,
- ]
+ ].freeze
GEM_DEP_FILES = %w[
gem.deps.rb
gems.rb
Gemfile
Isolate
- ]
+ ].freeze
##
# Subdirectories in a gem repository
@@ -145,7 +145,7 @@ module Gem
extensions
gems
specifications
- ]
+ ].freeze
##
# Subdirectories in a gem repository for default gems
@@ -153,7 +153,7 @@ module Gem
REPOSITORY_DEFAULT_GEM_SUBDIRECTORIES = %w[
gems
specifications/default
- ]
+ ].freeze
##
# Exception classes used in a Gem.read_binary +rescue+ statement. Not all of
@@ -1342,7 +1342,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
##
# Location of Marshal quick gemspecs on remote repositories
- MARSHAL_SPEC_DIR = "quick/Marshal.#{Gem.marshal_version}/"
+ MARSHAL_SPEC_DIR = "quick/Marshal.#{Gem.marshal_version}/".freeze
autoload :BundlerVersionFinder, 'rubygems/bundler_version_finder'
autoload :ConfigFile, 'rubygems/config_file'
diff --git a/lib/rubygems/bundler_version_finder.rb b/lib/rubygems/bundler_version_finder.rb
index 2f448c9562..7babeaa848 100644
--- a/lib/rubygems/bundler_version_finder.rb
+++ b/lib/rubygems/bundler_version_finder.rb
@@ -104,9 +104,9 @@ To install the missing version, run `gem install bundler:#{vr.first}`
return unless gemfile
lockfile = case gemfile
- when "gems.rb" then "gems.locked"
- else "#{gemfile}.lock"
- end.dup.untaint
+ when "gems.rb" then "gems.locked"
+ else "#{gemfile}.lock"
+ end.dup.untaint
return unless File.file?(lockfile)
diff --git a/lib/rubygems/command.rb b/lib/rubygems/command.rb
index 71199c59b4..3fc8a70a3e 100644
--- a/lib/rubygems/command.rb
+++ b/lib/rubygems/command.rb
@@ -570,7 +570,7 @@ class Gem::Command
# :stopdoc:
- HELP = <<-HELP
+ HELP = <<-HELP.freeze
RubyGems is a sophisticated package manager for Ruby. This is a
basic help message containing pointers to more information.
diff --git a/lib/rubygems/command_manager.rb b/lib/rubygems/command_manager.rb
index 3dc5779c91..40ae6191c5 100644
--- a/lib/rubygems/command_manager.rb
+++ b/lib/rubygems/command_manager.rb
@@ -69,11 +69,11 @@ class Gem::CommandManager
:update,
:which,
:yank,
- ]
+ ].freeze
ALIAS_COMMANDS = {
'i' => 'install'
- }
+ }.freeze
##
# Return the authoritative instance of the command manager.
diff --git a/lib/rubygems/commands/build_command.rb b/lib/rubygems/commands/build_command.rb
index f1d700349f..3c778cf705 100644
--- a/lib/rubygems/commands/build_command.rb
+++ b/lib/rubygems/commands/build_command.rb
@@ -55,7 +55,11 @@ with gem spec:
spec = Gem::Specification.load File.basename(gemspec)
if spec then
- Gem::Package.build spec, options[:force], options[:strict]
+ Gem::Package.build(
+ spec,
+ options[:force],
+ options[:strict]
+ )
else
alert_error "Error loading gemspec. Aborting."
terminate_interaction 1
diff --git a/lib/rubygems/commands/cert_command.rb b/lib/rubygems/commands/cert_command.rb
index 3f74508074..e93c39747c 100644
--- a/lib/rubygems/commands/cert_command.rb
+++ b/lib/rubygems/commands/cert_command.rb
@@ -149,15 +149,15 @@ class Gem::Commands::CertCommand < Gem::Command
end
def build_cert email, key # :nodoc:
- expiration_length_days = options[:expiration_length_days]
- age =
- if expiration_length_days.nil? || expiration_length_days == 0
- Gem::Security::ONE_YEAR
- else
- Gem::Security::ONE_DAY * expiration_length_days
- end
+ expiration_length_days = options[:expiration_length_days] ||
+ Gem.configuration.cert_expiration_length_days
+
+ cert = Gem::Security.create_cert_email(
+ email,
+ key,
+ (Gem::Security::ONE_DAY * expiration_length_days)
+ )
- cert = Gem::Security.create_cert_email email, key, age
Gem::Security.write cert, "gem-public_cert.pem"
end
diff --git a/lib/rubygems/commands/help_command.rb b/lib/rubygems/commands/help_command.rb
index 7d02022369..0c96963fac 100644
--- a/lib/rubygems/commands/help_command.rb
+++ b/lib/rubygems/commands/help_command.rb
@@ -4,7 +4,7 @@ require 'rubygems/command'
class Gem::Commands::HelpCommand < Gem::Command
# :stopdoc:
- EXAMPLES = <<-EOF
+ EXAMPLES = <<-EOF.freeze
Some examples of 'gem' usage.
* Install 'rake', either from local directory or remote server:
@@ -53,7 +53,7 @@ Some examples of 'gem' usage.
gem update --system
EOF
- GEM_DEPENDENCIES = <<-EOF
+ GEM_DEPENDENCIES = <<-EOF.freeze
A gem dependencies file allows installation of a consistent set of gems across
multiple environments. The RubyGems implementation is designed to be
compatible with Bundler's Gemfile format. You can see additional
@@ -230,7 +230,7 @@ default. This may be overridden with the :development_group option:
EOF
- PLATFORMS = <<-'EOF'
+ PLATFORMS = <<-'EOF'.freeze
RubyGems platforms are composed of three parts, a CPU, an OS, and a
version. These values are taken from values in rbconfig.rb. You can view
your current platform by running `gem environment`.
@@ -277,7 +277,7 @@ platform.
["examples", EXAMPLES],
["gem_dependencies", GEM_DEPENDENCIES],
["platforms", PLATFORMS],
- ]
+ ].freeze
# :startdoc:
def initialize
diff --git a/lib/rubygems/commands/setup_command.rb b/lib/rubygems/commands/setup_command.rb
index 281108ea1f..37abe3b2ec 100644
--- a/lib/rubygems/commands/setup_command.rb
+++ b/lib/rubygems/commands/setup_command.rb
@@ -9,7 +9,7 @@ class Gem::Commands::SetupCommand < Gem::Command
HISTORY_HEADER = /^===\s*[\d.a-zA-Z]+\s*\/\s*\d{4}-\d{2}-\d{2}\s*$/
VERSION_MATCHER = /^===\s*([\d.a-zA-Z]+)\s*\/\s*\d{4}-\d{2}-\d{2}\s*$/
- ENV_PATHS = %w[/usr/bin/env /bin/env]
+ ENV_PATHS = %w[/usr/bin/env /bin/env].freeze
def initialize
require 'tmpdir'
@@ -84,8 +84,8 @@ class Gem::Commands::SetupCommand < Gem::Command
add_option '--[no-]regenerate-binstubs',
'Regenerate gem binstubs' do |value, options|
- options[:regenerate_binstubs] = value
- end
+ options[:regenerate_binstubs] = value
+ end
add_option('-E', '--[no-]env-shebang',
'Rewrite executables with a shebang',
diff --git a/lib/rubygems/commands/uninstall_command.rb b/lib/rubygems/commands/uninstall_command.rb
index 1ddc12c737..d1ffe675fe 100644
--- a/lib/rubygems/commands/uninstall_command.rb
+++ b/lib/rubygems/commands/uninstall_command.rb
@@ -20,7 +20,7 @@ class Gem::Commands::UninstallCommand < Gem::Command
add_option('-a', '--[no-]all',
'Uninstall all matching versions'
- ) do |value, options|
+ ) do |value, options|
options[:all] = value
end
diff --git a/lib/rubygems/commands/update_command.rb b/lib/rubygems/commands/update_command.rb
index 1c86ba6753..dc924265b0 100644
--- a/lib/rubygems/commands/update_command.rb
+++ b/lib/rubygems/commands/update_command.rb
@@ -168,12 +168,8 @@ command to remove old versions.
Dir.chdir update_dir do
say "Installing RubyGems #{version}"
- # Make sure old rubygems isn't loaded
- old = ENV["RUBYOPT"]
- ENV.delete("RUBYOPT") if old
- installed = system Gem.ruby, 'setup.rb', *args
+ installed = system Gem.ruby, '--disable-gems', 'setup.rb', *args
say "RubyGems system software updated" if installed
- ENV["RUBYOPT"] = old if old
end
end
diff --git a/lib/rubygems/compatibility.rb b/lib/rubygems/compatibility.rb
index 24c741e99b..b4332eb9f1 100644
--- a/lib/rubygems/compatibility.rb
+++ b/lib/rubygems/compatibility.rb
@@ -22,7 +22,7 @@ module Gem
EXEEXT RUBY_SO_NAME arch bindir datadir libdir ruby_install_name
ruby_version rubylibprefix sitedir sitelibdir vendordir vendorlibdir
rubylibdir
- ]
+ ].freeze
unless defined?(ConfigMap)
##
diff --git a/lib/rubygems/config_file.rb b/lib/rubygems/config_file.rb
index 9ef1236204..f8782015a1 100644
--- a/lib/rubygems/config_file.rb
+++ b/lib/rubygems/config_file.rb
@@ -45,6 +45,7 @@ class Gem::ConfigFile
DEFAULT_VERBOSITY = true
DEFAULT_UPDATE_SOURCES = true
DEFAULT_CONCURRENT_DOWNLOADS = 8
+ DEFAULT_CERT_EXPIRATION_LENGTH_DAYS = 365
##
# For Ruby packagers to set configuration defaults. Set in
@@ -136,6 +137,11 @@ class Gem::ConfigFile
attr_accessor :sources
##
+ # Expiration length to sign a certificate
+
+ attr_accessor :cert_expiration_length_days
+
+ ##
# Path name of directory or file of openssl client certificate, used for remote https connection with client authentication
attr_reader :ssl_client_cert
@@ -185,6 +191,7 @@ class Gem::ConfigFile
@verbose = DEFAULT_VERBOSITY
@update_sources = DEFAULT_UPDATE_SOURCES
@concurrent_downloads = DEFAULT_CONCURRENT_DOWNLOADS
+ @cert_expiration_length_days = DEFAULT_CERT_EXPIRATION_LENGTH_DAYS
operating_system_config = Marshal.load Marshal.dump(OPERATING_SYSTEM_DEFAULTS)
platform_config = Marshal.load Marshal.dump(PLATFORM_DEFAULTS)
@@ -202,15 +209,15 @@ class Gem::ConfigFile
end
# HACK these override command-line args, which is bad
- @backtrace = @hash[:backtrace] if @hash.key? :backtrace
- @bulk_threshold = @hash[:bulk_threshold] if @hash.key? :bulk_threshold
- @home = @hash[:gemhome] if @hash.key? :gemhome
- @path = @hash[:gempath] if @hash.key? :gempath
- @update_sources = @hash[:update_sources] if @hash.key? :update_sources
- @verbose = @hash[:verbose] if @hash.key? :verbose
- @concurrent_downloads = @hash[:concurrent_downloads] if @hash.key? :concurrent_downloads
- @disable_default_gem_server = @hash[:disable_default_gem_server] if @hash.key? :disable_default_gem_server
- @sources = @hash[:sources] if @hash.key? :sources
+ @backtrace = @hash[:backtrace] if @hash.key? :backtrace
+ @bulk_threshold = @hash[:bulk_threshold] if @hash.key? :bulk_threshold
+ @home = @hash[:gemhome] if @hash.key? :gemhome
+ @path = @hash[:gempath] if @hash.key? :gempath
+ @update_sources = @hash[:update_sources] if @hash.key? :update_sources
+ @verbose = @hash[:verbose] if @hash.key? :verbose
+ @disable_default_gem_server = @hash[:disable_default_gem_server] if @hash.key? :disable_default_gem_server
+ @sources = @hash[:sources] if @hash.key? :sources
+ @cert_expiration_length_days = @hash[:cert_expiration_length_days] if @hash.key? :cert_expiration_length_days
@ssl_verify_mode = @hash[:ssl_verify_mode] if @hash.key? :ssl_verify_mode
@ssl_ca_cert = @hash[:ssl_ca_cert] if @hash.key? :ssl_ca_cert
diff --git a/lib/rubygems/defaults.rb b/lib/rubygems/defaults.rb
index b8222877ae..334ef4d4c1 100644
--- a/lib/rubygems/defaults.rb
+++ b/lib/rubygems/defaults.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
module Gem
- DEFAULT_HOST = "https://rubygems.org"
+ DEFAULT_HOST = "https://rubygems.org".freeze
@post_install_hooks ||= []
@done_installing_hooks ||= []
@@ -36,9 +36,9 @@ module Gem
]
elsif RbConfig::CONFIG['rubylibprefix'] then
[
- RbConfig::CONFIG['rubylibprefix'],
- 'gems',
- RbConfig::CONFIG['ruby_version']
+ RbConfig::CONFIG['rubylibprefix'],
+ 'gems',
+ RbConfig::CONFIG['ruby_version']
]
else
[
diff --git a/lib/rubygems/dependency.rb b/lib/rubygems/dependency.rb
index 3465666790..c06df0fa35 100644
--- a/lib/rubygems/dependency.rb
+++ b/lib/rubygems/dependency.rb
@@ -19,7 +19,7 @@ class Gem::Dependency
TYPES = [
:development,
:runtime,
- ]
+ ].freeze
##
# Dependency name or regular expression.
diff --git a/lib/rubygems/doctor.rb b/lib/rubygems/doctor.rb
index ec4a16c3f8..e5d8c43de8 100644
--- a/lib/rubygems/doctor.rb
+++ b/lib/rubygems/doctor.rb
@@ -26,7 +26,7 @@ class Gem::Doctor
['doc', ''],
['extensions', ''],
['gems', ''],
- ]
+ ].freeze
missing =
Gem::REPOSITORY_SUBDIRECTORIES.sort -
diff --git a/lib/rubygems/ext/builder.rb b/lib/rubygems/ext/builder.rb
index 6382a8f5c7..b3b9033962 100644
--- a/lib/rubygems/ext/builder.rb
+++ b/lib/rubygems/ext/builder.rb
@@ -148,9 +148,21 @@ EOF
def build_extension extension, dest_path # :nodoc:
results = []
+ # FIXME: Determine if this line is necessary and, if so, why.
+ # Notes:
+ # 1. As far as I can tell, this method is only called by +build_extensions+.
+ # 2. The existence of this line implies +extension+ is, or previously was,
+ # sometimes +false+ or +nil+.
+ # 3. #1 and #2 combined suggests, but does not confirm, that
+ # +@specs.extensions+ sometimes contained +false+ or +nil+ values.
+ # 4. Nothing seems to explicitly handle +extension+ being empty,
+ # which makes me wonder both what it should do and what it does.
+ #
+ # - @duckinator
extension ||= '' # I wish I knew why this line existed
+
extension_dir =
- File.expand_path File.join @gem_dir, File.dirname(extension)
+ File.expand_path File.join(@gem_dir, File.dirname(extension))
lib_dir = File.join @spec.full_gem_path, @spec.raw_require_paths.first
builder = builder_for extension
@@ -200,6 +212,7 @@ EOF
FileUtils.rm_f @spec.gem_build_complete_path
+ # FIXME: action at a distance: @ran_rake modified deep in build_extension(). - @duckinator
@ran_rake = false # only run rake once
@spec.extensions.each do |extension|
diff --git a/lib/rubygems/ext/ext_conf_builder.rb b/lib/rubygems/ext/ext_conf_builder.rb
index a17881a890..18e300d8c2 100644
--- a/lib/rubygems/ext/ext_conf_builder.rb
+++ b/lib/rubygems/ext/ext_conf_builder.rb
@@ -38,7 +38,7 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder
destdir = ENV["DESTDIR"]
begin
- cmd = [Gem.ruby, "-r", get_relative_path(siteconf.path), File.basename(extension), *args].join ' '
+ cmd = [Gem.ruby, "-I", File.expand_path("../../..", __FILE__), "-r", get_relative_path(siteconf.path), File.basename(extension), *args].join ' '
begin
run cmd, results
diff --git a/lib/rubygems/ext/rake_builder.rb b/lib/rubygems/ext/rake_builder.rb
index 7a5a48c6cc..890803aaef 100644
--- a/lib/rubygems/ext/rake_builder.rb
+++ b/lib/rubygems/ext/rake_builder.rb
@@ -5,6 +5,8 @@
# See LICENSE.txt for permissions.
#++
+require "shellwords"
+
class Gem::Ext::RakeBuilder < Gem::Ext::Builder
def self.build(extension, dest_path, results, args=[], lib_dir=nil)
@@ -14,9 +16,6 @@ class Gem::Ext::RakeBuilder < Gem::Ext::Builder
run cmd, results
end
- # Deal with possible spaces in the path, e.g. C:/Program Files
- dest_path = '"' + dest_path.to_s + '"' if dest_path.to_s.include?(' ')
-
rake = ENV['rake']
rake ||= begin
@@ -26,9 +25,8 @@ class Gem::Ext::RakeBuilder < Gem::Ext::Builder
rake ||= Gem.default_exec_format % 'rake'
- cmd = "#{rake} RUBYARCHDIR=#{dest_path} RUBYLIBDIR=#{dest_path}" # ENV is frozen
-
- run cmd, results
+ rake_args = ["RUBYARCHDIR=#{dest_path}", "RUBYLIBDIR=#{dest_path}", *args]
+ run "#{rake} #{rake_args.shelljoin}", results
results
end
diff --git a/lib/rubygems/install_update_options.rb b/lib/rubygems/install_update_options.rb
index 75968605f1..824682f9ad 100644
--- a/lib/rubygems/install_update_options.rb
+++ b/lib/rubygems/install_update_options.rb
@@ -63,30 +63,6 @@ module Gem::InstallUpdateOptions
options[:document] = []
end
- add_option(:Deprecated, '--[no-]rdoc',
- 'Generate RDoc for installed gems',
- 'Use --document instead') do |value, options|
- if value then
- options[:document] << 'rdoc'
- else
- options[:document].delete 'rdoc'
- end
-
- options[:document].uniq!
- end
-
- add_option(:Deprecated, '--[no-]ri',
- 'Generate ri data for installed gems.',
- 'Use --document instead') do |value, options|
- if value then
- options[:document] << 'ri'
- else
- options[:document].delete 'ri'
- end
-
- options[:document].uniq!
- end
-
add_option(:"Install/Update", '-E', '--[no-]env-shebang',
"Rewrite the shebang line on installed",
"scripts to use /usr/bin/env") do |value, options|
diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb
index a3bb9b821e..298a7053c7 100644
--- a/lib/rubygems/installer.rb
+++ b/lib/rubygems/installer.rb
@@ -34,7 +34,7 @@ class Gem::Installer
# Paths where env(1) might live. Some systems are broken and have it in
# /bin
- ENV_PATHS = %w[/usr/bin/env /bin/env]
+ ENV_PATHS = %w[/usr/bin/env /bin/env].freeze
##
# Deprecated in favor of Gem::Ext::BuildError
diff --git a/lib/rubygems/package.rb b/lib/rubygems/package.rb
index ec9541d19b..a71c41afc7 100644
--- a/lib/rubygems/package.rb
+++ b/lib/rubygems/package.rb
@@ -119,7 +119,7 @@ class Gem::Package
# Permission for other files
attr_accessor :data_mode
- def self.build spec, skip_validation=false, strict_validation=false
+ def self.build spec, skip_validation = false, strict_validation = false
gem_file = spec.file_name
package = new gem_file
@@ -263,7 +263,11 @@ class Gem::Package
@spec.mark_version
@spec.validate true, strict_validation unless skip_validation
- setup_signer
+ setup_signer(
+ signer_options: {
+ expiration_length_days: Gem.configuration.cert_expiration_length_days
+ }
+ )
@gem.with_write_io do |gem_io|
Gem::Package::TarWriter.new gem_io do |gem|
@@ -521,10 +525,17 @@ EOM
# Prepares the gem for signing and checksum generation. If a signing
# certificate and key are not present only checksum generation is set up.
- def setup_signer
+ def setup_signer(signer_options: {})
passphrase = ENV['GEM_PRIVATE_KEY_PASSPHRASE']
if @spec.signing_key then
- @signer = Gem::Security::Signer.new @spec.signing_key, @spec.cert_chain, passphrase
+ @signer =
+ Gem::Security::Signer.new(
+ @spec.signing_key,
+ @spec.cert_chain,
+ passphrase,
+ signer_options
+ )
+
@spec.signing_key = nil
@spec.cert_chain = @signer.cert_chain.map { |cert| cert.to_s }
else
diff --git a/lib/rubygems/package/tar_header.rb b/lib/rubygems/package/tar_header.rb
index fa1f5b6e46..d3c242f815 100644
--- a/lib/rubygems/package/tar_header.rb
+++ b/lib/rubygems/package/tar_header.rb
@@ -50,7 +50,7 @@ class Gem::Package::TarHeader
:uid,
:uname,
:version,
- ]
+ ].freeze
##
# Pack format for a tar header
diff --git a/lib/rubygems/platform.rb b/lib/rubygems/platform.rb
index 2dd9ed5782..1019fc22b9 100644
--- a/lib/rubygems/platform.rb
+++ b/lib/rubygems/platform.rb
@@ -195,12 +195,12 @@ class Gem::Platform
# A pure-Ruby gem that may use Gem::Specification#extensions to build
# binary files.
- RUBY = 'ruby'
+ 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'
+ CURRENT = 'current'.freeze
end
diff --git a/lib/rubygems/remote_fetcher.rb b/lib/rubygems/remote_fetcher.rb
index 940523f246..7c4f3f9a6f 100644
--- a/lib/rubygems/remote_fetcher.rb
+++ b/lib/rubygems/remote_fetcher.rb
@@ -71,13 +71,10 @@ class Gem::RemoteFetcher
# HTTP_PROXY_PASS)
# * <tt>:no_proxy</tt>: ignore environment variables and _don't_ use a proxy
#
- # +dns+: An object to use for DNS resolution of the API endpoint.
- # By default, use Resolv::DNS.
- #
# +headers+: A set of additional HTTP headers to be sent to the server when
# fetching the gem.
- def initialize(proxy=nil, dns=Resolv::DNS.new, headers={})
+ def initialize(proxy=nil, dns=nil, headers={})
require 'net/http'
require 'stringio'
require 'time'
@@ -90,35 +87,10 @@ class Gem::RemoteFetcher
@pool_lock = Mutex.new
@cert_files = Gem::Request.get_cert_files
- @dns = dns
@headers = headers
end
##
- # Given a source at +uri+, calculate what hostname to actually
- # connect to query the data for it.
-
- def api_endpoint(uri)
- host = uri.host
-
- begin
- res = @dns.getresource "_rubygems._tcp.#{host}",
- Resolv::DNS::Resource::IN::SRV
- rescue Resolv::ResolvError => e
- verbose "Getting SRV record failed: #{e}"
- uri
- else
- target = res.target.to_s.strip
-
- if URI("http://" + target).host.end_with?(".#{host}")
- return URI.parse "#{uri.scheme}://#{target}#{uri.path}"
- end
-
- uri
- end
- end
-
- ##
# Given a name and requirement, downloads this gem into cache and returns the
# filename. Returns nil if the gem cannot be located.
#--
diff --git a/lib/rubygems/request_set/gem_dependency_api.rb b/lib/rubygems/request_set/gem_dependency_api.rb
index a26e8b90a3..177079da03 100644
--- a/lib/rubygems/request_set/gem_dependency_api.rb
+++ b/lib/rubygems/request_set/gem_dependency_api.rb
@@ -48,7 +48,7 @@ class Gem::RequestSet::GemDependencyAPI
:ruby_19 => %w[ruby rbx maglev],
:ruby_20 => %w[ruby rbx maglev],
:ruby_21 => %w[ruby rbx maglev],
- }
+ }.freeze
mswin = Gem::Platform.new 'x86-mswin32'
mswin64 = Gem::Platform.new 'x64-mswin64'
@@ -88,7 +88,7 @@ class Gem::RequestSet::GemDependencyAPI
:x64_mingw => x64_mingw,
:x64_mingw_20 => x64_mingw,
:x64_mingw_21 => x64_mingw
- }
+ }.freeze
gt_eq_0 = Gem::Requirement.new '>= 0'
tilde_gt_1_8_0 = Gem::Requirement.new '~> 1.8.0'
@@ -129,7 +129,7 @@ class Gem::RequestSet::GemDependencyAPI
:x64_mingw => gt_eq_0,
:x64_mingw_20 => tilde_gt_2_0_0,
:x64_mingw_21 => tilde_gt_2_1_0,
- }
+ }.freeze
WINDOWS = { # :nodoc:
:mingw => :only,
@@ -160,7 +160,7 @@ class Gem::RequestSet::GemDependencyAPI
:x64_mingw => :only,
:x64_mingw_20 => :only,
:x64_mingw_21 => :only,
- }
+ }.freeze
##
# The gems required by #gem statements in the gem.deps.rb file
diff --git a/lib/rubygems/requirement.rb b/lib/rubygems/requirement.rb
index 0717739dc0..93bfe7d022 100644
--- a/lib/rubygems/requirement.rb
+++ b/lib/rubygems/requirement.rb
@@ -22,12 +22,12 @@ class Gem::Requirement
">=" => lambda { |v, r| v >= r },
"<=" => lambda { |v, r| v <= r },
"~>" => lambda { |v, r| v >= r && v.release < r.bump }
- }
+ }.freeze
SOURCE_SET_REQUIREMENT = Struct.new(:for_lockfile).new "!" # :nodoc:
quoted = OPS.keys.map { |k| Regexp.quote k }.join "|"
- PATTERN_RAW = "\\s*(#{quoted})?\\s*(#{Gem::Version::VERSION_PATTERN})\\s*" # :nodoc:
+ PATTERN_RAW = "\\s*(#{quoted})?\\s*(#{Gem::Version::VERSION_PATTERN})\\s*".freeze # :nodoc:
##
# A regular expression that matches a requirement
@@ -37,7 +37,7 @@ class Gem::Requirement
##
# The default requirement matches any version
- DefaultRequirement = [">=", Gem::Version.new(0)]
+ DefaultRequirement = [">=", Gem::Version.new(0)].freeze
##
# Raised when a bad requirement is encountered
diff --git a/lib/rubygems/resolver/source_set.rb b/lib/rubygems/resolver/source_set.rb
index 66f5963e54..696d963732 100644
--- a/lib/rubygems/resolver/source_set.rb
+++ b/lib/rubygems/resolver/source_set.rb
@@ -37,7 +37,7 @@ class Gem::Resolver::SourceSet < Gem::Resolver::Set
@links[name] = source
end
-private
+ private
def get_set(name)
link = @links[name]
diff --git a/lib/rubygems/resolver/stats.rb b/lib/rubygems/resolver/stats.rb
index 3b95efebf7..64b458f504 100644
--- a/lib/rubygems/resolver/stats.rb
+++ b/lib/rubygems/resolver/stats.rb
@@ -32,7 +32,7 @@ class Gem::Resolver::Stats
@iterations += 1
end
- PATTERN = "%20s: %d\n"
+ PATTERN = "%20s: %d\n".freeze
def display
$stdout.puts "=== Resolver Statistics ==="
diff --git a/lib/rubygems/safe_yaml.rb b/lib/rubygems/safe_yaml.rb
index 949c7b4754..d610889995 100644
--- a/lib/rubygems/safe_yaml.rb
+++ b/lib/rubygems/safe_yaml.rb
@@ -19,12 +19,12 @@ module Gem
Gem::Version::Requirement
YAML::Syck::DefaultKey
Syck::DefaultKey
- )
+ ).freeze
WHITELISTED_SYMBOLS = %w(
development
runtime
- )
+ ).freeze
if ::YAML.respond_to? :safe_load
def self.safe_load input
diff --git a/lib/rubygems/security.rb b/lib/rubygems/security.rb
index dc5e91a6f4..f896039fa4 100644
--- a/lib/rubygems/security.rb
+++ b/lib/rubygems/security.rb
@@ -401,7 +401,7 @@ module Gem::Security
'keyUsage' =>
'keyEncipherment,dataEncipherment,digitalSignature',
'subjectKeyIdentifier' => 'hash',
- }
+ }.freeze
def self.alt_name_or_x509_entry certificate, x509_entry
alt_name = certificate.extensions.find do |extension|
diff --git a/lib/rubygems/security/policies.rb b/lib/rubygems/security/policies.rb
index f16c46306a..49ca8d860d 100644
--- a/lib/rubygems/security/policies.rb
+++ b/lib/rubygems/security/policies.rb
@@ -110,7 +110,7 @@ module Gem::Security
'MediumSecurity' => MediumSecurity,
'HighSecurity' => HighSecurity,
# SigningPolicy is not intended for use by `gem -P` so do not list it
- }
+ }.freeze
end
diff --git a/lib/rubygems/security/policy.rb b/lib/rubygems/security/policy.rb
index f43e6c8c96..2e9159797c 100644
--- a/lib/rubygems/security/policy.rb
+++ b/lib/rubygems/security/policy.rb
@@ -196,9 +196,9 @@ class Gem::Security::Policy
def inspect # :nodoc:
("[Policy: %s - data: %p signer: %p chain: %p root: %p " +
"signed-only: %p trusted-only: %p]") % [
- @name, @verify_chain, @verify_data, @verify_root, @verify_signer,
- @only_signed, @only_trusted,
- ]
+ @name, @verify_chain, @verify_data, @verify_root, @verify_signer,
+ @only_signed, @only_trusted,
+ ]
end
##
diff --git a/lib/rubygems/security/signer.rb b/lib/rubygems/security/signer.rb
index fc98f951bc..32dab9fa81 100644
--- a/lib/rubygems/security/signer.rb
+++ b/lib/rubygems/security/signer.rb
@@ -30,6 +30,15 @@ class Gem::Security::Signer
attr_reader :digest_name # :nodoc:
##
+ # Gem::Security::Signer options
+
+ attr_reader :options
+
+ DEFAULT_OPTIONS = {
+ expiration_length_days: 365
+ }.freeze
+
+ ##
# Attemps to re-sign an expired cert with a given private key
def self.re_sign_cert(expired_cert, expired_cert_path, private_key)
return unless expired_cert.not_after < Time.now
@@ -40,7 +49,11 @@ class Gem::Security::Signer
Gem::Security.write(expired_cert, new_expired_cert_path)
- re_signed_cert = Gem::Security.re_sign(expired_cert, private_key)
+ re_signed_cert = Gem::Security.re_sign(
+ expired_cert,
+ private_key,
+ (Gem::Security::ONE_DAY * Gem.configuration.cert_expiration_length_days)
+ )
Gem::Security.write(re_signed_cert, expired_cert_path)
@@ -52,10 +65,11 @@ class Gem::Security::Signer
# +chain+ containing X509 certificates, encoding certificates or paths to
# certificates.
- def initialize key, cert_chain, passphrase = nil
+ def initialize key, cert_chain, passphrase = nil, options = {}
@cert_chain = cert_chain
@key = key
@passphrase = passphrase
+ @options = DEFAULT_OPTIONS.merge(options)
unless @key then
default_key = File.join Gem.default_key_path
@@ -130,7 +144,9 @@ class Gem::Security::Signer
raise Gem::Security::Exception, 'no certs provided' if @cert_chain.empty?
if @cert_chain.length == 1 and @cert_chain.last.not_after < Time.now then
- re_sign_key
+ re_sign_key(
+ expiration_length: (Gem::Security::ONE_DAY * options[:expiration_length_days])
+ )
end
full_name = extract_name @cert_chain.last
@@ -154,7 +170,7 @@ class Gem::Security::Signer
# be saved as ~/.gem/gem-public_cert.pem.expired.%Y%m%d%H%M%S where the
# expiry time (not after) is used for the timestamp.
- def re_sign_key # :nodoc:
+ def re_sign_key(expiration_length: Gem::Security::ONE_YEAR) # :nodoc:
old_cert = @cert_chain.last
disk_cert_path = File.join(Gem.default_cert_path)
@@ -174,7 +190,7 @@ class Gem::Security::Signer
unless File.exist?(old_cert_path)
Gem::Security.write(old_cert, old_cert_path)
- cert = Gem::Security.re_sign(old_cert, @key)
+ cert = Gem::Security.re_sign(old_cert, @key, expiration_length)
Gem::Security.write(cert, disk_cert_path)
diff --git a/lib/rubygems/security/trust_dir.rb b/lib/rubygems/security/trust_dir.rb
index 62dbe29e4e..6d837affa1 100644
--- a/lib/rubygems/security/trust_dir.rb
+++ b/lib/rubygems/security/trust_dir.rb
@@ -11,7 +11,7 @@ class Gem::Security::TrustDir
DEFAULT_PERMISSIONS = {
:trust_dir => 0700,
:trusted_cert => 0600,
- }
+ }.freeze
##
# The directory where trusted certificates will be stored.
diff --git a/lib/rubygems/server.rb b/lib/rubygems/server.rb
index 9ebd2f5e44..5c65f74aa3 100644
--- a/lib/rubygems/server.rb
+++ b/lib/rubygems/server.rb
@@ -35,7 +35,7 @@ class Gem::Server
include ERB::Util
include Gem::UserInteraction
- SEARCH = <<-ERB
+ SEARCH = <<-ERB.freeze
<form class="headerSearch" name="headerSearchForm" method="get" action="/rdoc">
<div id="search" style="float:right">
<label for="q">Filter/Search</label>
@@ -45,7 +45,7 @@ class Gem::Server
</form>
ERB
- DOC_TEMPLATE = <<-'ERB'
+ DOC_TEMPLATE = <<-'ERB'.freeze
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
@@ -129,7 +129,7 @@ class Gem::Server
ERB
# CSS is copy & paste from rdoc-style.css, RDoc V1.0.1 - 20041108
- RDOC_CSS = <<-CSS
+ RDOC_CSS = <<-CSS.freeze
body {
font-family: Verdana,Arial,Helvetica,sans-serif;
font-size: 90%;
@@ -339,7 +339,7 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
.ruby-value { color: #7fffd4; background: transparent; }
CSS
- RDOC_NO_DOCUMENTATION = <<-'ERB'
+ RDOC_NO_DOCUMENTATION = <<-'ERB'.freeze
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
@@ -373,7 +373,7 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
</html>
ERB
- RDOC_SEARCH_TEMPLATE = <<-'ERB'
+ RDOC_SEARCH_TEMPLATE = <<-'ERB'.freeze
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
diff --git a/lib/rubygems/source.rb b/lib/rubygems/source.rb
index 7f38b6325f..5530c2ce32 100644
--- a/lib/rubygems/source.rb
+++ b/lib/rubygems/source.rb
@@ -16,7 +16,7 @@ class Gem::Source
:released => 'specs',
:latest => 'latest_specs',
:prerelease => 'prerelease_specs',
- }
+ }.freeze
##
# The URI this source will fetch gems from.
@@ -36,15 +36,6 @@ class Gem::Source
end
@uri = uri
- @api_uri = nil
- end
-
- ##
- # Use an SRV record on the host to look up the true endpoint for the index.
-
- def api_uri # :nodoc:
- require 'rubygems/remote_fetcher'
- @api_uri ||= Gem::RemoteFetcher.fetcher.api_endpoint uri
end
##
@@ -87,9 +78,9 @@ 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' == api_uri.scheme
+ return Gem::Resolver::IndexSet.new self if 'file' == uri.scheme
- bundler_api_uri = api_uri + './api/v1/dependencies'
+ bundler_api_uri = uri + './api/v1/dependencies'
begin
fetcher = Gem::RemoteFetcher.fetcher
@@ -140,9 +131,9 @@ class Gem::Source
spec_file_name = name_tuple.spec_name
- uri = api_uri + "#{Gem::MARSHAL_SPEC_DIR}#{spec_file_name}"
+ source_uri = uri + "#{Gem::MARSHAL_SPEC_DIR}#{spec_file_name}"
- cache_dir = cache_dir uri
+ cache_dir = cache_dir source_uri
local_spec = File.join cache_dir, spec_file_name
@@ -152,9 +143,9 @@ class Gem::Source
return spec if spec
end
- uri.path << '.rz'
+ source_uri.path << '.rz'
- spec = fetcher.fetch_path uri
+ spec = fetcher.fetch_path source_uri
spec = Gem::Util.inflate spec
if update_cache? then
@@ -184,7 +175,7 @@ class Gem::Source
file = FILES[type]
fetcher = Gem::RemoteFetcher.fetcher
file_name = "#{file}.#{Gem.marshal_version}"
- spec_path = api_uri + "#{file_name}.gz"
+ spec_path = uri + "#{file_name}.gz"
cache_dir = cache_dir spec_path
local_file = File.join(cache_dir, file_name)
retried = false
@@ -212,7 +203,7 @@ class Gem::Source
def download(spec, dir=Dir.pwd)
fetcher = Gem::RemoteFetcher.fetcher
- fetcher.download spec, api_uri.to_s, dir
+ fetcher.download spec, uri.to_s, dir
end
def pretty_print q # :nodoc:
@@ -220,7 +211,7 @@ class Gem::Source
q.breakable
q.text @uri.to_s
- if api = api_uri
+ if api = uri
q.breakable
q.text 'API URI: '
q.text api.to_s
diff --git a/lib/rubygems/spec_fetcher.rb b/lib/rubygems/spec_fetcher.rb
index 4d224ca173..7c77eeffdb 100644
--- a/lib/rubygems/spec_fetcher.rb
+++ b/lib/rubygems/spec_fetcher.rb
@@ -203,9 +203,9 @@ class Gem::SpecFetcher
matches = if matches.empty? && type != :prerelease
suggest_gems_from_name gem_name, :prerelease
- else
- matches.uniq.sort_by { |name, dist| dist }
- end
+ else
+ matches.uniq.sort_by { |name, dist| dist }
+ end
matches.first(5).map { |name, dist| name }
end
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb
index 1ec4ed9227..7b2f031d27 100644
--- a/lib/rubygems/specification.rb
+++ b/lib/rubygems/specification.rb
@@ -1,5 +1,5 @@
-# -*- coding: utf-8 -*-
# frozen_string_literal: true
+# -*- coding: utf-8 -*-
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
@@ -89,13 +89,13 @@ class Gem::Specification < Gem::BasicSpecification
'Added "required_rubygems_version"',
'Now forward-compatible with future versions',
],
- 3 => [
- 'Added Fixnum validation to the specification_version'
+ 3 => [
+ 'Added Fixnum validation to the specification_version'
],
- 4 => [
+ 4 => [
'Added sandboxed freeform metadata to the specification version.'
]
- }
+ }.freeze
MARSHAL_FIELDS = { # :nodoc:
-1 => 16,
@@ -103,12 +103,14 @@ class Gem::Specification < Gem::BasicSpecification
2 => 16,
3 => 17,
4 => 18,
- }
+ }.freeze
today = Time.now.utc
TODAY = Time.utc(today.year, today.month, today.day) # :nodoc:
+ # rubocop:disable Style/MutableConstant
LOAD_CACHE = {} # :nodoc:
+ # rubocop:enable Style/MutableConstant
private_constant :LOAD_CACHE if defined? private_constant
@@ -163,19 +165,21 @@ class Gem::Specification < Gem::BasicSpecification
:version => nil,
}.freeze
+ # rubocop:disable Style/MutableConstant
INITIALIZE_CODE_FOR_DEFAULTS = { } # :nodoc:
+ # rubocop:enable Style/MutableConstant
@@default_value.each do |k,v|
INITIALIZE_CODE_FOR_DEFAULTS[k] = case v
- when [], {}, true, false, nil, Numeric, Symbol
- v.inspect
- when String
- v.dump
- when Numeric
- "default_value(:#{k})"
- else
- "default_value(:#{k}).dup"
- end
+ when [], {}, true, false, nil, Numeric, Symbol
+ v.inspect
+ when String
+ v.dump
+ when Numeric
+ "default_value(:#{k})"
+ else
+ "default_value(:#{k}).dup"
+ end
end
@@attributes = @@default_value.keys.sort_by { |s| s.to_s }
@@ -260,22 +264,11 @@ class Gem::Specification < Gem::BasicSpecification
].flatten.compact.uniq.sort
end
- ######################################################################
- # :section: Recommended gemspec attributes
-
##
- # Singular writer for #authors
+ # A list of authors for this gem.
#
- # Usage:
- #
- # spec.author = 'John Jones'
-
- def author= o
- self.authors = [o]
- end
-
- ##
- # Sets the list of authors, ensuring it is an array.
+ # Alternatively, a single author can be specified by assigning a string to
+ # `spec.author`
#
# Usage:
#
@@ -285,6 +278,9 @@ class Gem::Specification < Gem::BasicSpecification
@authors = Array(value).flatten.grep(String)
end
+ ######################################################################
+ # :section: Recommended gemspec attributes
+
##
# A long description of this gem
#
@@ -404,6 +400,17 @@ class Gem::Specification < Gem::BasicSpecification
# :section: Optional gemspec attributes
##
+ # Singular (alternative) writer for #authors
+ #
+ # Usage:
+ #
+ # spec.author = 'John Jones'
+
+ def author= o
+ self.authors = [o]
+ end
+
+ ##
# The path in the gem for executable scripts. Usually 'bin'
#
# Usage:
diff --git a/lib/rubygems/specification_policy.rb b/lib/rubygems/specification_policy.rb
index d117120e9a..e28408a5a5 100644
--- a/lib/rubygems/specification_policy.rb
+++ b/lib/rubygems/specification_policy.rb
@@ -4,6 +4,8 @@ require 'uri'
class Gem::SpecificationPolicy < SimpleDelegator
VALID_NAME_PATTERN = /\A[a-zA-Z0-9\.\-\_]+\z/ # :nodoc:
+ SPECIAL_CHARACTERS = /\A[#{Regexp.escape('.-_')}]+/ # :nodoc:
+
VALID_URI_PATTERN = %r{\Ahttps?:\/\/([^\s:@]+:[^\s:@]*@)?[A-Za-z\d\-]+(\.[A-Za-z\d\-]+)+\.?(:\d{1,5})?([\/?]\S*)?\z} # :nodoc:
METADATA_LINK_KEYS = %w[
@@ -14,7 +16,7 @@ class Gem::SpecificationPolicy < SimpleDelegator
mailing_list_uri
source_code_uri
wiki_uri
- ] # :nodoc:
+ ].freeze # :nodoc:
def initialize(specification)
@warnings = 0
@@ -219,12 +221,14 @@ open-ended dependency on #{dep} is not recommended
end
def validate_name
- if !name.is_a?(String) then
+ if !name.is_a?(String)
error "invalid value for attribute name: \"#{name.inspect}\" must be a string"
- elsif name !~ /[a-zA-Z]/ then
+ elsif name !~ /[a-zA-Z]/
error "invalid value for attribute name: #{name.dump} must include at least one letter"
- elsif name !~ VALID_NAME_PATTERN then
+ elsif name !~ VALID_NAME_PATTERN
error "invalid value for attribute name: #{name.dump} can only include letters, numbers, dashes, and underscores"
+ elsif name =~ SPECIAL_CHARACTERS
+ error "invalid value for attribute name: #{name.dump} can not begin with a period, dash, or underscore"
end
end
@@ -257,9 +261,9 @@ open-ended dependency on #{dep} is not recommended
def validate_platform
case platform
- when Gem::Platform, Gem::Platform::RUBY then # ok
- else
- error "invalid platform #{platform.inspect}, see Gem::Platform"
+ when Gem::Platform, Gem::Platform::RUBY then # ok
+ else
+ error "invalid platform #{platform.inspect}, see Gem::Platform"
end
end
@@ -272,10 +276,10 @@ open-ended dependency on #{dep} is not recommended
def validate_array_attribute(field)
val = self.send(field)
klass = case field
- when :dependencies then
- Gem::Dependency
- else
- String
+ when :dependencies then
+ Gem::Dependency
+ else
+ String
end
unless Array === val and val.all? {|x| x.kind_of?(klass)} then
diff --git a/lib/rubygems/stub_specification.rb b/lib/rubygems/stub_specification.rb
index 62689c21f9..8dd6df17e3 100644
--- a/lib/rubygems/stub_specification.rb
+++ b/lib/rubygems/stub_specification.rb
@@ -6,10 +6,10 @@
class Gem::StubSpecification < Gem::BasicSpecification
# :nodoc:
- PREFIX = "# stub: "
+ PREFIX = "# stub: ".freeze
# :nodoc:
- OPEN_MODE = 'r:UTF-8:-'
+ OPEN_MODE = 'r:UTF-8:-'.freeze
class StubLine # :nodoc: all
attr_reader :name, :version, :platform, :require_paths, :extensions,
@@ -22,7 +22,7 @@ class Gem::StubSpecification < Gem::BasicSpecification
'lib' => 'lib'.freeze,
'test' => 'test'.freeze,
'ext' => 'ext'.freeze,
- }
+ }.freeze
# These are common require path lists. This hash is used to optimize
# and consolidate require_path objects. Most specs just specify "lib"
@@ -30,7 +30,7 @@ class Gem::StubSpecification < Gem::BasicSpecification
# a require path list for that case.
REQUIRE_PATH_LIST = { # :nodoc:
'lib' => ['lib'].freeze
- }
+ }.freeze
def initialize data, extensions
parts = data[PREFIX.length..-1].split(" ".freeze, 4)
diff --git a/lib/rubygems/test_case.rb b/lib/rubygems/test_case.rb
index ced33c4d11..718571ea57 100644
--- a/lib/rubygems/test_case.rb
+++ b/lib/rubygems/test_case.rb
@@ -1540,7 +1540,7 @@ Also, a list:
# :stopdoc:
# only available in RubyGems tests
- PRIVATE_KEY_PASSPHRASE = 'Foo bar'
+ PRIVATE_KEY_PASSPHRASE = 'Foo bar'.freeze
begin
PRIVATE_KEY = load_key 'private'
diff --git a/lib/rubygems/test_utilities.rb b/lib/rubygems/test_utilities.rb
index 3e17973dd4..1ec142937a 100644
--- a/lib/rubygems/test_utilities.rb
+++ b/lib/rubygems/test_utilities.rb
@@ -25,17 +25,11 @@ class Gem::FakeFetcher
attr_reader :data
attr_reader :last_request
- attr_reader :api_endpoints
attr_accessor :paths
def initialize
@data = {}
@paths = []
- @api_endpoints = {}
- end
-
- def api_endpoint(uri)
- @api_endpoints[uri] || uri
end
def find_data(path)
@@ -111,14 +105,6 @@ class Gem::FakeFetcher
q.breakable
q.pp @data.keys
-
- unless @api_endpoints.empty? then
- q.breakable
- q.text 'API endpoints:'
-
- q.breakable
- q.pp @api_endpoints.keys
- end
end
end
diff --git a/lib/rubygems/text.rb b/lib/rubygems/text.rb
index b944b62c27..52580e780c 100644
--- a/lib/rubygems/text.rb
+++ b/lib/rubygems/text.rb
@@ -73,7 +73,7 @@ module Gem::Text
d[j+1] + 1, # insertion
e + 1, # deletion
d[j] + cost # substitution
- )
+ )
d[j] = e
e = x
end
diff --git a/lib/rubygems/uninstaller.rb b/lib/rubygems/uninstaller.rb
index 3059099373..ee0467c7bf 100644
--- a/lib/rubygems/uninstaller.rb
+++ b/lib/rubygems/uninstaller.rb
@@ -315,8 +315,8 @@ class Gem::Uninstaller
msg << ''
siblings = Gem::Specification.select do |s|
- s.name == spec.name && s.full_name != spec.full_name
- end
+ s.name == spec.name && s.full_name != spec.full_name
+ end
spec.dependent_gems.each do |dep_spec, dep, satlist|
unless siblings.any? { |s| s.satisfies_requirement? dep }
diff --git a/lib/rubygems/version.rb b/lib/rubygems/version.rb
index 08f0d1e7a5..d700aebd5d 100644
--- a/lib/rubygems/version.rb
+++ b/lib/rubygems/version.rb
@@ -154,7 +154,7 @@ class Gem::Version
include Comparable
- VERSION_PATTERN = '[0-9]+(?>\.[0-9a-zA-Z]+)*(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?' # :nodoc:
+ VERSION_PATTERN = '[0-9]+(?>\.[0-9a-zA-Z]+)*(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?'.freeze # :nodoc:
ANCHORED_VERSION_PATTERN = /\A\s*(#{VERSION_PATTERN})?\s*\z/ # :nodoc:
##