summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/rubygems.rb21
-rw-r--r--lib/rubygems/available_set.rb1
-rw-r--r--lib/rubygems/basic_specification.rb1
-rw-r--r--lib/rubygems/command.rb29
-rw-r--r--lib/rubygems/commands/build_command.rb1
-rw-r--r--lib/rubygems/commands/cleanup_command.rb14
-rw-r--r--lib/rubygems/commands/contents_command.rb6
-rw-r--r--lib/rubygems/commands/dependency_command.rb5
-rw-r--r--lib/rubygems/commands/info_command.rb2
-rw-r--r--lib/rubygems/commands/install_command.rb7
-rw-r--r--lib/rubygems/commands/lock_command.rb4
-rw-r--r--lib/rubygems/commands/mirror_command.rb1
-rw-r--r--lib/rubygems/commands/open_command.rb3
-rw-r--r--lib/rubygems/commands/outdated_command.rb1
-rw-r--r--lib/rubygems/commands/owner_command.rb3
-rw-r--r--lib/rubygems/commands/pristine_command.rb1
-rw-r--r--lib/rubygems/commands/push_command.rb2
-rw-r--r--lib/rubygems/commands/query_command.rb8
-rw-r--r--lib/rubygems/commands/rdoc_command.rb1
-rw-r--r--lib/rubygems/commands/setup_command.rb1
-rw-r--r--lib/rubygems/commands/signin_command.rb1
-rw-r--r--lib/rubygems/commands/specification_command.rb1
-rw-r--r--lib/rubygems/commands/stale_command.rb2
-rw-r--r--lib/rubygems/commands/uninstall_command.rb1
-rw-r--r--lib/rubygems/commands/update_command.rb2
-rw-r--r--lib/rubygems/commands/which_command.rb1
-rw-r--r--lib/rubygems/commands/yank_command.rb1
-rw-r--r--lib/rubygems/config_file.rb1
-rw-r--r--lib/rubygems/core_ext/kernel_gem.rb4
-rw-r--r--lib/rubygems/defaults.rb4
-rw-r--r--lib/rubygems/dependency.rb9
-rw-r--r--lib/rubygems/dependency_installer.rb10
-rw-r--r--lib/rubygems/dependency_list.rb21
-rw-r--r--lib/rubygems/deprecate.rb4
-rw-r--r--lib/rubygems/errors.rb13
-rw-r--r--lib/rubygems/exceptions.rb9
-rw-r--r--lib/rubygems/ext/builder.rb4
-rw-r--r--lib/rubygems/ext/cmake_builder.rb2
-rw-r--r--lib/rubygems/ext/ext_conf_builder.rb3
-rw-r--r--lib/rubygems/gemcutter_utilities.rb4
-rw-r--r--lib/rubygems/indexer.rb14
-rw-r--r--lib/rubygems/installer.rb8
-rw-r--r--lib/rubygems/installer_test_case.rb8
-rw-r--r--lib/rubygems/local_remote_options.rb2
-rw-r--r--lib/rubygems/mock_gem_ui.rb3
-rw-r--r--lib/rubygems/name_tuple.rb1
-rw-r--r--lib/rubygems/package.rb3
-rw-r--r--lib/rubygems/path_support.rb2
-rw-r--r--lib/rubygems/platform.rb1
-rw-r--r--lib/rubygems/psych_tree.rb2
-rw-r--r--lib/rubygems/remote_fetcher.rb1
-rw-r--r--lib/rubygems/request.rb9
-rw-r--r--lib/rubygems/request/connection_pools.rb4
-rw-r--r--lib/rubygems/request/http_pool.rb1
-rw-r--r--lib/rubygems/request/https_pool.rb2
-rw-r--r--lib/rubygems/request_set.rb4
-rw-r--r--lib/rubygems/request_set/gem_dependency_api.rb17
-rw-r--r--lib/rubygems/request_set/lockfile.rb7
-rw-r--r--lib/rubygems/request_set/lockfile/parser.rb6
-rw-r--r--lib/rubygems/request_set/lockfile/tokenizer.rb2
-rw-r--r--lib/rubygems/requirement.rb16
-rw-r--r--lib/rubygems/resolver.rb5
-rw-r--r--lib/rubygems/resolver/activation_request.rb4
-rw-r--r--lib/rubygems/resolver/best_set.rb4
-rw-r--r--lib/rubygems/resolver/installer_set.rb6
-rw-r--r--lib/rubygems/resolver/lock_set.rb2
-rw-r--r--lib/rubygems/resolver/lock_specification.rb4
-rw-r--r--lib/rubygems/resolver/requirement_list.rb1
-rw-r--r--lib/rubygems/resolver/specification.rb1
-rw-r--r--lib/rubygems/resolver/stats.rb2
-rw-r--r--lib/rubygems/security/signer.rb2
-rw-r--r--lib/rubygems/server.rb9
-rw-r--r--lib/rubygems/source_list.rb1
-rw-r--r--lib/rubygems/spec_fetcher.rb4
-rw-r--r--lib/rubygems/specification.rb54
-rw-r--r--lib/rubygems/specification_policy.rb6
-rw-r--r--lib/rubygems/stub_specification.rb7
-rw-r--r--lib/rubygems/syck_hack.rb2
-rw-r--r--lib/rubygems/test_case.rb64
-rw-r--r--lib/rubygems/test_utilities.rb1
-rw-r--r--lib/rubygems/text.rb4
-rw-r--r--lib/rubygems/uninstaller.rb9
-rw-r--r--lib/rubygems/user_interaction.rb9
-rw-r--r--lib/rubygems/util.rb4
-rw-r--r--lib/rubygems/util/licenses.rb2
-rw-r--r--lib/rubygems/util/list.rb2
-rw-r--r--lib/rubygems/validator.rb11
-rw-r--r--lib/rubygems/version.rb2
-rw-r--r--test/rubygems/plugin/load/rubygems_plugin.rb2
-rw-r--r--test/rubygems/test_deprecate.rb3
-rw-r--r--test/rubygems/test_gem.rb81
-rw-r--r--test/rubygems/test_gem_available_set.rb5
-rw-r--r--test/rubygems/test_gem_bundler_version_finder.rb6
-rw-r--r--test/rubygems/test_gem_command.rb97
-rw-r--r--test/rubygems/test_gem_commands_cleanup_command.rb28
-rw-r--r--test/rubygems/test_gem_commands_environment_command.rb1
-rw-r--r--test/rubygems/test_gem_commands_help_command.rb2
-rw-r--r--test/rubygems/test_gem_commands_info_command.rb1
-rw-r--r--test/rubygems/test_gem_commands_install_command.rb55
-rw-r--r--test/rubygems/test_gem_commands_mirror.rb1
-rw-r--r--test/rubygems/test_gem_commands_outdated_command.rb1
-rw-r--r--test/rubygems/test_gem_commands_pristine_command.rb17
-rw-r--r--test/rubygems/test_gem_commands_push_command.rb18
-rw-r--r--test/rubygems/test_gem_commands_query_command.rb4
-rw-r--r--test/rubygems/test_gem_commands_setup_command.rb60
-rw-r--r--test/rubygems/test_gem_commands_signin_command.rb7
-rw-r--r--test/rubygems/test_gem_commands_sources_command.rb8
-rw-r--r--test/rubygems/test_gem_commands_uninstall_command.rb10
-rw-r--r--test/rubygems/test_gem_commands_update_command.rb37
-rw-r--r--test/rubygems/test_gem_commands_yank_command.rb3
-rw-r--r--test/rubygems/test_gem_config_file.rb1
-rw-r--r--test/rubygems/test_gem_dependency_installer.rb20
-rw-r--r--test/rubygems/test_gem_dependency_list.rb27
-rw-r--r--test/rubygems/test_gem_ext_builder.rb4
-rw-r--r--test/rubygems/test_gem_ext_rake_builder.rb2
-rw-r--r--test/rubygems/test_gem_gemcutter_utilities.rb16
-rw-r--r--test/rubygems/test_gem_indexer.rb7
-rw-r--r--test/rubygems/test_gem_install_update_options.rb1
-rw-r--r--test/rubygems/test_gem_installer.rb18
-rw-r--r--test/rubygems/test_gem_package.rb49
-rw-r--r--test/rubygems/test_gem_package_tar_reader_entry.rb10
-rw-r--r--test/rubygems/test_gem_package_tar_writer.rb16
-rw-r--r--test/rubygems/test_gem_path_support.rb2
-rw-r--r--test/rubygems/test_gem_platform.rb5
-rw-r--r--test/rubygems/test_gem_rdoc.rb137
-rw-r--r--test/rubygems/test_gem_remote_fetcher.rb31
-rw-r--r--test/rubygems/test_gem_request.rb10
-rw-r--r--test/rubygems/test_gem_request_connection_pools.rb8
-rw-r--r--test/rubygems/test_gem_request_set.rb41
-rw-r--r--test/rubygems/test_gem_request_set_gem_dependency_api.rb36
-rw-r--r--test/rubygems/test_gem_request_set_lockfile.rb1
-rw-r--r--test/rubygems/test_gem_request_set_lockfile_parser.rb2
-rw-r--r--test/rubygems/test_gem_request_set_lockfile_tokenizer.rb2
-rw-r--r--test/rubygems/test_gem_requirement.rb1
-rw-r--r--test/rubygems/test_gem_resolver.rb79
-rw-r--r--test/rubygems/test_gem_resolver_index_specification.rb9
-rw-r--r--test/rubygems/test_gem_resolver_installer_set.rb4
-rw-r--r--test/rubygems/test_gem_resolver_specification.rb2
-rw-r--r--test/rubygems/test_gem_security.rb2
-rw-r--r--test/rubygems/test_gem_server.rb8
-rw-r--r--test/rubygems/test_gem_silent_ui.rb1
-rw-r--r--test/rubygems/test_gem_source.rb14
-rw-r--r--test/rubygems/test_gem_source_fetch_problem.rb1
-rw-r--r--test/rubygems/test_gem_source_git.rb8
-rw-r--r--test/rubygems/test_gem_source_installed.rb12
-rw-r--r--test/rubygems/test_gem_source_list.rb1
-rw-r--r--test/rubygems/test_gem_source_local.rb9
-rw-r--r--test/rubygems/test_gem_source_lock.rb24
-rw-r--r--test/rubygems/test_gem_source_specific_file.rb13
-rw-r--r--test/rubygems/test_gem_source_vendor.rb8
-rw-r--r--test/rubygems/test_gem_specification.rb37
-rw-r--r--test/rubygems/test_gem_stream_ui.rb2
-rw-r--r--test/rubygems/test_gem_stub_specification.rb1
-rw-r--r--test/rubygems/test_gem_text.rb2
-rw-r--r--test/rubygems/test_gem_uninstaller.rb31
-rw-r--r--test/rubygems/test_gem_util.rb4
-rw-r--r--test/rubygems/test_gem_version.rb17
-rw-r--r--test/rubygems/test_kernel.rb1
-rw-r--r--test/rubygems/test_remote_fetch_error.rb1
-rw-r--r--test/rubygems/test_require.rb8
160 files changed, 1159 insertions, 578 deletions
diff --git a/lib/rubygems.rb b/lib/rubygems.rb
index d31c216142..d0933e1b6c 100644
--- a/lib/rubygems.rb
+++ b/lib/rubygems.rb
@@ -271,9 +271,9 @@ module Gem
specs = dep.matching_specs(true)
- specs = specs.find_all { |spec|
+ specs = specs.find_all do |spec|
spec.executables.include? exec_name
- } if exec_name
+ end if exec_name
unless spec = specs.first
msg = "can't find gem #{dep} with executable #{exec_name}"
@@ -521,9 +521,9 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
def self.find_files_from_load_path(glob) # :nodoc:
glob_with_suffixes = "#{glob}#{Gem.suffix_pattern}"
- $LOAD_PATH.map { |load_path|
+ $LOAD_PATH.map do |load_path|
Gem::Util.glob_files_in_dir(glob_with_suffixes, load_path)
- }.flatten.select { |file| File.file? file.untaint }
+ end.flatten.select { |file| File.file? file.untaint }
end
##
@@ -593,8 +593,10 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
end
class << self
+
extend Gem::Deprecate
deprecate :gunzip, "Gem::Util.gunzip", 2018, 12
+
end
##
@@ -605,8 +607,10 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
end
class << self
+
extend Gem::Deprecate
deprecate :gzip, "Gem::Util.gzip", 2018, 12
+
end
##
@@ -617,8 +621,10 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
end
class << self
+
extend Gem::Deprecate
deprecate :inflate, "Gem::Util.inflate", 2018, 12
+
end
##
@@ -1015,11 +1021,11 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
def self.suffixes
@suffixes ||= ['',
'.rb',
- *%w(DLEXT DLEXT2).map { |key|
+ *%w(DLEXT DLEXT2).map do |key|
val = RbConfig::CONFIG[key]
next unless val and not val.empty?
".#{val}"
- }
+ end
].compact.uniq
end
@@ -1211,6 +1217,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
end
class << self
+
##
# TODO remove with RubyGems 4.0
@@ -1218,6 +1225,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
extend Gem::Deprecate
deprecate :detect_gemdeps, "Gem.use_gemdeps", 2018, 12
+
end
# FIX: Almost everywhere else we use the `def self.` way of defining class
@@ -1337,6 +1345,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
# work
attr_reader :pre_uninstall_hooks
+
end
##
diff --git a/lib/rubygems/available_set.rb b/lib/rubygems/available_set.rb
index 8334a73ecb..2e9d9496f6 100644
--- a/lib/rubygems/available_set.rb
+++ b/lib/rubygems/available_set.rb
@@ -162,4 +162,5 @@ class Gem::AvailableSet
def inject_into_list(dep_list)
@set.each { |t| dep_list.add t.spec }
end
+
end
diff --git a/lib/rubygems/basic_specification.rb b/lib/rubygems/basic_specification.rb
index d1878021ba..edb38cb1c2 100644
--- a/lib/rubygems/basic_specification.rb
+++ b/lib/rubygems/basic_specification.rb
@@ -329,4 +329,5 @@ class Gem::BasicSpecification
false
end
end
+
end
diff --git a/lib/rubygems/command.rb b/lib/rubygems/command.rb
index 5b8868b0cd..a509b783dd 100644
--- a/lib/rubygems/command.rb
+++ b/lib/rubygems/command.rb
@@ -122,6 +122,7 @@ class Gem::Command
@defaults = defaults
@options = defaults.dup
@option_groups = Hash.new { |h,k| h[k] = [] }
+ @deprecated_options = { command => {} }
@parser = nil
@when_invoked = nil
end
@@ -365,13 +366,34 @@ class Gem::Command
end
end
+ def deprecate_option(short_name: nil, long_name: nil, version: nil)
+ @deprecated_options[command].merge!({ short_name => { "rg_version_to_expire" => version } }) if short_name
+ @deprecated_options[command].merge!({ long_name => { "rg_version_to_expire" => version } }) if long_name
+ end
+
+ def check_deprecated_options(options)
+ options.each do |option|
+ if option_is_deprecated?(option)
+ version_to_expire = @deprecated_options[command][option]["rg_version_to_expire"]
+
+ deprecate_option_msg = if version_to_expire
+ "The \"#{option}\" option has been deprecated and will be removed in Rubygems #{version_to_expire}, its use is discouraged."
+ else
+ "The \"#{option}\" option has been deprecated and will be removed in future versions of Rubygems, its use is discouraged."
+ end
+
+ alert_warning(deprecate_option_msg)
+ end
+ end
+ end
+
##
# Merge a set of command options with the set of default options (without
# modifying the default option hash).
def merge_options(new_options)
@options = @defaults.clone
- new_options.each do |k,v| @options[k] = v end
+ new_options.each { |k,v| @options[k] = v }
end
##
@@ -392,6 +414,7 @@ class Gem::Command
def handle_options(args)
args = add_extra_args(args)
+ check_deprecated_options(args)
@options = Marshal.load Marshal.dump @defaults # deep copy
parser.parse!(args)
@options[:args] = args
@@ -420,6 +443,10 @@ class Gem::Command
private
+ def option_is_deprecated?(option)
+ @deprecated_options[command].has_key?(option)
+ end
+
def add_parser_description # :nodoc:
return unless description
diff --git a/lib/rubygems/commands/build_command.rb b/lib/rubygems/commands/build_command.rb
index 761b80ee94..9d318e6e8b 100644
--- a/lib/rubygems/commands/build_command.rb
+++ b/lib/rubygems/commands/build_command.rb
@@ -96,4 +96,5 @@ Gems can be saved to a specified filename with the output option:
terminate_interaction 1
end
end
+
end
diff --git a/lib/rubygems/commands/cleanup_command.rb b/lib/rubygems/commands/cleanup_command.rb
index aeb4d82fae..fedaec8448 100644
--- a/lib/rubygems/commands/cleanup_command.rb
+++ b/lib/rubygems/commands/cleanup_command.rb
@@ -99,7 +99,7 @@ If no gems are named all gems in GEM_HOME are cleaned.
@full = Gem::DependencyList.from_specs
deplist = Gem::DependencyList.new
- @gems_to_cleanup.each do |spec| deplist.add spec end
+ @gems_to_cleanup.each { |spec| deplist.add spec }
deps = deplist.strongly_connected_components.flatten
@@ -121,19 +121,19 @@ If no gems are named all gems in GEM_HOME are cleaned.
end
def get_gems_to_cleanup
- gems_to_cleanup = @candidate_gems.select { |spec|
+ gems_to_cleanup = @candidate_gems.select do |spec|
@primary_gems[spec.name].version != spec.version
- }
+ end
- default_gems, gems_to_cleanup = gems_to_cleanup.partition { |spec|
+ default_gems, gems_to_cleanup = gems_to_cleanup.partition do |spec|
spec.default_gem?
- }
+ end
uninstall_from = options[:user_install] ? Gem.user_dir : @original_home
- gems_to_cleanup = gems_to_cleanup.select { |spec|
+ gems_to_cleanup = gems_to_cleanup.select do |spec|
spec.base_dir == uninstall_from
- }
+ end
@default_gems += default_gems
@default_gems.uniq!
diff --git a/lib/rubygems/commands/contents_command.rb b/lib/rubygems/commands/contents_command.rb
index 6da89a136e..26d6828fe6 100644
--- a/lib/rubygems/commands/contents_command.rb
+++ b/lib/rubygems/commands/contents_command.rb
@@ -14,7 +14,7 @@ class Gem::Commands::ContentsCommand < Gem::Command
add_version_option
- add_option( '--all',
+ add_option('--all',
"Contents for all gems") do |all, options|
options[:all] = all
end
@@ -29,12 +29,12 @@ class Gem::Commands::ContentsCommand < Gem::Command
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',
+ add_option('--[no-]show-install-dir',
'Show only the gem install dir') do |show, options|
options[:show_install_dir] = show
end
diff --git a/lib/rubygems/commands/dependency_command.rb b/lib/rubygems/commands/dependency_command.rb
index 9e88b04ea5..8e198ac93a 100644
--- a/lib/rubygems/commands/dependency_command.rb
+++ b/lib/rubygems/commands/dependency_command.rb
@@ -80,9 +80,9 @@ use with other commands.
end
def gem_dependency(pattern, version, prerelease) # :nodoc:
- dependency = Gem::Deprecate.skip_during {
+ dependency = Gem::Deprecate.skip_during do
Gem::Dependency.new pattern, version
- }
+ end
dependency.prerelease = prerelease
@@ -215,4 +215,5 @@ use with other commands.
/\A#{Regexp.union(*args)}/
end
end
+
end
diff --git a/lib/rubygems/commands/info_command.rb b/lib/rubygems/commands/info_command.rb
index 8d9611a957..6a737b178b 100644
--- a/lib/rubygems/commands/info_command.rb
+++ b/lib/rubygems/commands/info_command.rb
@@ -4,6 +4,7 @@ require 'rubygems/command'
require 'rubygems/commands/query_command'
class Gem::Commands::InfoCommand < Gem::Commands::QueryCommand
+
def initialize
super "info", "Show information for the given gem"
@@ -30,4 +31,5 @@ class Gem::Commands::InfoCommand < Gem::Commands::QueryCommand
def defaults_str
"--local"
end
+
end
diff --git a/lib/rubygems/commands/install_command.rb b/lib/rubygems/commands/install_command.rb
index 776b58651f..82631b1ffd 100644
--- a/lib/rubygems/commands/install_command.rb
+++ b/lib/rubygems/commands/install_command.rb
@@ -201,10 +201,13 @@ You can use `i` command instead of `install`.
request_set = inst.resolve_dependencies name, req
if options[:explain]
- puts "Gems to install:"
+ say "Gems to install:"
request_set.sorted_requests.each do |s|
- puts " #{s.full_name}"
+ # shows platform specific gems if used
+ say (plat = s.spec.platform) == Gem::Platform::RUBY ?
+ " #{s.full_name}" :
+ " #{s.full_name}-#{plat}"
end
return
diff --git a/lib/rubygems/commands/lock_command.rb b/lib/rubygems/commands/lock_command.rb
index 7f02e9feda..ebb402a8bd 100644
--- a/lib/rubygems/commands/lock_command.rb
+++ b/lib/rubygems/commands/lock_command.rb
@@ -100,9 +100,9 @@ lock it down to the exact version.
end
def spec_path(gem_full_name)
- gemspecs = Gem.path.map { |path|
+ gemspecs = Gem.path.map do |path|
File.join path, "specifications", "#{gem_full_name}.gemspec"
- }
+ end
gemspecs.find { |path| File.exist? path }
end
diff --git a/lib/rubygems/commands/mirror_command.rb b/lib/rubygems/commands/mirror_command.rb
index 801c9c8927..4e2a41fa33 100644
--- a/lib/rubygems/commands/mirror_command.rb
+++ b/lib/rubygems/commands/mirror_command.rb
@@ -3,6 +3,7 @@ require 'rubygems/command'
unless defined? Gem::Commands::MirrorCommand
class Gem::Commands::MirrorCommand < Gem::Command
+
def initialize
super('mirror', 'Mirror all gem files (requires rubygems-mirror)')
begin
diff --git a/lib/rubygems/commands/open_command.rb b/lib/rubygems/commands/open_command.rb
index 2794fe05e6..8eaeb64ba9 100644
--- a/lib/rubygems/commands/open_command.rb
+++ b/lib/rubygems/commands/open_command.rb
@@ -17,7 +17,7 @@ class Gem::Commands::OpenCommand < Gem::Command
end
add_option('-v', '--version VERSION', String,
"Opens specific gem version") do |version|
- options[:version] = version
+ options[:version] = version
end
end
@@ -84,4 +84,5 @@ class Gem::Commands::OpenCommand < Gem::Command
say "Unable to find gem '#{name}'"
end
+
end
diff --git a/lib/rubygems/commands/outdated_command.rb b/lib/rubygems/commands/outdated_command.rb
index 70f6c02801..035eaffcbc 100644
--- a/lib/rubygems/commands/outdated_command.rb
+++ b/lib/rubygems/commands/outdated_command.rb
@@ -30,4 +30,5 @@ update the gems with the update or install commands.
say "#{spec.name} (#{spec.version} < #{remote_version})"
end
end
+
end
diff --git a/lib/rubygems/commands/owner_command.rb b/lib/rubygems/commands/owner_command.rb
index 799f31704a..9fcabaa9f8 100644
--- a/lib/rubygems/commands/owner_command.rb
+++ b/lib/rubygems/commands/owner_command.rb
@@ -4,6 +4,7 @@ require 'rubygems/local_remote_options'
require 'rubygems/gemcutter_utilities'
class Gem::Commands::OwnerCommand < Gem::Command
+
include Gem::LocalRemoteOptions
include Gem::GemcutterUtilities
@@ -60,6 +61,8 @@ permission to.
end
def show_owners(name)
+ Gem.load_yaml
+
response = rubygems_api_request :get, "api/v1/gems/#{name}/owners.yaml" do |request|
request.add_field "Authorization", api_key
end
diff --git a/lib/rubygems/commands/pristine_command.rb b/lib/rubygems/commands/pristine_command.rb
index 41decde856..1d0eb61700 100644
--- a/lib/rubygems/commands/pristine_command.rb
+++ b/lib/rubygems/commands/pristine_command.rb
@@ -183,4 +183,5 @@ extensions will be restored.
say "Restored #{spec.full_name}"
end
end
+
end
diff --git a/lib/rubygems/commands/push_command.rb b/lib/rubygems/commands/push_command.rb
index 55ee3ae73f..7fd1119ff9 100644
--- a/lib/rubygems/commands/push_command.rb
+++ b/lib/rubygems/commands/push_command.rb
@@ -5,6 +5,7 @@ require 'rubygems/gemcutter_utilities'
require 'rubygems/package'
class Gem::Commands::PushCommand < Gem::Command
+
include Gem::LocalRemoteOptions
include Gem::GemcutterUtilities
@@ -145,4 +146,5 @@ You can upgrade or downgrade to the latest release version with:
gem_metadata["allowed_push_host"]
]
end
+
end
diff --git a/lib/rubygems/commands/query_command.rb b/lib/rubygems/commands/query_command.rb
index d947d588ef..5a42d45249 100644
--- a/lib/rubygems/commands/query_command.rb
+++ b/lib/rubygems/commands/query_command.rb
@@ -39,7 +39,7 @@ class Gem::Commands::QueryCommand < Gem::Command
options[:details] = value
end
- add_option( '--[no-]versions',
+ add_option('--[no-]versions',
'Display only gem names') do |value, options|
options[:versions] = value
options[:details] = false unless value
@@ -56,7 +56,7 @@ class Gem::Commands::QueryCommand < Gem::Command
options[:exact] = value
end
- add_option( '--[no-]prerelease',
+ add_option('--[no-]prerelease',
'Display prerelease versions') do |value, options|
options[:prerelease] = value
end
@@ -141,9 +141,9 @@ is too hard to use.
display_header 'LOCAL'
- specs = Gem::Specification.find_all { |s|
+ specs = Gem::Specification.find_all do |s|
s.name =~ name and req =~ s.version
- }
+ end
spec_tuples = specs.map do |spec|
[spec.name_tuple, spec]
diff --git a/lib/rubygems/commands/rdoc_command.rb b/lib/rubygems/commands/rdoc_command.rb
index 5f8b72eb7a..ff9e1ffcfa 100644
--- a/lib/rubygems/commands/rdoc_command.rb
+++ b/lib/rubygems/commands/rdoc_command.rb
@@ -5,6 +5,7 @@ require 'rubygems/rdoc'
require 'fileutils'
class Gem::Commands::RdocCommand < Gem::Command
+
include Gem::VersionOption
def initialize
diff --git a/lib/rubygems/commands/setup_command.rb b/lib/rubygems/commands/setup_command.rb
index c9c00b5be4..975eca593d 100644
--- a/lib/rubygems/commands/setup_command.rb
+++ b/lib/rubygems/commands/setup_command.rb
@@ -6,6 +6,7 @@ require 'rubygems/command'
# RubyGems checkout or tarball.
class Gem::Commands::SetupCommand < Gem::Command
+
HISTORY_HEADER = /^===\s*[\d.a-zA-Z]+\s*\/\s*\d{4}-\d{2}-\d{2}\s*$/.freeze
VERSION_MATCHER = /^===\s*([\d.a-zA-Z]+)\s*\/\s*\d{4}-\d{2}-\d{2}\s*$/.freeze
diff --git a/lib/rubygems/commands/signin_command.rb b/lib/rubygems/commands/signin_command.rb
index 0d527fc339..7c4b5ceb69 100644
--- a/lib/rubygems/commands/signin_command.rb
+++ b/lib/rubygems/commands/signin_command.rb
@@ -3,6 +3,7 @@ require 'rubygems/command'
require 'rubygems/gemcutter_utilities'
class Gem::Commands::SigninCommand < Gem::Command
+
include Gem::GemcutterUtilities
def initialize
diff --git a/lib/rubygems/commands/specification_command.rb b/lib/rubygems/commands/specification_command.rb
index 56b9371686..7326822ad7 100644
--- a/lib/rubygems/commands/specification_command.rb
+++ b/lib/rubygems/commands/specification_command.rb
@@ -143,4 +143,5 @@ Specific fields in the specification can be extracted in YAML format:
say "\n"
end
end
+
end
diff --git a/lib/rubygems/commands/stale_command.rb b/lib/rubygems/commands/stale_command.rb
index 0524ee1e2b..89bafeae98 100644
--- a/lib/rubygems/commands/stale_command.rb
+++ b/lib/rubygems/commands/stale_command.rb
@@ -2,6 +2,7 @@
require 'rubygems/command'
class Gem::Commands::StaleCommand < Gem::Command
+
def initialize
super('stale', 'List gems along with access times')
end
@@ -36,4 +37,5 @@ longer using.
say "#{name} at #{atime.strftime '%c'}"
end
end
+
end
diff --git a/lib/rubygems/commands/uninstall_command.rb b/lib/rubygems/commands/uninstall_command.rb
index 9de0ea722b..698ff4b555 100644
--- a/lib/rubygems/commands/uninstall_command.rb
+++ b/lib/rubygems/commands/uninstall_command.rb
@@ -185,4 +185,5 @@ that is a dependency of an existing gem. You can use the
def uninstall(gem_name)
Gem::Uninstaller.new(gem_name, options).uninstall
end
+
end
diff --git a/lib/rubygems/commands/update_command.rb b/lib/rubygems/commands/update_command.rb
index 9ab3b80e96..c44dcf0bd8 100644
--- a/lib/rubygems/commands/update_command.rb
+++ b/lib/rubygems/commands/update_command.rb
@@ -194,7 +194,7 @@ command to remove old versions.
}
gems_to_update = which_to_update hig, options[:args], :system
- _, up_ver = gems_to_update.first
+ _, up_ver = gems_to_update.first
target = if update_latest
up_ver
diff --git a/lib/rubygems/commands/which_command.rb b/lib/rubygems/commands/which_command.rb
index 5c51ed72dd..334bde2622 100644
--- a/lib/rubygems/commands/which_command.rb
+++ b/lib/rubygems/commands/which_command.rb
@@ -2,6 +2,7 @@
require 'rubygems/command'
class Gem::Commands::WhichCommand < Gem::Command
+
def initialize
super 'which', 'Find the location of a library file you can require',
:search_gems_first => false, :show_all => false
diff --git a/lib/rubygems/commands/yank_command.rb b/lib/rubygems/commands/yank_command.rb
index d13b674b48..be675fa460 100644
--- a/lib/rubygems/commands/yank_command.rb
+++ b/lib/rubygems/commands/yank_command.rb
@@ -5,6 +5,7 @@ require 'rubygems/version_option'
require 'rubygems/gemcutter_utilities'
class Gem::Commands::YankCommand < Gem::Command
+
include Gem::LocalRemoteOptions
include Gem::VersionOption
include Gem::GemcutterUtilities
diff --git a/lib/rubygems/config_file.rb b/lib/rubygems/config_file.rb
index e02655fc51..a5c552dc9f 100644
--- a/lib/rubygems/config_file.rb
+++ b/lib/rubygems/config_file.rb
@@ -484,4 +484,5 @@ if you believe they were disclosed to a third party.
attr_reader :hash
protected :hash
+
end
diff --git a/lib/rubygems/core_ext/kernel_gem.rb b/lib/rubygems/core_ext/kernel_gem.rb
index b0dd69bfcc..39b00387ea 100644
--- a/lib/rubygems/core_ext/kernel_gem.rb
+++ b/lib/rubygems/core_ext/kernel_gem.rb
@@ -64,9 +64,9 @@ module Kernel
spec = dep.to_spec
- Gem::LOADED_SPECS_MUTEX.synchronize {
+ Gem::LOADED_SPECS_MUTEX.synchronize do
spec.activate
- } if spec
+ end if spec
end
private :gem
diff --git a/lib/rubygems/defaults.rb b/lib/rubygems/defaults.rb
index 50f46b32a2..7aa0480b80 100644
--- a/lib/rubygems/defaults.rb
+++ b/lib/rubygems/defaults.rb
@@ -2,8 +2,8 @@
module Gem
DEFAULT_HOST = "https://rubygems.org".freeze
- @post_install_hooks ||= []
- @done_installing_hooks ||= []
+ @post_install_hooks ||= []
+ @done_installing_hooks ||= []
@post_uninstall_hooks ||= []
@pre_uninstall_hooks ||= []
@pre_install_hooks ||= []
diff --git a/lib/rubygems/dependency.rb b/lib/rubygems/dependency.rb
index 33ba1968d1..3c91392cdd 100644
--- a/lib/rubygems/dependency.rb
+++ b/lib/rubygems/dependency.rb
@@ -277,16 +277,16 @@ class Gem::Dependency
def matching_specs(platform_only = false)
env_req = Gem.env_requirement(name)
- matches = Gem::Specification.stubs_for(name).find_all { |spec|
+ matches = Gem::Specification.stubs_for(name).find_all do |spec|
requirement.satisfied_by?(spec.version) && env_req.satisfied_by?(spec.version)
- }.map(&:to_spec)
+ end.map(&:to_spec)
Gem::BundlerVersionFinder.filter!(matches) if name == "bundler".freeze
if platform_only
- matches.reject! { |spec|
+ matches.reject! do |spec|
spec.nil? || !Gem::Platform.match(spec.platform)
- }
+ end
end
matches
@@ -333,4 +333,5 @@ class Gem::Dependency
matches.first
end
+
end
diff --git a/lib/rubygems/dependency_installer.rb b/lib/rubygems/dependency_installer.rb
index 346208603c..7f4f914591 100644
--- a/lib/rubygems/dependency_installer.rb
+++ b/lib/rubygems/dependency_installer.rb
@@ -29,7 +29,7 @@ class Gem::DependencyInstaller
:wrappers => true,
:build_args => nil,
:build_docs_in_background => false,
- :install_as_default => false
+ :install_as_default => false
}.freeze
##
@@ -336,15 +336,15 @@ class Gem::DependencyInstaller
# REFACTOR maybe abstract away using Gem::Specification.include? so
# that this isn't dependent only on the currently installed gems
- dependency_list.specs.reject! { |spec|
+ dependency_list.specs.reject! do |spec|
not keep_names.include?(spec.full_name) and
Gem::Specification.include?(spec)
- }
+ end
unless dependency_list.ok? or @ignore_dependencies or @force
- reason = dependency_list.why_not_ok?.map { |k,v|
+ reason = dependency_list.why_not_ok?.map do |k,v|
"#{k} requires #{v.join(", ")}"
- }.join("; ")
+ end.join("; ")
raise Gem::DependencyError, "Unable to resolve dependencies: #{reason}"
end
diff --git a/lib/rubygems/dependency_list.rb b/lib/rubygems/dependency_list.rb
index ee2e4c7343..eec2223077 100644
--- a/lib/rubygems/dependency_list.rb
+++ b/lib/rubygems/dependency_list.rb
@@ -17,6 +17,7 @@ require 'rubygems/deprecate'
# this class necessary anymore? Especially #ok?, #why_not_ok?
class Gem::DependencyList
+
attr_reader :specs
include Enumerable
@@ -118,10 +119,10 @@ class Gem::DependencyList
unsatisfied = Hash.new { |h,k| h[k] = [] }
each do |spec|
spec.runtime_dependencies.each do |dep|
- inst = Gem::Specification.any? { |installed_spec|
+ inst = Gem::Specification.any? do |installed_spec|
dep.name == installed_spec.name and
dep.requirement.satisfied_by? installed_spec.version
- }
+ end
unless inst or @specs.find { |s| s.satisfies_requirement? dep }
unsatisfied[spec.name] << dep
@@ -145,10 +146,10 @@ class Gem::DependencyList
# If the state is inconsistent, at least don't crash
return true unless gem_to_remove
- siblings = @specs.find_all { |s|
+ siblings = @specs.find_all do |s|
s.name == gem_to_remove.name &&
s.full_name != gem_to_remove.full_name
- }
+ end
deps = []
@@ -160,11 +161,11 @@ class Gem::DependencyList
end
end
- deps.all? { |dep|
- siblings.any? { |s|
+ deps.all? do |dep|
+ siblings.any? do |s|
s.satisfies_requirement? dep
- }
- }
+ end
+ end
end
##
@@ -173,10 +174,10 @@ class Gem::DependencyList
# dependencies).
def remove_specs_unsatisfied_by(dependencies)
- specs.reject! { |spec|
+ specs.reject! do |spec|
dep = dependencies[spec.name]
dep and not dep.requirement.satisfied_by? spec.version
- }
+ end
end
##
diff --git a/lib/rubygems/deprecate.rb b/lib/rubygems/deprecate.rb
index 815f42ae8c..b5591e6ac1 100644
--- a/lib/rubygems/deprecate.rb
+++ b/lib/rubygems/deprecate.rb
@@ -48,7 +48,7 @@ module Gem::Deprecate
# year/month that it is planned to go away.
def deprecate(name, repl, year, month)
- class_eval {
+ class_eval do
old = "_deprecated_#{name}"
alias_method old, name
define_method name do |*args, &block|
@@ -62,7 +62,7 @@ module Gem::Deprecate
warn "#{msg.join}." unless Gem::Deprecate.skip
send old, *args, &block
end
- }
+ end
end
module_function :deprecate, :skip_during
diff --git a/lib/rubygems/errors.rb b/lib/rubygems/errors.rb
index 6773bbcd26..2cd18e2e20 100644
--- a/lib/rubygems/errors.rb
+++ b/lib/rubygems/errors.rb
@@ -13,11 +13,13 @@ module Gem
# already activated gems or that RubyGems is otherwise unable to activate.
class LoadError < ::LoadError
+
# Name of gem
attr_accessor :name
# Version requirement of gem
attr_accessor :requirement
+
end
##
@@ -25,6 +27,7 @@ module Gem
# system. Instead of rescuing from this class, make sure to rescue from the
# superclass Gem::LoadError to catch all types of load errors.
class MissingSpecError < Gem::LoadError
+
def initialize(name, requirement)
@name = name
@requirement = requirement
@@ -41,6 +44,7 @@ module Gem
total = Gem::Specification.stubs.size
"Could not find '#{name}' (#{requirement}) among #{total} total gem(s)\n"
end
+
end
##
@@ -48,6 +52,7 @@ module Gem
# not the requested version. Instead of rescuing from this class, make sure to
# rescue from the superclass Gem::LoadError to catch all types of load errors.
class MissingSpecVersionError < MissingSpecError
+
attr_reader :specs
def initialize(name, requirement, specs)
@@ -64,6 +69,7 @@ module Gem
names = specs.map(&:full_name)
"Could not find '#{name}' (#{requirement}) - did find: [#{names.join ','}]\n"
end
+
end
# Raised when there are conflicting gem specs loaded
@@ -86,14 +92,15 @@ module Gem
@conflicts = conflicts
@name = target.name
- reason = conflicts.map { |act, dependencies|
+ reason = conflicts.map do |act, dependencies|
"#{act.full_name} conflicts with #{dependencies.join(", ")}"
- }.join ", "
+ end.join ", "
# TODO: improve message by saying who activated `con`
super("Unable to activate #{target.full_name}, because #{reason}")
end
+
end
class ErrorReason; end
@@ -143,6 +150,7 @@ module Gem
@platforms.size == 1 ? '' : 's',
@platforms.join(' ,')]
end
+
end
##
@@ -181,5 +189,6 @@ module Gem
# The "exception" alias allows you to call raise on a SourceFetchProblem.
alias exception error
+
end
end
diff --git a/lib/rubygems/exceptions.rb b/lib/rubygems/exceptions.rb
index a387cd390f..28ae3aa24e 100644
--- a/lib/rubygems/exceptions.rb
+++ b/lib/rubygems/exceptions.rb
@@ -19,6 +19,7 @@ class Gem::Exception < RuntimeError
extend Gem::Deprecate
deprecate :source_exception, :none, 2018, 12
+
end
class Gem::CommandLineError < Gem::Exception; end
@@ -53,14 +54,18 @@ end
# Raised when attempting to uninstall a gem that isn't in GEM_HOME.
class Gem::GemNotInHomeException < Gem::Exception
+
attr_accessor :spec
+
end
###
# Raised when removing a gem with the uninstall command fails
class Gem::UninstallError < Gem::Exception
+
attr_accessor :spec
+
end
class Gem::DocumentError < Gem::Exception; end
@@ -88,7 +93,9 @@ end
##
# Used to raise parsing and loading errors
class Gem::FormatException < Gem::Exception
+
attr_accessor :file_path
+
end
class Gem::GemNotFoundException < Gem::Exception; end
@@ -166,10 +173,12 @@ end
class Gem::InstallError < Gem::Exception; end
class Gem::RuntimeRequirementNotMetError < Gem::InstallError
+
attr_accessor :suggestion
def message
[suggestion, super].compact.join("\n\t")
end
+
end
##
diff --git a/lib/rubygems/ext/builder.rb b/lib/rubygems/ext/builder.rb
index f578e7feee..8276dd769a 100644
--- a/lib/rubygems/ext/builder.rb
+++ b/lib/rubygems/ext/builder.rb
@@ -240,7 +240,9 @@ EOF
FileUtils.mkdir_p @spec.extension_dir
- File.open destination, 'wb' do |io| io.puts output end
+ File.open destination, 'wb' do |io|
+ io.puts output
+ end
destination
end
diff --git a/lib/rubygems/ext/cmake_builder.rb b/lib/rubygems/ext/cmake_builder.rb
index ab226733d9..829b88d1bb 100644
--- a/lib/rubygems/ext/cmake_builder.rb
+++ b/lib/rubygems/ext/cmake_builder.rb
@@ -2,6 +2,7 @@
require 'rubygems/command'
class Gem::Ext::CmakeBuilder < Gem::Ext::Builder
+
def self.build(extension, dest_path, results, args=[], lib_dir=nil)
unless File.exist?('Makefile')
cmd = "cmake . -DCMAKE_INSTALL_PREFIX=#{dest_path}"
@@ -14,4 +15,5 @@ class Gem::Ext::CmakeBuilder < Gem::Ext::Builder
results
end
+
end
diff --git a/lib/rubygems/ext/ext_conf_builder.rb b/lib/rubygems/ext/ext_conf_builder.rb
index 5a2b3eb533..169da438ba 100644
--- a/lib/rubygems/ext/ext_conf_builder.rb
+++ b/lib/rubygems/ext/ext_conf_builder.rb
@@ -10,6 +10,7 @@ require 'tempfile'
require 'shellwords'
class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder
+
FileEntry = FileUtils::Entry_ # :nodoc:
def self.build(extension, dest_path, results, args=[], lib_dir=nil)
@@ -88,7 +89,7 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder
private
def self.get_relative_path(path)
- path[0..Dir.pwd.length-1] = '.' if path.start_with?(Dir.pwd)
+ path[0..Dir.pwd.length - 1] = '.' if path.start_with?(Dir.pwd)
path
end
diff --git a/lib/rubygems/gemcutter_utilities.rb b/lib/rubygems/gemcutter_utilities.rb
index c6ccc209c8..877205b619 100644
--- a/lib/rubygems/gemcutter_utilities.rb
+++ b/lib/rubygems/gemcutter_utilities.rb
@@ -63,7 +63,7 @@ module Gem::GemcutterUtilities
env_rubygems_host = nil if
env_rubygems_host and env_rubygems_host.empty?
- env_rubygems_host|| configured_host
+ env_rubygems_host || configured_host
end
end
@@ -116,7 +116,7 @@ module Gem::GemcutterUtilities
say "Don't have an account yet? " +
"Create one at #{sign_in_host}/sign_up"
- email = ask " Email: "
+ email = ask " Email: "
password = ask_for_password "Password: "
say "\n"
diff --git a/lib/rubygems/indexer.rb b/lib/rubygems/indexer.rb
index b97347177d..4d199868fb 100644
--- a/lib/rubygems/indexer.rb
+++ b/lib/rubygems/indexer.rb
@@ -131,7 +131,10 @@ class Gem::Indexer
marshal_name = File.join @quick_marshal_dir, spec_file_name
marshal_zipped = Gem.deflate Marshal.dump(spec)
- File.open marshal_name, 'wb' do |io| io.write marshal_zipped end
+
+ File.open marshal_name, 'wb' do |io|
+ io.write marshal_zipped
+ end
files << marshal_name
@@ -180,9 +183,9 @@ class Gem::Indexer
# Builds indices for RubyGems 1.2 and newer. Handles full, latest, prerelease
def build_modern_indices(specs)
- prerelease, released = specs.partition { |s|
+ prerelease, released = specs.partition do |s|
s.version.prerelease?
- }
+ end
latest_specs =
Gem::Specification._latest_specs specs
@@ -200,7 +203,7 @@ class Gem::Indexer
end
def map_gems_to_specs(gems)
- gems.map { |gemfile|
+ gems.map do |gemfile|
if File.size(gemfile) == 0
alert_warning "Skipping zero-length gem: #{gemfile}"
next
@@ -223,7 +226,7 @@ class Gem::Indexer
"\t#{e.backtrace.join "\n\t"}"].join("\n")
alert_error msg
end
- }.compact
+ end.compact
end
##
@@ -439,4 +442,5 @@ class Gem::Indexer
Marshal.dump specs_index, io
end
end
+
end
diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb
index 6cd073e11d..b64ba17be6 100644
--- a/lib/rubygems/installer.rb
+++ b/lib/rubygems/installer.rb
@@ -108,6 +108,7 @@ class Gem::Installer
end
class FakePackage
+
attr_accessor :spec
attr_accessor :dir_mode
@@ -125,12 +126,15 @@ class Gem::Installer
file = File.join destination_dir, file
next if File.exist? file
FileUtils.mkdir_p File.dirname(file)
- File.open file, 'w' do |fp| fp.puts "# #{file}" end
+ File.open file, 'w' do |fp|
+ fp.puts "# #{file}"
+ end
end
end
def copy_to(path)
end
+
end
##
@@ -467,7 +471,7 @@ class Gem::Installer
def generate_windows_script(filename, bindir)
if Gem.win_platform?
- script_name = filename + ".bat"
+ script_name = formatted_program_filename(filename) + ".bat"
script_path = File.join bindir, File.basename(script_name)
File.open script_path, 'w' do |file|
file.puts windows_stub_script(bindir, filename)
diff --git a/lib/rubygems/installer_test_case.rb b/lib/rubygems/installer_test_case.rb
index d6d16a9194..6fdc2d6337 100644
--- a/lib/rubygems/installer_test_case.rb
+++ b/lib/rubygems/installer_test_case.rb
@@ -58,6 +58,7 @@ class Gem::Installer
# Available through requiring rubygems/installer_test_case
attr_writer :wrappers
+
end
##
@@ -150,10 +151,15 @@ class Gem::InstallerTestCase < Gem::TestCase
FileUtils.mkdir_p 'bin'
FileUtils.mkdir_p 'lib'
FileUtils.mkdir_p File.join('ext', 'a')
+
File.open File.join('bin', 'executable'), 'w' do |f|
f.puts "raise 'ran executable'"
end
- File.open File.join('lib', 'code.rb'), 'w' do |f| f.puts '1' end
+
+ File.open File.join('lib', 'code.rb'), 'w' do |f|
+ f.puts '1'
+ end
+
File.open File.join('ext', 'a', 'mkrf_conf.rb'), 'w' do |f|
f << <<-EOF
File.open 'Rakefile', 'w' do |rf| rf.puts "task :default" end
diff --git a/lib/rubygems/local_remote_options.rb b/lib/rubygems/local_remote_options.rb
index 9fa256b08a..c940f50ad6 100644
--- a/lib/rubygems/local_remote_options.rb
+++ b/lib/rubygems/local_remote_options.rb
@@ -26,7 +26,7 @@ module Gem::LocalRemoteOptions
valid_uri_schemes = ["http", "https", "file", "s3"]
unless valid_uri_schemes.include?(uri.scheme)
- msg = "Invalid uri scheme for #{value}\nPreface URLs with one of #{valid_uri_schemes.map{|s| "#{s}://"}}"
+ msg = "Invalid uri scheme for #{value}\nPreface URLs with one of #{valid_uri_schemes.map{|s| "#{s}://"}}"
raise ArgumentError, msg
end
diff --git a/lib/rubygems/mock_gem_ui.rb b/lib/rubygems/mock_gem_ui.rb
index 92ec85625c..e6105d9d49 100644
--- a/lib/rubygems/mock_gem_ui.rb
+++ b/lib/rubygems/mock_gem_ui.rb
@@ -7,6 +7,7 @@ require 'rubygems/user_interaction'
# retrieval during tests.
class Gem::MockGemUi < Gem::StreamUI
+
##
# Raised when you haven't provided enough input to your MockGemUi
@@ -19,12 +20,14 @@ class Gem::MockGemUi < Gem::StreamUI
end
class TermError < RuntimeError
+
attr_reader :exit_code
def initialize(exit_code)
super
@exit_code = exit_code
end
+
end
class SystemExitException < RuntimeError; end
diff --git a/lib/rubygems/name_tuple.rb b/lib/rubygems/name_tuple.rb
index e948fb3d86..7cb38233eb 100644
--- a/lib/rubygems/name_tuple.rb
+++ b/lib/rubygems/name_tuple.rb
@@ -7,6 +7,7 @@
require 'rubygems/platform'
class Gem::NameTuple
+
def initialize(name, version, platform="ruby")
@name = name
@version = version
diff --git a/lib/rubygems/package.rb b/lib/rubygems/package.rb
index 8695b85fec..278ada8514 100644
--- a/lib/rubygems/package.rb
+++ b/lib/rubygems/package.rb
@@ -53,6 +53,7 @@ class Gem::Package
class Error < Gem::Exception; end
class FormatError < Error
+
attr_reader :path
def initialize(message, source = nil)
@@ -68,10 +69,12 @@ class Gem::Package
end
class PathError < Error
+
def initialize(destination, destination_dir)
super "installing into parent path %s of %s is not allowed" %
[destination, destination_dir]
end
+
end
class NonSeekableIO < Error; end
diff --git a/lib/rubygems/path_support.rb b/lib/rubygems/path_support.rb
index ed680d6553..2187766c41 100644
--- a/lib/rubygems/path_support.rb
+++ b/lib/rubygems/path_support.rb
@@ -5,6 +5,7 @@
# to the rest of RubyGems.
#
class Gem::PathSupport
+
##
# The default system path for managing Gems.
attr_reader :home
@@ -87,4 +88,5 @@ class Gem::PathSupport
path
end
end
+
end
diff --git a/lib/rubygems/platform.rb b/lib/rubygems/platform.rb
index f8fe4dad54..603d8ae8b8 100644
--- a/lib/rubygems/platform.rb
+++ b/lib/rubygems/platform.rb
@@ -202,4 +202,5 @@ class Gem::Platform
# This will be replaced with Gem::Platform::local.
CURRENT = 'current'.freeze
+
end
diff --git a/lib/rubygems/psych_tree.rb b/lib/rubygems/psych_tree.rb
index 6f399a289e..b4eebf1dcc 100644
--- a/lib/rubygems/psych_tree.rb
+++ b/lib/rubygems/psych_tree.rb
@@ -2,6 +2,7 @@
module Gem
if defined? ::Psych::Visitors
class NoAliasYAMLTree < Psych::Visitors::YAMLTree
+
def self.create
new({})
end unless respond_to? :create
@@ -27,6 +28,7 @@ module Gem
end
private :format_time
+
end
end
end
diff --git a/lib/rubygems/remote_fetcher.rb b/lib/rubygems/remote_fetcher.rb
index 69879df67c..32c65eada8 100644
--- a/lib/rubygems/remote_fetcher.rb
+++ b/lib/rubygems/remote_fetcher.rb
@@ -402,4 +402,5 @@ class Gem::RemoteFetcher
[id, secret]
end
+
end
diff --git a/lib/rubygems/request.rb b/lib/rubygems/request.rb
index d442f6534b..1ed2b8ad50 100644
--- a/lib/rubygems/request.rb
+++ b/lib/rubygems/request.rb
@@ -13,7 +13,7 @@ class Gem::Request
def self.create_with_proxy(uri, request_class, last_modified, proxy) # :nodoc:
cert_files = get_cert_files
proxy ||= get_proxy_from_env(uri.scheme)
- pool = ConnectionPools.new proxy_uri(proxy), cert_files
+ pool = ConnectionPools.new proxy_uri(proxy), cert_files
new(uri, request_class, last_modified, pool.pool_for(uri))
end
@@ -168,9 +168,10 @@ class Gem::Request
no_env_proxy = env_proxy.nil? || env_proxy.empty?
- return :no_proxy if scheme == 'https' && no_env_proxy
- return get_proxy_from_env 'http' if no_env_proxy and _scheme != 'http'
- return :no_proxy if no_env_proxy
+ if no_env_proxy
+ return (_scheme == 'https' || _scheme == 'http') ?
+ :no_proxy : get_proxy_from_env('http')
+ end
uri = URI(Gem::UriFormatter.new(env_proxy).normalize)
diff --git a/lib/rubygems/request/connection_pools.rb b/lib/rubygems/request/connection_pools.rb
index c02f083b63..7c273d5465 100644
--- a/lib/rubygems/request/connection_pools.rb
+++ b/lib/rubygems/request/connection_pools.rb
@@ -5,7 +5,9 @@ class Gem::Request::ConnectionPools # :nodoc:
@client = Net::HTTP
class << self
+
attr_accessor :client
+
end
def initialize(proxy_uri, cert_files)
@@ -40,7 +42,7 @@ class Gem::Request::ConnectionPools # :nodoc:
def get_no_proxy_from_env
env_no_proxy = ENV['no_proxy'] || ENV['NO_PROXY']
- return [] if env_no_proxy.nil? or env_no_proxy.empty?
+ return [] if env_no_proxy.nil? or env_no_proxy.empty?
env_no_proxy.split(/\s*,\s*/)
end
diff --git a/lib/rubygems/request/http_pool.rb b/lib/rubygems/request/http_pool.rb
index a85fc2bdf6..058094a209 100644
--- a/lib/rubygems/request/http_pool.rb
+++ b/lib/rubygems/request/http_pool.rb
@@ -6,6 +6,7 @@
# use it.
class Gem::Request::HTTPPool # :nodoc:
+
attr_reader :cert_files, :proxy_uri
def initialize(http_args, cert_files, proxy_uri)
diff --git a/lib/rubygems/request/https_pool.rb b/lib/rubygems/request/https_pool.rb
index 50f42d9e0d..1236079b7d 100644
--- a/lib/rubygems/request/https_pool.rb
+++ b/lib/rubygems/request/https_pool.rb
@@ -1,9 +1,11 @@
# frozen_string_literal: true
class Gem::Request::HTTPSPool < Gem::Request::HTTPPool # :nodoc:
+
private
def setup_connection(connection)
Gem::Request.configure_connection_for_https(connection, @cert_files)
super
end
+
end
diff --git a/lib/rubygems/request_set.rb b/lib/rubygems/request_set.rb
index 6017d15d13..4ac6ce0293 100644
--- a/lib/rubygems/request_set.rb
+++ b/lib/rubygems/request_set.rb
@@ -457,9 +457,9 @@ class Gem::RequestSet
node.spec.dependencies.each do |dep|
next if dep.type == :development and not @development
- match = @requests.find { |r|
+ match = @requests.find do |r|
dep.match? r.spec.name, r.spec.version, @prerelease
- }
+ end
unless match
next if dep.type == :development and @development_shallow
diff --git a/lib/rubygems/request_set/gem_dependency_api.rb b/lib/rubygems/request_set/gem_dependency_api.rb
index 3892e7aa5f..a4d803f915 100644
--- a/lib/rubygems/request_set/gem_dependency_api.rb
+++ b/lib/rubygems/request_set/gem_dependency_api.rb
@@ -43,11 +43,12 @@ class Gem::RequestSet::GemDependencyAPI
:mri_20 => %w[ruby],
:mri_21 => %w[ruby],
:rbx => %w[rbx],
- :ruby => %w[ruby rbx maglev],
- :ruby_18 => %w[ruby rbx maglev],
- :ruby_19 => %w[ruby rbx maglev],
- :ruby_20 => %w[ruby rbx maglev],
- :ruby_21 => %w[ruby rbx maglev],
+ :truffleruby => %w[truffleruby],
+ :ruby => %w[ruby rbx maglev truffleruby],
+ :ruby_18 => %w[ruby rbx maglev truffleruby],
+ :ruby_19 => %w[ruby rbx maglev truffleruby],
+ :ruby_20 => %w[ruby rbx maglev truffleruby],
+ :ruby_21 => %w[ruby rbx maglev truffleruby],
}.freeze
mswin = Gem::Platform.new 'x86-mswin32'
@@ -85,6 +86,7 @@ class Gem::RequestSet::GemDependencyAPI
:ruby_19 => Gem::Platform::RUBY,
:ruby_20 => Gem::Platform::RUBY,
:ruby_21 => Gem::Platform::RUBY,
+ :truffleruby => Gem::Platform::RUBY,
:x64_mingw => x64_mingw,
:x64_mingw_20 => x64_mingw,
:x64_mingw_21 => x64_mingw
@@ -126,6 +128,7 @@ class Gem::RequestSet::GemDependencyAPI
:ruby_19 => tilde_gt_1_9_0,
:ruby_20 => tilde_gt_2_0_0,
:ruby_21 => tilde_gt_2_1_0,
+ :truffleruby => gt_eq_0,
:x64_mingw => gt_eq_0,
:x64_mingw_20 => tilde_gt_2_0_0,
:x64_mingw_21 => tilde_gt_2_1_0,
@@ -440,7 +443,7 @@ Gem dependencies file #{@path} requires #{name} more than once.
Gem dependencies file #{@path} includes git reference for both ref and branch but only ref is used.
WARNING
end
- if (ref||branch) && tag
+ if (ref || branch) && tag
warn <<-WARNING
Gem dependencies file #{@path} includes git reference for both ref/branch and tag but only ref/branch is used.
WARNING
@@ -480,7 +483,7 @@ Gem dependencies file #{@path} includes git reference for both ref/branch and ta
def gem_group(name, options) # :nodoc:
g = options.delete :group
- all_groups = g ? Array(g) : []
+ all_groups = g ? Array(g) : []
groups = options.delete :groups
all_groups |= groups if groups
diff --git a/lib/rubygems/request_set/lockfile.rb b/lib/rubygems/request_set/lockfile.rb
index 1b374660f0..0776cf82e3 100644
--- a/lib/rubygems/request_set/lockfile.rb
+++ b/lib/rubygems/request_set/lockfile.rb
@@ -5,6 +5,7 @@
# constructed.
class Gem::RequestSet::Lockfile
+
##
# Raised when a lockfile cannot be parsed
@@ -35,6 +36,7 @@ class Gem::RequestSet::Lockfile
@path = path
super "#{message} (at line #{line} column #{column})"
end
+
end
##
@@ -79,7 +81,7 @@ class Gem::RequestSet::Lockfile
@gem_deps_file.untaint unless gem_deps_file.tainted?
- @platforms = []
+ @platforms = []
end
def add_DEPENDENCIES(out) # :nodoc:
@@ -153,7 +155,7 @@ class Gem::RequestSet::Lockfile
base = File.expand_path(base)
if dest.index(base) == 0
- offset = dest[base.size+1..-1]
+ offset = dest[base.size + 1..-1]
return '.' unless offset
@@ -233,6 +235,7 @@ class Gem::RequestSet::Lockfile
def requests
@set.sorted_requests
end
+
end
require 'rubygems/request_set/lockfile/tokenizer'
diff --git a/lib/rubygems/request_set/lockfile/parser.rb b/lib/rubygems/request_set/lockfile/parser.rb
index 0fe0405e32..1e9d2b12de 100644
--- a/lib/rubygems/request_set/lockfile/parser.rb
+++ b/lib/rubygems/request_set/lockfile/parser.rb
@@ -1,5 +1,6 @@
# frozen_string_literal: true
class Gem::RequestSet::Lockfile::Parser
+
###
# Parses lockfiles
@@ -327,9 +328,9 @@ class Gem::RequestSet::Lockfile::Parser
def pinned_requirement(name) # :nodoc:
requirement = Gem::Dependency.new name
- specification = @set.sets.flat_map { |set|
+ specification = @set.sets.flat_map do |set|
set.find_all(requirement)
- }.compact.first
+ end.compact.first
specification && specification.version
end
@@ -340,4 +341,5 @@ class Gem::RequestSet::Lockfile::Parser
def unget(token) # :nodoc:
@tokens.unshift token
end
+
end
diff --git a/lib/rubygems/request_set/lockfile/tokenizer.rb b/lib/rubygems/request_set/lockfile/tokenizer.rb
index bb69c85fb4..97396ec199 100644
--- a/lib/rubygems/request_set/lockfile/tokenizer.rb
+++ b/lib/rubygems/request_set/lockfile/tokenizer.rb
@@ -2,6 +2,7 @@
require 'rubygems/request_set/lockfile/parser'
class Gem::RequestSet::Lockfile::Tokenizer
+
Token = Struct.new :type, :value, :column, :line
EOF = Token.new :EOF
@@ -109,4 +110,5 @@ class Gem::RequestSet::Lockfile::Tokenizer
@tokens
end
+
end
diff --git a/lib/rubygems/requirement.rb b/lib/rubygems/requirement.rb
index 48f4b00d63..918404f2cd 100644
--- a/lib/rubygems/requirement.rb
+++ b/lib/rubygems/requirement.rb
@@ -2,10 +2,6 @@
require "rubygems/version"
require "rubygems/deprecate"
-# If we're being loaded after yaml was already required, then
-# load our yaml + workarounds now.
-Gem.load_yaml if defined? ::YAML
-
##
# A Requirement is a set of one or more version restrictions. It supports a
# few (<tt>=, !=, >, <, >=, <=, ~></tt>) different restriction operators.
@@ -14,6 +10,7 @@ Gem.load_yaml if defined? ::YAML
# together in RubyGems.
class Gem::Requirement
+
OPS = { #:nodoc:
"=" => lambda { |v, r| v == r },
"!=" => lambda { |v, r| v != r },
@@ -26,7 +23,7 @@ class Gem::Requirement
SOURCE_SET_REQUIREMENT = Struct.new(:for_lockfile).new "!" # :nodoc:
- quoted = OPS.keys.map { |k| Regexp.quote k }.join "|"
+ quoted = OPS.keys.map { |k| Regexp.quote k }.join "|"
PATTERN_RAW = "\\s*(#{quoted})?\\s*(#{Gem::Version::VERSION_PATTERN})\\s*".freeze # :nodoc:
##
@@ -156,11 +153,11 @@ class Gem::Requirement
def for_lockfile # :nodoc:
return if [DefaultRequirement] == @requirements
- list = requirements.sort_by { |_, version|
+ list = requirements.sort_by do |_, version|
version
- }.map { |op, version|
+ end.map do |op, version|
"#{op} #{version}"
- }.uniq
+ end.uniq
" (#{list.join ', '})"
end
@@ -305,11 +302,14 @@ class Gem::Requirement
l.first <=> r.first # then, sort by the operator (for stability)
end
end
+
end
class Gem::Version
+
# This is needed for compatibility with older yaml
# gemspecs.
Requirement = Gem::Requirement # :nodoc:
+
end
diff --git a/lib/rubygems/resolver.rb b/lib/rubygems/resolver.rb
index 8a72006ea8..d308f68f21 100644
--- a/lib/rubygems/resolver.rb
+++ b/lib/rubygems/resolver.rb
@@ -11,6 +11,7 @@ require 'rubygems/util/list'
# all the requirements.
class Gem::Resolver
+
require 'rubygems/resolver/molinillo'
##
@@ -234,11 +235,11 @@ class Gem::Resolver
groups = Hash.new { |hash, key| hash[key] = [] }
# create groups & sources in the same loop
- sources = possibles.map { |spec|
+ sources = possibles.map do |spec|
source = spec.source
groups[source] << spec
source
- }.uniq.reverse
+ end.uniq.reverse
activation_requests = []
diff --git a/lib/rubygems/resolver/activation_request.rb b/lib/rubygems/resolver/activation_request.rb
index b28e1bef32..78e8a46674 100644
--- a/lib/rubygems/resolver/activation_request.rb
+++ b/lib/rubygems/resolver/activation_request.rb
@@ -54,12 +54,12 @@ class Gem::Resolver::ActivationRequest
if @spec.respond_to? :sources
exception = nil
- path = @spec.sources.find{ |source|
+ path = @spec.sources.find do |source|
begin
source.download full_spec, path
rescue exception
end
- }
+ end
return path if path
raise exception if exception
diff --git a/lib/rubygems/resolver/best_set.rb b/lib/rubygems/resolver/best_set.rb
index cc91b65c0b..8a8c15d9a4 100644
--- a/lib/rubygems/resolver/best_set.rb
+++ b/lib/rubygems/resolver/best_set.rb
@@ -63,9 +63,9 @@ class Gem::Resolver::BestSet < Gem::Resolver::ComposedSet
uri = URI uri unless URI === uri
uri.query = nil
- raise error unless api_set = @sets.find { |set|
+ raise error unless api_set = @sets.find do |set|
Gem::Resolver::APISet === set and set.dep_uri == uri
- }
+ end
index_set = Gem::Resolver::IndexSet.new api_set.source
diff --git a/lib/rubygems/resolver/installer_set.rb b/lib/rubygems/resolver/installer_set.rb
index f3827ad4e9..ba14ee945d 100644
--- a/lib/rubygems/resolver/installer_set.rb
+++ b/lib/rubygems/resolver/installer_set.rb
@@ -55,9 +55,9 @@ class Gem::Resolver::InstallerSet < Gem::Resolver::Set
found = find_all request
- found.delete_if { |s|
+ found.delete_if do |s|
s.version.prerelease? and not s.local?
- } unless dependency.prerelease?
+ end unless dependency.prerelease?
found = found.select do |s|
Gem::Source::SpecificFile === s.source or
@@ -115,7 +115,7 @@ class Gem::Resolver::InstallerSet < Gem::Resolver::Set
def find_all(req)
res = []
- dep = req.dependency
+ dep = req.dependency
return res if @ignore_dependencies and
@always_install.none? { |spec| dep.match? spec }
diff --git a/lib/rubygems/resolver/lock_set.rb b/lib/rubygems/resolver/lock_set.rb
index 4002a963a4..4134b4dcaf 100644
--- a/lib/rubygems/resolver/lock_set.rb
+++ b/lib/rubygems/resolver/lock_set.rb
@@ -16,7 +16,7 @@ class Gem::Resolver::LockSet < Gem::Resolver::Set
Gem::Source::Lock.new source
end
- @specs = []
+ @specs = []
end
##
diff --git a/lib/rubygems/resolver/lock_specification.rb b/lib/rubygems/resolver/lock_specification.rb
index e29b567de4..5954507dba 100644
--- a/lib/rubygems/resolver/lock_specification.rb
+++ b/lib/rubygems/resolver/lock_specification.rb
@@ -71,9 +71,9 @@ class Gem::Resolver::LockSpecification < Gem::Resolver::Specification
# A specification constructed from the lockfile is returned
def spec
- @spec ||= Gem::Specification.find { |spec|
+ @spec ||= Gem::Specification.find do |spec|
spec.name == @name and spec.version == @version
- }
+ end
@spec ||= Gem::Specification.new do |s|
s.name = @name
diff --git a/lib/rubygems/resolver/requirement_list.rb b/lib/rubygems/resolver/requirement_list.rb
index 98d086e63c..cf0014b0bb 100644
--- a/lib/rubygems/resolver/requirement_list.rb
+++ b/lib/rubygems/resolver/requirement_list.rb
@@ -79,4 +79,5 @@ class Gem::Resolver::RequirementList
x = @exact[0,5]
x + @list[0,5 - x.size]
end
+
end
diff --git a/lib/rubygems/resolver/specification.rb b/lib/rubygems/resolver/specification.rb
index 7c1e9be702..e859d6659a 100644
--- a/lib/rubygems/resolver/specification.rb
+++ b/lib/rubygems/resolver/specification.rb
@@ -111,4 +111,5 @@ class Gem::Resolver::Specification
def local? # :nodoc:
false
end
+
end
diff --git a/lib/rubygems/resolver/stats.rb b/lib/rubygems/resolver/stats.rb
index 64b458f504..5f41940b1e 100644
--- a/lib/rubygems/resolver/stats.rb
+++ b/lib/rubygems/resolver/stats.rb
@@ -1,5 +1,6 @@
# frozen_string_literal: true
class Gem::Resolver::Stats
+
def initialize
@max_depth = 0
@max_requirements = 0
@@ -42,4 +43,5 @@ class Gem::Resolver::Stats
$stdout.printf PATTERN, "Backtracking #", @backtracking
$stdout.printf PATTERN, "Iteration #", @iterations
end
+
end
diff --git a/lib/rubygems/security/signer.rb b/lib/rubygems/security/signer.rb
index 34e86e921a..4e835e5b80 100644
--- a/lib/rubygems/security/signer.rb
+++ b/lib/rubygems/security/signer.rb
@@ -72,7 +72,7 @@ class Gem::Security::Signer
@options = DEFAULT_OPTIONS.merge(options)
unless @key
- default_key = File.join Gem.default_key_path
+ default_key = File.join Gem.default_key_path
@key = default_key if File.exist? default_key
end
diff --git a/lib/rubygems/server.rb b/lib/rubygems/server.rb
index 1453bf2323..97923ef698 100644
--- a/lib/rubygems/server.rb
+++ b/lib/rubygems/server.rb
@@ -607,13 +607,13 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
Gem::Specification.each do |spec|
total_file_count += spec.files.size
- deps = spec.dependencies.map { |dep|
+ deps = spec.dependencies.map do |dep|
{
"name" => dep.name,
"type" => dep.type,
"version" => dep.requirement.to_s,
}
- }
+ end
deps = deps.sort_by { |dep| [dep["name"].downcase, dep["version"]] }
deps.last["is_last"] = true unless deps.empty?
@@ -754,9 +754,9 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
# documentation - just put it underneath the main doc folder.
def show_rdoc_for_pattern(pattern, res)
- found_gems = Dir.glob("{#{@gem_dirs.join ','}}/doc/#{pattern}").select {|path|
+ found_gems = Dir.glob("{#{@gem_dirs.join ','}}/doc/#{pattern}").select do |path|
File.exist? File.join(path, 'rdoc/index.html')
- }
+ end
case found_gems.length
when 0
return false
@@ -875,4 +875,5 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
system("#{@launch} http://#{host}:#{@port}")
end
+
end
diff --git a/lib/rubygems/source_list.rb b/lib/rubygems/source_list.rb
index 83b689f78e..0622bfa17b 100644
--- a/lib/rubygems/source_list.rb
+++ b/lib/rubygems/source_list.rb
@@ -147,4 +147,5 @@ class Gem::SourceList
@sources.delete_if { |x| x.uri.to_s == source.to_s }
end
end
+
end
diff --git a/lib/rubygems/spec_fetcher.rb b/lib/rubygems/spec_fetcher.rb
index ca901cb8bf..4e62d7dd81 100644
--- a/lib/rubygems/spec_fetcher.rb
+++ b/lib/rubygems/spec_fetcher.rb
@@ -189,7 +189,7 @@ class Gem::SpecFetcher
max = gem_name.size / 2
names = available_specs(type).first.values.flatten(1)
- matches = names.map { |n|
+ matches = names.map do |n|
next unless n.match_platform?
distance = levenshtein_distance gem_name, n.name.downcase.tr('_-', '')
@@ -199,7 +199,7 @@ class Gem::SpecFetcher
return [n.name] if distance == 0
[n.name, distance]
- }.compact
+ end.compact
matches = if matches.empty? && type != :prerelease
suggest_gems_from_name gem_name, :prerelease
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb
index 0215f4aa66..6e1246c920 100644
--- a/lib/rubygems/specification.rb
+++ b/lib/rubygems/specification.rb
@@ -85,14 +85,14 @@ class Gem::Specification < Gem::BasicSpecification
'Deprecated "test_suite_file" in favor of the new, but equivalent, "test_files"',
'"test_file=x" is a shortcut for "test_files=[x]"'
],
- 2 => [
+ 2 => [
'Added "required_rubygems_version"',
'Now forward-compatible with future versions',
],
- 3 => [
+ 3 => [
'Added Fixnum validation to the specification_version'
],
- 4 => [
+ 4 => [
'Added sandboxed freeform metadata to the specification version.'
]
}.freeze
@@ -183,9 +183,9 @@ class Gem::Specification < Gem::BasicSpecification
@@attributes = @@default_value.keys.sort_by { |s| s.to_s }
@@array_attributes = @@default_value.reject { |k,v| v != [] }.keys
- @@nil_attributes, @@non_nil_attributes = @@default_value.keys.partition { |k|
+ @@nil_attributes, @@non_nil_attributes = @@default_value.keys.partition do |k|
@@default_value[k].nil?
- }
+ end
@@stubs_by_name = {}
@@ -792,11 +792,11 @@ class Gem::Specification < Gem::BasicSpecification
private_class_method :installed_stubs
def self.map_stubs(dirs, pattern) # :nodoc:
- dirs.flat_map { |dir|
+ dirs.flat_map do |dir|
base_dir = File.dirname dir
gems_dir = File.join base_dir, "gems"
gemspec_stubs_in(dir, pattern) { |path| yield path, base_dir, gems_dir }
- }
+ end
end
private_class_method :map_stubs
@@ -854,11 +854,11 @@ class Gem::Specification < Gem::BasicSpecification
end
def self._resort!(specs) # :nodoc:
- specs.sort! { |a, b|
+ specs.sort! do |a, b|
names = a.name <=> b.name
next names if names.nonzero?
b.version <=> a.version
- }
+ end
end
##
@@ -974,9 +974,9 @@ class Gem::Specification < Gem::BasicSpecification
# Return the directories that Specification uses to find specs.
def self.dirs
- @@dirs ||= Gem.path.collect { |dir|
+ @@dirs ||= Gem.path.collect do |dir|
File.join dir.dup.untaint, "specifications"
- }
+ end
end
##
@@ -1038,10 +1038,10 @@ class Gem::Specification < Gem::BasicSpecification
def self.find_by_path(path)
path = path.dup.freeze
- spec = @@spec_with_requirable_file[path] ||= (stubs.find { |s|
+ spec = @@spec_with_requirable_file[path] ||= (stubs.find do |s|
next unless Gem::BundlerVersionFinder.compatible?(s)
s.contains_requirable_file? path
- } || NOT_FOUND)
+ end || NOT_FOUND)
spec.to_spec
end
@@ -1050,18 +1050,18 @@ class Gem::Specification < Gem::BasicSpecification
# amongst the specs that are not activated.
def self.find_inactive_by_path(path)
- stub = stubs.find { |s|
+ stub = stubs.find do |s|
next if s.activated?
next unless Gem::BundlerVersionFinder.compatible?(s)
s.contains_requirable_file? path
- }
+ end
stub && stub.to_spec
end
def self.find_active_stub_by_path(path)
- stub = @@active_stub_with_requirable_file[path] ||= (stubs.find { |s|
+ stub = @@active_stub_with_requirable_file[path] ||= (stubs.find do |s|
s.activated? and s.contains_requirable_file? path
- } || NOT_FOUND)
+ end || NOT_FOUND)
stub.this
end
@@ -1142,10 +1142,10 @@ class Gem::Specification < Gem::BasicSpecification
result[spec.name][spec.platform] = spec
end
- result.map(&:last).map(&:values).flatten.reject { |spec|
+ result.map(&:last).map(&:values).flatten.reject do |spec|
minimum = native[spec.name]
minimum && spec.version < minimum
- }.sort_by{ |tup| tup.name }
+ end.sort_by{ |tup| tup.name }
end
##
@@ -1311,6 +1311,8 @@ class Gem::Specification < Gem::BasicSpecification
# Load custom marshal format, re-initializing defaults as needed
def self._load(str)
+ Gem.load_yaml
+
array = Marshal.load str
spec = Gem::Specification.new
@@ -1678,12 +1680,12 @@ class Gem::Specification < Gem::BasicSpecification
def conflicts
conflicts = {}
- self.runtime_dependencies.each { |dep|
+ self.runtime_dependencies.each do |dep|
spec = Gem.loaded_specs[dep.name]
if spec and not spec.satisfies_requirement? dep
(conflicts[spec] ||= []) << dep
end
- }
+ end
env_req = Gem.env_requirement(name)
(conflicts[self] ||= []) << env_req unless env_req.satisfied_by? version
conflicts
@@ -1693,9 +1695,9 @@ class Gem::Specification < Gem::BasicSpecification
# return true if there will be conflict when spec if loaded together with the list of specs.
def conficts_when_loaded_with?(list_of_specs) # :nodoc:
- result = list_of_specs.any? { |spec|
+ result = list_of_specs.any? do |spec|
spec.dependencies.any? { |dep| dep.runtime? && (dep.name == name) && !satisfies_requirement?(dep) }
- }
+ end
result
end
@@ -1704,14 +1706,14 @@ class Gem::Specification < Gem::BasicSpecification
def has_conflicts?
return true unless Gem.env_requirement(name).satisfied_by?(version)
- self.dependencies.any? { |dep|
+ self.dependencies.any? do |dep|
if dep.runtime?
spec = Gem.loaded_specs[dep.name]
spec and not spec.satisfies_requirement? dep
else
false
end
- }
+ end
end
# The date this gem was created.
@@ -2591,6 +2593,8 @@ class Gem::Specification < Gem::BasicSpecification
end
def to_yaml(opts = {}) # :nodoc:
+ Gem.load_yaml
+
# Because the user can switch the YAML engine behind our
# back, we have to check again here to make sure that our
# psych code was properly loaded, and load it if not.
diff --git a/lib/rubygems/specification_policy.rb b/lib/rubygems/specification_policy.rb
index 4b79c1ac61..a4c6888cd1 100644
--- a/lib/rubygems/specification_policy.rb
+++ b/lib/rubygems/specification_policy.rb
@@ -2,6 +2,7 @@ require 'delegate'
require 'uri'
class Gem::SpecificationPolicy < SimpleDelegator
+
VALID_NAME_PATTERN = /\A[a-zA-Z0-9\.\-\_]+\z/.freeze # :nodoc:
SPECIAL_CHARACTERS = /\A[#{Regexp.escape('.-_')}]+/.freeze # :nodoc:
@@ -300,7 +301,7 @@ duplicate dependency on #{dep}, (#{prev.requirement}) use:
end
def validate_licenses
- licenses.each { |license|
+ licenses.each do |license|
if license.length > 64
error "each license must be 64 characters or less"
end
@@ -314,7 +315,7 @@ http://spdx.org/licenses or '#{Gem::Licenses::NONSTANDARD}' for a nonstandard li
message += "Did you mean #{suggestions.map { |s| "'#{s}'"}.join(', ')}?\n" unless suggestions.nil?
warning(message)
end
- }
+ end
warning <<-warning if licenses.empty?
licenses is empty, but is recommended. Use a license identifier from
@@ -404,4 +405,5 @@ http://spdx.org/licenses or '#{Gem::Licenses::NONSTANDARD}' for a nonstandard li
def help_text # :nodoc:
"See http://guides.rubygems.org/specification-reference/ for help"
end
+
end
diff --git a/lib/rubygems/stub_specification.rb b/lib/rubygems/stub_specification.rb
index 022da9185d..e2f6e245e7 100644
--- a/lib/rubygems/stub_specification.rb
+++ b/lib/rubygems/stub_specification.rb
@@ -5,6 +5,7 @@
# information.
class Gem::StubSpecification < Gem::BasicSpecification
+
# :nodoc:
PREFIX = "# stub: ".freeze
@@ -12,6 +13,7 @@ class Gem::StubSpecification < Gem::BasicSpecification
OPEN_MODE = 'r:UTF-8:-'.freeze
class StubLine # :nodoc: all
+
attr_reader :name, :version, :platform, :require_paths, :extensions,
:full_name
@@ -50,10 +52,11 @@ class Gem::StubSpecification < Gem::BasicSpecification
end
path_list = parts.last
- @require_paths = REQUIRE_PATH_LIST[path_list] || path_list.split("\0".freeze).map! { |x|
+ @require_paths = REQUIRE_PATH_LIST[path_list] || path_list.split("\0".freeze).map! do |x|
REQUIRE_PATHS[x] || x
- }
+ end
end
+
end
def self.default_gemspec_stub(filename, base_dir, gems_dir)
diff --git a/lib/rubygems/syck_hack.rb b/lib/rubygems/syck_hack.rb
index 051483eac8..0d87c71df4 100644
--- a/lib/rubygems/syck_hack.rb
+++ b/lib/rubygems/syck_hack.rb
@@ -40,11 +40,13 @@ module YAML # :nodoc:
# should.
module Syck
class DefaultKey
+
remove_method :to_s rescue nil
def to_s
'='
end
+
end
end
diff --git a/lib/rubygems/test_case.rb b/lib/rubygems/test_case.rb
index 783e8956a1..5f2bbd7b86 100644
--- a/lib/rubygems/test_case.rb
+++ b/lib/rubygems/test_case.rb
@@ -1,12 +1,6 @@
# frozen_string_literal: true
# TODO: $SAFE = 1
-begin
- gem 'minitest', '~> 5.0'
-rescue NoMethodError, Gem::LoadError
- # for ruby tests
-end
-
if defined? Gem::QuickLoader
Gem::QuickLoader.load_full_rubygems_library
else
@@ -23,7 +17,7 @@ if File.exist?(bundler_gemspec)
end
begin
- gem 'minitest'
+ gem 'minitest', '~> 5.0'
rescue Gem::LoadError
end
@@ -115,6 +109,8 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
attr_accessor :uri # :nodoc:
+ TEST_PATH = ENV.fetch('RUBYGEMS_TEST_PATH', File.expand_path('../../../test/rubygems', __FILE__))
+
def assert_activate(expected, *specs)
specs.each do |spec|
case spec
@@ -191,19 +187,19 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
def assert_contains_make_command(target, output, msg = nil)
if output.match(/\n/)
- msg = message(msg) {
+ msg = message(msg) do
'Expected output containing make command "%s": %s' % [
('%s %s' % [make_command, target]).rstrip,
output.inspect
]
- }
+ end
else
- msg = message(msg) {
+ msg = message(msg) do
'Expected make command "%s": %s' % [
('%s %s' % [make_command, target]).rstrip,
output.inspect
]
- }
+ end
end
assert scan_make_command_lines(output).any? { |line|
@@ -260,7 +256,7 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
@fetcher = nil
if Gem::USE_BUNDLER_FOR_GEMDEPS
- Bundler.ui = Bundler::UI::Silent.new
+ Bundler.ui = Bundler::UI::Silent.new
end
@back_ui = Gem::DefaultUserInteraction.ui
@ui = Gem::MockGemUi.new
@@ -316,7 +312,7 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
Gem.ensure_gem_subdirectories @gemhome
@orig_LOAD_PATH = $LOAD_PATH.dup
- $LOAD_PATH.map! { |s|
+ $LOAD_PATH.map! do |s|
expand_path = File.expand_path(s)
if expand_path != s
expand_path.untaint
@@ -327,7 +323,7 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
s = expand_path
end
s
- }
+ end
Dir.chdir @tempdir
@@ -599,11 +595,11 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
def uninstall_gem(spec)
require 'rubygems/uninstaller'
- Class.new(Gem::Uninstaller) {
+ Class.new(Gem::Uninstaller) do
def ask_if_ok(spec)
true
end
- }.new(spec.name, :executables => true, :user_install => true).uninstall
+ end.new(spec.name, :executables => true, :user_install => true).uninstall
end
##
@@ -612,7 +608,11 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
def create_tmpdir
tmpdir = nil
- Dir.chdir Dir.tmpdir do tmpdir = Dir.pwd end # HACK OSX /private/tmp
+
+ Dir.chdir Dir.tmpdir do
+ tmpdir = Dir.pwd
+ end # HACK OSX /private/tmp
+
tmpdir = File.join tmpdir, "test_rubygems_#{$$}"
FileUtils.mkdir_p tmpdir
return tmpdir
@@ -723,7 +723,10 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
spec.files.each do |file|
next if File.exist? file
FileUtils.mkdir_p File.dirname(file)
- File.open file, 'w' do |fp| fp.puts "# #{file}" end
+
+ File.open file, 'w' do |fp|
+ fp.puts "# #{file}"
+ end
end
use_ui Gem::MockGemUi.new do
@@ -751,6 +754,11 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
Gem::Specification.reset
end
+ def util_clear_default_gems
+ FileUtils.rm_rf @default_spec_dir
+ FileUtils.mkdir @default_spec_dir
+ end
+
##
# Install the provided specs
@@ -1017,7 +1025,7 @@ Also, a list:
s.add_dependency 'x', '>= 1'
end
- @pl1 = quick_gem 'pl', '1' do |s| # l for legacy
+ @pl1 = quick_gem 'pl', '1' do |s| # l for legacy
s.files = %w[lib/code.rb]
s.require_paths = %w[lib]
s.platform = Gem::Platform.new 'i386-linux'
@@ -1339,6 +1347,7 @@ Also, a list:
end
class << self
+
# :nodoc:
##
# Return the join path, with escaping backticks, dollars, and
@@ -1352,12 +1361,12 @@ Also, a list:
"\"#{path.gsub(/[`$"]/, '\\&')}\""
end
end
+
end
@@ruby = rubybin
- gempath = File.expand_path('../../../test/rubygems', __FILE__)
- @@good_rake = "#{rubybin} #{escape_path(gempath, 'good_rake.rb')}"
- @@bad_rake = "#{rubybin} #{escape_path(gempath, 'bad_rake.rb')}"
+ @@good_rake = "#{rubybin} #{escape_path(TEST_PATH, 'good_rake.rb')}"
+ @@bad_rake = "#{rubybin} #{escape_path(TEST_PATH, 'bad_rake.rb')}"
##
# Construct a new Gem::Dependency.
@@ -1526,6 +1535,7 @@ Also, a list:
def prefetch(reqs) # :nodoc:
end
+
end
##
@@ -1545,14 +1555,12 @@ Also, a list:
def self.cert_path(cert_name)
if 32 == (Time.at(2**32) rescue 32)
- cert_file =
- File.expand_path "../../../test/rubygems/#{cert_name}_cert_32.pem",
- __FILE__
+ cert_file = "#{TEST_PATH}/#{cert_name}_cert_32.pem"
return cert_file if File.exist? cert_file
end
- File.expand_path "../../../test/rubygems/#{cert_name}_cert.pem", __FILE__
+ "#{TEST_PATH}/#{cert_name}_cert.pem"
end
##
@@ -1570,13 +1578,13 @@ Also, a list:
# Returns the path to the key named +key_name+ from <tt>test/rubygems</tt>
def self.key_path(key_name)
- File.expand_path "../../../test/rubygems/#{key_name}_key.pem", __FILE__
+ "#{TEST_PATH}/#{key_name}_key.pem"
end
# :stopdoc:
# only available in RubyGems tests
- PRIVATE_KEY_PASSPHRASE = 'Foo bar'.freeze
+ 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 d531239812..069ecccabe 100644
--- a/lib/rubygems/test_utilities.rb
+++ b/lib/rubygems/test_utilities.rb
@@ -366,4 +366,5 @@ class TempIO < Tempfile
flush
Gem.read_binary path
end
+
end
diff --git a/lib/rubygems/text.rb b/lib/rubygems/text.rb
index 5d346b496b..f6817c06a2 100644
--- a/lib/rubygems/text.rb
+++ b/lib/rubygems/text.rb
@@ -65,12 +65,12 @@ module Gem::Text
x = nil
str1.each_char.each_with_index do |char1,i|
- e = i+1
+ e = i + 1
str2.each_char.each_with_index do |char2,j|
cost = (char1 == char2) ? 0 : 1
x = min3(
- d[j+1] + 1, # insertion
+ d[j + 1] + 1, # insertion
e + 1, # deletion
d[j] + cost # substitution
)
diff --git a/lib/rubygems/uninstaller.rb b/lib/rubygems/uninstaller.rb
index c213cf656e..fe423a7ebd 100644
--- a/lib/rubygems/uninstaller.rb
+++ b/lib/rubygems/uninstaller.rb
@@ -57,7 +57,7 @@ class Gem::Uninstaller
# Indicate if development dependencies should be checked when
# uninstalling. (default: false)
#
- @check_dev = options[:check_dev]
+ @check_dev = options[:check_dev]
if options[:force]
@force_all = true
@@ -134,7 +134,7 @@ class Gem::Uninstaller
elsif index >= 0 && index < list.size
uninstall_gem list[index]
else
- say "Error: must enter a number [1-#{list.size+1}]"
+ say "Error: must enter a number [1-#{list.size + 1}]"
end
else
uninstall_gem list.first
@@ -180,9 +180,9 @@ class Gem::Uninstaller
# Leave any executables created by other installed versions
# of this gem installed.
- list = Gem::Specification.find_all { |s|
+ list = Gem::Specification.find_all do |s|
s.name == spec.name && s.version != spec.version
- }
+ end
list.each do |s|
s.executables.each do |exe_name|
@@ -354,4 +354,5 @@ class Gem::Uninstaller
raise e
end
+
end
diff --git a/lib/rubygems/user_interaction.rb b/lib/rubygems/user_interaction.rb
index 03eac76ea8..ecd1454e2d 100644
--- a/lib/rubygems/user_interaction.rb
+++ b/lib/rubygems/user_interaction.rb
@@ -227,7 +227,7 @@ class Gem::StreamUI
@outs.puts question
list.each_with_index do |item, index|
- @outs.puts " #{index+1}. #{item}"
+ @outs.puts " #{index + 1}. #{item}"
end
@outs.print "> "
@@ -418,6 +418,7 @@ class Gem::StreamUI
def done
end
+
end
##
@@ -506,6 +507,7 @@ class Gem::StreamUI
def done
@out.puts @terminal_message
end
+
end
##
@@ -549,6 +551,7 @@ class Gem::StreamUI
def done
end
+
end
##
@@ -603,7 +606,9 @@ class Gem::StreamUI
@out.puts message
end
end
+
end
+
end
##
@@ -619,6 +624,7 @@ class Gem::ConsoleUI < Gem::StreamUI
def initialize
super STDIN, STDOUT, STDERR, true
end
+
end
##
@@ -651,4 +657,5 @@ class Gem::SilentUI < Gem::StreamUI
def progress_reporter(*args) # :nodoc:
SilentProgressReporter.new(@outs, *args)
end
+
end
diff --git a/lib/rubygems/util.rb b/lib/rubygems/util.rb
index b9e5dfc8c7..401e5609f7 100644
--- a/lib/rubygems/util.rb
+++ b/lib/rubygems/util.rb
@@ -28,7 +28,9 @@ module Gem::Util
zipped = StringIO.new(String.new, 'w')
zipped.set_encoding Encoding::BINARY
- Zlib::GzipWriter.wrap zipped do |io| io.write data end
+ Zlib::GzipWriter.wrap zipped do |io|
+ io.write data
+ end
zipped.string
end
diff --git a/lib/rubygems/util/licenses.rb b/lib/rubygems/util/licenses.rb
index 2a536575c0..ac0d3bb44e 100644
--- a/lib/rubygems/util/licenses.rb
+++ b/lib/rubygems/util/licenses.rb
@@ -2,6 +2,7 @@
require 'rubygems/text'
class Gem::Licenses
+
extend Gem::Text
NONSTANDARD = 'Nonstandard'.freeze
@@ -434,4 +435,5 @@ class Gem::Licenses
return unless lowest < license.size
by_distance[lowest]
end
+
end
diff --git a/lib/rubygems/util/list.rb b/lib/rubygems/util/list.rb
index 33c40af4bb..7e4d6b5de6 100644
--- a/lib/rubygems/util/list.rb
+++ b/lib/rubygems/util/list.rb
@@ -1,6 +1,7 @@
# frozen_string_literal: true
module Gem
class List
+
include Enumerable
attr_accessor :value, :tail
@@ -33,5 +34,6 @@ module Gem
return List.new(value) unless list
List.new value, list
end
+
end
end
diff --git a/lib/rubygems/validator.rb b/lib/rubygems/validator.rb
index f00021daa9..7ed0a1f80f 100644
--- a/lib/rubygems/validator.rb
+++ b/lib/rubygems/validator.rb
@@ -25,7 +25,7 @@ class Gem::Validator
installed_files = []
Find.find gem_directory do |file_name|
- fn = file_name[gem_directory.size..file_name.size-1].sub(/^\//, "")
+ fn = file_name[gem_directory.size..file_name.size - 1].sub(/^\//, "")
installed_files << fn unless
fn =~ /CVS/ || fn.empty? || File.directory?(file_name)
end
@@ -91,17 +91,17 @@ class Gem::Validator
File.open gem_path, Gem.binary_mode do |file|
package = Gem::Package.new gem_path
- good, gone = package.contents.partition { |file_name|
+ good, gone = package.contents.partition do |file_name|
File.exist? File.join(gem_directory, file_name)
- }
+ end
gone.sort.each do |path|
errors[gem_name][path] = "Missing file"
end
- good, unreadable = good.partition { |file_name|
+ good, unreadable = good.partition do |file_name|
File.readable? File.join(gem_directory, file_name)
- }
+ end
unreadable.sort.each do |path|
errors[gem_name][path] = "Unreadable file"
@@ -141,4 +141,5 @@ class Gem::Validator
errors
end
+
end
diff --git a/lib/rubygems/version.rb b/lib/rubygems/version.rb
index f2f10569e8..c23b157708 100644
--- a/lib/rubygems/version.rb
+++ b/lib/rubygems/version.rb
@@ -150,6 +150,7 @@
# a zero to give a sensible result.
class Gem::Version
+
autoload :Requirement, 'rubygems/requirement'
include Comparable
@@ -395,4 +396,5 @@ class Gem::Version
numeric_segments = string_segments.slice!(0, string_start || string_segments.size)
return numeric_segments, string_segments
end
+
end
diff --git a/test/rubygems/plugin/load/rubygems_plugin.rb b/test/rubygems/plugin/load/rubygems_plugin.rb
index 7cc6bef90b..85a6851ace 100644
--- a/test/rubygems/plugin/load/rubygems_plugin.rb
+++ b/test/rubygems/plugin/load/rubygems_plugin.rb
@@ -1,4 +1,6 @@
# frozen_string_literal: true
class TestGem
+
TEST_PLUGIN_LOAD = :loaded
+
end
diff --git a/test/rubygems/test_deprecate.rb b/test/rubygems/test_deprecate.rb
index fab4f33b86..b92bd1c3da 100644
--- a/test/rubygems/test_deprecate.rb
+++ b/test/rubygems/test_deprecate.rb
@@ -45,6 +45,7 @@ class TestDeprecate < Gem::TestCase
end
class Thing
+
extend Gem::Deprecate
attr_accessor :message
def foo
@@ -54,6 +55,7 @@ class TestDeprecate < Gem::TestCase
@message = "bar"
end
deprecate :foo, :bar, 2099, 3
+
end
def test_deprecated_method_calls_the_old_method
@@ -74,4 +76,5 @@ class TestDeprecate < Gem::TestCase
assert_match(/Thing#foo is deprecated; use bar instead\./, err)
assert_match(/on or after 2099-03-01/, err)
end
+
end
diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb
index c913f30e27..b2f718bf1a 100644
--- a/test/rubygems/test_gem.rb
+++ b/test/rubygems/test_gem.rb
@@ -14,7 +14,6 @@ $LOAD_PATH.map! do |path|
end
class TestGem < Gem::TestCase
- RUBY_INSTALL_NAME = RbConfig::CONFIG['RUBY_INSTALL_NAME']
PLUGINS_LOADED = [] # rubocop:disable Style/MutableConstant
@@ -151,35 +150,40 @@ class TestGem < Gem::TestCase
end
def test_self_install_permissions_with_format_executable
- @format_executable = true
- assert_self_install_permissions
+ assert_self_install_permissions(format_executable: true)
+ end
+
+ def test_self_install_permissions_with_format_executable_and_non_standard_ruby_install_name
+ Gem::Installer.exec_format = nil
+ ruby_install_name 'ruby27' do
+ assert_self_install_permissions(format_executable: true)
+ end
+ ensure
+ Gem::Installer.exec_format = nil
end
- def assert_self_install_permissions
+ def assert_self_install_permissions(format_executable: false)
mask = win_platform? ? 0700 : 0777
options = {
:dir_mode => 0500,
- :prog_mode => 0510,
+ :prog_mode => win_platform? ? 0410 : 0510,
:data_mode => 0640,
:wrappers => true,
- :format_executable => !!(@format_executable if defined?(@format_executable))
+ :format_executable => format_executable
}
Dir.chdir @tempdir do
Dir.mkdir 'bin'
- File.open 'bin/foo.cmd', 'w' do |fp|
- fp.chmod(0755)
- fp.puts 'p'
- end
-
Dir.mkdir 'data'
- File.open 'data/foo.txt', 'w' do |fp|
- fp.puts 'blah'
- end
+
+ File.write 'bin/foo', "#!/usr/bin/env ruby\n"
+ File.chmod 0755, 'bin/foo'
+
+ File.write 'data/foo.txt', "blah\n"
spec_fetcher do |f|
f.gem 'foo', 1 do |s|
- s.executables = ['foo.cmd']
- s.files = %w[bin/foo.cmd data/foo.txt]
+ s.executables = ['foo']
+ s.files = %w[bin/foo data/foo.txt]
end
end
Gem.install 'foo', Gem::Requirement.default, options
@@ -188,19 +192,18 @@ class TestGem < Gem::TestCase
prog_mode = (options[:prog_mode] & mask).to_s(8)
dir_mode = (options[:dir_mode] & mask).to_s(8)
data_mode = (options[:data_mode] & mask).to_s(8)
- prog_name = 'foo.cmd'
- prog_name = RUBY_INSTALL_NAME.sub('ruby', 'foo.cmd') if options[:format_executable]
+ prog_name = 'foo'
+ prog_name = RbConfig::CONFIG['ruby_install_name'].sub('ruby', 'foo') if options[:format_executable]
expected = {
"bin/#{prog_name}" => prog_mode,
'gems/foo-1' => dir_mode,
'gems/foo-1/bin' => dir_mode,
'gems/foo-1/data' => dir_mode,
- 'gems/foo-1/bin/foo.cmd' => prog_mode,
+ 'gems/foo-1/bin/foo' => prog_mode,
'gems/foo-1/data/foo.txt' => data_mode,
}
- # below is for intermittent errors on Appveyor & Travis 2019-01,
- # see https://github.com/rubygems/rubygems/pull/2568
- sleep 0.2
+ # add Windows script
+ expected["bin/#{prog_name}.bat"] = mask.to_s(8) if win_platform?
result = {}
Dir.chdir @gemhome do
expected.each_key do |n|
@@ -209,7 +212,7 @@ class TestGem < Gem::TestCase
end
assert_equal(expected, result)
ensure
- File.chmod(0755, *Dir.glob(@gemhome+'/gems/**/').map {|path| path.untaint})
+ File.chmod(0755, *Dir.glob(@gemhome + '/gems/**/').map {|path| path.untaint})
end
def test_require_missing
@@ -413,7 +416,10 @@ class TestGem < Gem::TestCase
fp.puts 'blah'
end
- foo = util_spec 'foo' do |s| s.files = %w[data/foo.txt] end
+ foo = util_spec 'foo' do |s|
+ s.files = %w[data/foo.txt]
+ end
+
install_gem foo
end
@@ -631,7 +637,7 @@ class TestGem < Gem::TestCase
discover_path = File.join 'lib', 'sff', 'discover.rb'
- foo1, foo2 = %w(1 2).map { |version|
+ foo1, foo2 = %w(1 2).map do |version|
spec = quick_gem 'sff', version do |s|
s.files << discover_path
end
@@ -641,7 +647,7 @@ class TestGem < Gem::TestCase
end
spec
- }
+ end
Gem.refresh
@@ -663,7 +669,7 @@ class TestGem < Gem::TestCase
discover_path = File.join 'lib', 'sff', 'discover.rb'
- foo1, _ = %w(1 2).map { |version|
+ foo1, _ = %w(1 2).map do |version|
spec = quick_gem 'sff', version do |s|
s.files << discover_path
end
@@ -673,7 +679,7 @@ class TestGem < Gem::TestCase
end
spec
- }
+ end
Gem.refresh
write_file(File.join Dir.pwd, 'Gemfile') do |fp|
@@ -699,7 +705,7 @@ class TestGem < Gem::TestCase
discover_path = File.join 'lib', 'sff', 'discover.rb'
- _, foo2 = %w(1 2).map { |version|
+ _, foo2 = %w(1 2).map do |version|
spec = quick_gem 'sff', version do |s|
s.files << discover_path
end
@@ -709,7 +715,7 @@ class TestGem < Gem::TestCase
end
spec
- }
+ end
Gem.refresh
@@ -1087,7 +1093,7 @@ class TestGem < Gem::TestCase
def test_self_post_build
assert_equal 1, Gem.post_build_hooks.length
- Gem.post_build do |installer| end
+ Gem.post_build { |installer| }
assert_equal 2, Gem.post_build_hooks.length
end
@@ -1095,7 +1101,7 @@ class TestGem < Gem::TestCase
def test_self_post_install
assert_equal 1, Gem.post_install_hooks.length
- Gem.post_install do |installer| end
+ Gem.post_install { |installer| }
assert_equal 2, Gem.post_install_hooks.length
end
@@ -1103,7 +1109,7 @@ class TestGem < Gem::TestCase
def test_self_done_installing
assert_empty Gem.done_installing_hooks
- Gem.done_installing do |gems| end
+ Gem.done_installing { |gems| }
assert_equal 1, Gem.done_installing_hooks.length
end
@@ -1119,7 +1125,7 @@ class TestGem < Gem::TestCase
def test_self_post_uninstall
assert_equal 1, Gem.post_uninstall_hooks.length
- Gem.post_uninstall do |installer| end
+ Gem.post_uninstall { |installer| }
assert_equal 2, Gem.post_uninstall_hooks.length
end
@@ -1127,7 +1133,7 @@ class TestGem < Gem::TestCase
def test_self_pre_install
assert_equal 1, Gem.pre_install_hooks.length
- Gem.pre_install do |installer| end
+ Gem.pre_install { |installer| }
assert_equal 2, Gem.pre_install_hooks.length
end
@@ -1143,7 +1149,7 @@ class TestGem < Gem::TestCase
def test_self_pre_uninstall
assert_equal 1, Gem.pre_uninstall_hooks.length
- Gem.pre_uninstall do |installer| end
+ Gem.pre_uninstall { |installer| }
assert_equal 2, Gem.pre_uninstall_hooks.length
end
@@ -1328,7 +1334,7 @@ class TestGem < Gem::TestCase
a = util_spec "a", "1"
b = util_spec "b", "1", "c" => nil
c = util_spec "c", "2"
- d = util_spec "d", "1", {'e' => '= 1'}, "lib/d.rb"
+ d = util_spec "d", "1", {'e' => '= 1'}, "lib/d.rb"
e = util_spec "e", "1"
install_specs a, c, b, e, d
@@ -1943,4 +1949,5 @@ You may need to `gem install -g` to install missing gems
def util_cache_dir
File.join Gem.dir, "cache"
end
+
end
diff --git a/test/rubygems/test_gem_available_set.rb b/test/rubygems/test_gem_available_set.rb
index d4042c94f5..64ee9a36a9 100644
--- a/test/rubygems/test_gem_available_set.rb
+++ b/test/rubygems/test_gem_available_set.rb
@@ -68,7 +68,7 @@ class TestGemAvailableSet < Gem::TestCase
def test_best
a1, _ = util_gem 'a', '1'
- a2, _ = util_gem 'a', '2'
+ a2, _ = util_gem 'a', '2'
set = Gem::AvailableSet.new
set.add a1, @source
@@ -97,7 +97,7 @@ class TestGemAvailableSet < Gem::TestCase
def test_sorted_normal_versions
a1, _ = util_gem 'a', '1'
- a2, _ = util_gem 'a', '2'
+ a2, _ = util_gem 'a', '2'
set = Gem::AvailableSet.new
set.add a1, @source
@@ -127,4 +127,5 @@ class TestGemAvailableSet < Gem::TestCase
assert_equal [a3a, a2, a2a, a1, a1a], g
end
+
end
diff --git a/test/rubygems/test_gem_bundler_version_finder.rb b/test/rubygems/test_gem_bundler_version_finder.rb
index 3b63b89423..8e883bc719 100644
--- a/test/rubygems/test_gem_bundler_version_finder.rb
+++ b/test/rubygems/test_gem_bundler_version_finder.rb
@@ -2,7 +2,10 @@
require 'rubygems/test_case'
class TestGemBundlerVersionFinder < Gem::TestCase
+
def setup
+ super
+
@argv = ARGV.dup
@env = ENV.to_hash.clone
ENV.delete("BUNDLER_VERSION")
@@ -13,6 +16,8 @@ class TestGemBundlerVersionFinder < Gem::TestCase
ARGV.replace @argv
ENV.replace @env
$0 = @dollar_0
+
+ super
end
def bvf
@@ -123,4 +128,5 @@ class TestGemBundlerVersionFinder < Gem::TestCase
bvf.filter!(specs)
specs
end
+
end
diff --git a/test/rubygems/test_gem_command.rb b/test/rubygems/test_gem_command.rb
index 8caa9c6e2e..f3897c7102 100644
--- a/test/rubygems/test_gem_command.rb
+++ b/test/rubygems/test_gem_command.rb
@@ -3,7 +3,9 @@ require 'rubygems/test_case'
require 'rubygems/command'
class Gem::Command
+
public :parser
+
end
class TestGemCommand < Gem::TestCase
@@ -15,7 +17,7 @@ class TestGemCommand < Gem::TestCase
@common_options = Gem::Command.common_options.dup
Gem::Command.common_options.clear
- Gem::Command.common_options << [
+ Gem::Command.common_options << [
['-x', '--exe', 'Execute'], lambda do |*a|
@xopt = true
end
@@ -32,7 +34,7 @@ class TestGemCommand < Gem::TestCase
def test_self_add_specific_extra_args
added_args = %w[--all]
- @cmd.add_option '--all' do |v,o| end
+ @cmd.add_option('--all') { |v,o| }
Gem::Command.add_specific_extra_args @cmd_name, added_args
@@ -96,7 +98,7 @@ class TestGemCommand < Gem::TestCase
def test_invoke_with_bad_options
use_ui @ui do
- @cmd.when_invoked do true end
+ @cmd.when_invoked { true }
ex = assert_raises OptionParser::InvalidOption do
@cmd.invoke('-zzz')
@@ -107,7 +109,7 @@ class TestGemCommand < Gem::TestCase
end
def test_invoke_with_common_options
- @cmd.when_invoked do true end
+ @cmd.when_invoked { true }
use_ui @ui do
@cmd.invoke "-x"
@@ -195,6 +197,93 @@ class TestGemCommand < Gem::TestCase
assert_equal ['-h', 'command'], args
end
+ def test_deprecate_option_long_name
+ deprecate_msg = <<-EXPECTED
+WARNING: The \"--test\" option has been deprecated and will be removed in Rubygems 3.1, its use is discouraged.
+ EXPECTED
+
+ testCommand = Class.new(Gem::Command) do
+ def initialize
+ super('test', 'Gem::Command instance for testing')
+
+ add_option('-t', '--test', 'Test command') do |value, options|
+ options[:test] = true
+ end
+
+ deprecate_option(long_name: '--test', version: '3.1')
+ end
+
+ def execute
+ true
+ end
+ end
+
+ cmd = testCommand.new
+
+ use_ui @ui do
+ cmd.invoke("--test")
+ assert_equal deprecate_msg, @ui.error
+ end
+ end
+
+ def test_deprecate_option_no_version
+ deprecate_msg = <<-EXPECTED
+WARNING: The \"--test\" option has been deprecated and will be removed in future versions of Rubygems, its use is discouraged.
+ EXPECTED
+
+ testCommand = Class.new(Gem::Command) do
+ def initialize
+ super('test', 'Gem::Command instance for testing')
+
+ add_option('-t', '--test', 'Test command') do |value, options|
+ options[:test] = true
+ end
+
+ deprecate_option(long_name: '--test')
+ end
+
+ def execute
+ true
+ end
+ end
+
+ cmd = testCommand.new
+
+ use_ui @ui do
+ cmd.invoke("--test")
+ assert_equal deprecate_msg, @ui.error
+ end
+ end
+
+ def test_deprecate_option_short_name
+ deprecate_msg = <<-EXPECTED
+WARNING: The \"-t\" option has been deprecated and will be removed in Rubygems 3.5, its use is discouraged.
+ EXPECTED
+
+ testCommand = Class.new(Gem::Command) do
+ def initialize
+ super('test', 'Gem::Command instance for testing')
+
+ add_option('-t', '--test', 'Test command') do |value, options|
+ options[:test] = true
+ end
+
+ deprecate_option(short_name: '-t', version: '3.5')
+ end
+
+ def execute
+ true
+ end
+ end
+
+ cmd = testCommand.new
+
+ use_ui @ui do
+ cmd.invoke("-t")
+ assert_equal deprecate_msg, @ui.error
+ end
+ end
+
def test_show_lookup_failure_suggestions_local
correct = "non_existent_with_hint"
misspelled = "nonexistent_with_hint"
diff --git a/test/rubygems/test_gem_commands_cleanup_command.rb b/test/rubygems/test_gem_commands_cleanup_command.rb
index fdcd71ed8a..3494085a64 100644
--- a/test/rubygems/test_gem_commands_cleanup_command.rb
+++ b/test/rubygems/test_gem_commands_cleanup_command.rb
@@ -56,8 +56,13 @@ class TestGemCommandsCleanupCommand < Gem::TestCase
end
def test_execute_all_dependencies
- @b_1 = util_spec 'b', 1 do |s| s.add_dependency 'a', '1' end
- @b_2 = util_spec 'b', 2 do |s| s.add_dependency 'a', '2' end
+ @b_1 = util_spec 'b', 1 do |s|
+ s.add_dependency 'a', '1'
+ end
+
+ @b_2 = util_spec 'b', 2 do |s|
+ s.add_dependency 'a', '2'
+ end
install_gem @b_1
install_gem @b_2
@@ -71,8 +76,13 @@ class TestGemCommandsCleanupCommand < Gem::TestCase
end
def test_execute_dev_dependencies
- @b_1 = util_spec 'b', 1 do |s| s.add_development_dependency 'a', '1' end
- @c_1 = util_spec 'c', 1 do |s| s.add_development_dependency 'a', '2' end
+ @b_1 = util_spec 'b', 1 do |s|
+ s.add_development_dependency 'a', '1'
+ end
+
+ @c_1 = util_spec 'c', 1 do |s|
+ s.add_development_dependency 'a', '2'
+ end
install_gem @b_1
install_gem @c_1
@@ -85,8 +95,13 @@ class TestGemCommandsCleanupCommand < Gem::TestCase
end
def test_execute_without_dev_dependencies
- @b_1 = util_spec 'b', 1 do |s| s.add_development_dependency 'a', '1' end
- @c_1 = util_spec 'c', 1 do |s| s.add_development_dependency 'a', '2' end
+ @b_1 = util_spec 'b', 1 do |s|
+ s.add_development_dependency 'a', '1'
+ end
+
+ @c_1 = util_spec 'c', 1 do |s|
+ s.add_development_dependency 'a', '2'
+ end
install_gem @b_1
install_gem @c_1
@@ -263,4 +278,5 @@ class TestGemCommandsCleanupCommand < Gem::TestCase
assert_path_exists d_1.gem_dir
assert_path_exists d_2.gem_dir
end
+
end
diff --git a/test/rubygems/test_gem_commands_environment_command.rb b/test/rubygems/test_gem_commands_environment_command.rb
index 1451f03982..074df19e52 100644
--- a/test/rubygems/test_gem_commands_environment_command.rb
+++ b/test/rubygems/test_gem_commands_environment_command.rb
@@ -152,4 +152,5 @@ class TestGemCommandsEnvironmentCommand < Gem::TestCase
assert_equal "#{Gem.platforms.join File::PATH_SEPARATOR}\n", @ui.output
assert_equal '', @ui.error
end
+
end
diff --git a/test/rubygems/test_gem_commands_help_command.rb b/test/rubygems/test_gem_commands_help_command.rb
index 55bc797b28..8fcff6b1e7 100644
--- a/test/rubygems/test_gem_commands_help_command.rb
+++ b/test/rubygems/test_gem_commands_help_command.rb
@@ -7,6 +7,7 @@ require "rubygems/command_manager"
require File.expand_path('../rubygems_plugin', __FILE__)
class TestGemCommandsHelpCommand < Gem::TestCase
+
# previously this was calc'd in setup, but 1.8.7 had
# intermittent failures, but no issues with above require
PLUGIN = File.expand_path('../rubygems_plugin.rb', __FILE__)
@@ -75,4 +76,5 @@ class TestGemCommandsHelpCommand < Gem::TestCase
yield @ui.output, @ui.error
end
+
end
diff --git a/test/rubygems/test_gem_commands_info_command.rb b/test/rubygems/test_gem_commands_info_command.rb
index 83b18c5036..373fccceee 100644
--- a/test/rubygems/test_gem_commands_info_command.rb
+++ b/test/rubygems/test_gem_commands_info_command.rb
@@ -41,4 +41,5 @@ class TestGemCommandsInfoCommand < Gem::TestCase
assert_match %r%#{@gem.summary}\n%, @ui.output
assert_match "", @ui.error
end
+
end
diff --git a/test/rubygems/test_gem_commands_install_command.rb b/test/rubygems/test_gem_commands_install_command.rb
index 0976a31b50..21aa29822f 100644
--- a/test/rubygems/test_gem_commands_install_command.rb
+++ b/test/rubygems/test_gem_commands_install_command.rb
@@ -1142,4 +1142,59 @@ ERROR: Possible alternatives: non_existent_with_hint
assert_equal [:test, :development], @cmd.options[:without_groups]
end
+ def test_explain_platform_local
+ local = Gem::Platform.local
+ spec_fetcher do |fetcher|
+ fetcher.spec 'a', 2
+
+ fetcher.spec 'a', 2 do |s|
+ s.platform = local
+ end
+ end
+
+ @cmd.options[:explain] = true
+ @cmd.options[:args] = %w[a]
+
+ use_ui @ui do
+ assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
+ @cmd.execute
+ end
+ end
+
+ out = @ui.output.split "\n"
+
+ assert_equal "Gems to install:", out.shift
+ assert_equal " a-2-#{local}", out.shift
+ assert_empty out
+ end
+
+ def test_explain_platform_ruby
+ local = Gem::Platform.local
+ spec_fetcher do |fetcher|
+ fetcher.spec 'a', 2
+
+ fetcher.spec 'a', 2 do |s|
+ s.platform = local
+ end
+ end
+
+ # equivalent to --platform=ruby
+ Gem.platforms = [Gem::Platform::RUBY]
+
+ @cmd.options[:explain] = true
+ @cmd.options[:args] = %w[a]
+
+ use_ui @ui do
+ assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
+ @cmd.execute
+ end
+ end
+
+ out = @ui.output.split "\n"
+
+ assert_equal "Gems to install:", out.shift
+ assert_equal " a-2", out.shift
+ assert_empty out
+ end
+
end
diff --git a/test/rubygems/test_gem_commands_mirror.rb b/test/rubygems/test_gem_commands_mirror.rb
index 1a29755911..07ec9f3d0c 100644
--- a/test/rubygems/test_gem_commands_mirror.rb
+++ b/test/rubygems/test_gem_commands_mirror.rb
@@ -3,6 +3,7 @@ require 'rubygems/test_case'
require 'rubygems/commands/mirror_command'
class TestGemCommandsMirrorCommand < Gem::TestCase
+
def setup
super
diff --git a/test/rubygems/test_gem_commands_outdated_command.rb b/test/rubygems/test_gem_commands_outdated_command.rb
index 3b0220e84b..3c37e22a09 100644
--- a/test/rubygems/test_gem_commands_outdated_command.rb
+++ b/test/rubygems/test_gem_commands_outdated_command.rb
@@ -29,4 +29,5 @@ class TestGemCommandsOutdatedCommand < Gem::TestCase
assert_equal "foo (0.2 < 2.0)\n", @ui.output
assert_equal "", @ui.error
end
+
end
diff --git a/test/rubygems/test_gem_commands_pristine_command.rb b/test/rubygems/test_gem_commands_pristine_command.rb
index e4aa8d8656..c8e3bec88e 100644
--- a/test/rubygems/test_gem_commands_pristine_command.rb
+++ b/test/rubygems/test_gem_commands_pristine_command.rb
@@ -54,7 +54,10 @@ class TestGemCommandsPristineCommand < Gem::TestCase
end
def test_execute_all
- a = util_spec 'a' do |s| s.executables = %w[foo] end
+ a = util_spec 'a' do |s|
+ s.executables = %w[foo]
+ end
+
write_file File.join(@tempdir, 'bin', 'foo') do |fp|
fp.puts "#!/usr/bin/ruby"
end
@@ -116,7 +119,9 @@ class TestGemCommandsPristineCommand < Gem::TestCase
end
def test_execute_extensions_explicit
- a = util_spec 'a' do |s| s.extensions << 'ext/a/extconf.rb' end
+ a = util_spec 'a' do |s|
+ s.extensions << 'ext/a/extconf.rb'
+ end
ext_path = File.join @tempdir, 'ext', 'a', 'extconf.rb'
write_file ext_path do |io|
@@ -152,7 +157,9 @@ class TestGemCommandsPristineCommand < Gem::TestCase
end
def test_execute_no_extension
- a = util_spec 'a' do |s| s.extensions << 'ext/a/extconf.rb' end
+ a = util_spec 'a' do |s|
+ s.extensions << 'ext/a/extconf.rb'
+ end
ext_path = File.join @tempdir, 'ext', 'a', 'extconf.rb'
write_file ext_path do |io|
@@ -178,7 +185,9 @@ class TestGemCommandsPristineCommand < Gem::TestCase
end
def test_execute_with_extension_with_build_args
- a = util_spec 'a' do |s| s.extensions << 'ext/a/extconf.rb' end
+ a = util_spec 'a' do |s|
+ s.extensions << 'ext/a/extconf.rb'
+ end
ext_path = File.join @tempdir, 'ext', 'a', 'extconf.rb'
write_file ext_path do |io|
diff --git a/test/rubygems/test_gem_commands_push_command.rb b/test/rubygems/test_gem_commands_push_command.rb
index 592295d684..185d3cc1fc 100644
--- a/test/rubygems/test_gem_commands_push_command.rb
+++ b/test/rubygems/test_gem_commands_push_command.rb
@@ -28,11 +28,13 @@ class TestGemCommandsPushCommand < Gem::TestCase
@cmd = Gem::Commands::PushCommand.new
class << Gem
+
alias_method :orig_latest_rubygems_version, :latest_rubygems_version
def latest_rubygems_version
Gem.rubygems_version
end
+
end
end
@@ -40,8 +42,10 @@ class TestGemCommandsPushCommand < Gem::TestCase
super
class << Gem
+
remove_method :latest_rubygems_version
alias_method :latest_rubygems_version, :orig_latest_rubygems_version
+
end
end
@@ -132,7 +136,7 @@ class TestGemCommandsPushCommand < Gem::TestCase
ENV["RUBYGEMS_HOST"] = @host
Gem.configuration.disable_default_gem_server = true
@response = "Successfully registered gem: freewill (1.0.0)"
- @fetcher.data["#{@host}/api/v1/gems"] = [@response, 200, 'OK']
+ @fetcher.data["#{@host}/api/v1/gems"] = [@response, 200, 'OK']
send_battery
end
@@ -160,14 +164,14 @@ class TestGemCommandsPushCommand < Gem::TestCase
FileUtils.rm Gem.configuration.credentials_path
@response = "Successfully registered gem: freebird (1.0.1)"
- @fetcher.data["#{@host}/api/v1/gems"] = [@response, 200, 'OK']
+ @fetcher.data["#{@host}/api/v1/gems"] = [@response, 200, 'OK']
send_battery
end
def test_sending_gem
@response = "Successfully registered gem: freewill (1.0.0)"
- @fetcher.data["#{@host}/api/v1/gems"] = [@response, 200, 'OK']
+ @fetcher.data["#{@host}/api/v1/gems"] = [@response, 200, 'OK']
send_battery
end
@@ -195,7 +199,7 @@ class TestGemCommandsPushCommand < Gem::TestCase
FileUtils.rm Gem.configuration.credentials_path
@response = "Successfully registered gem: freebird (1.0.1)"
- @fetcher.data["#{@host}/api/v1/gems"] = [@response, 200, 'OK']
+ @fetcher.data["#{@host}/api/v1/gems"] = [@response, 200, 'OK']
send_battery
end
@@ -210,7 +214,7 @@ class TestGemCommandsPushCommand < Gem::TestCase
ENV["GEM_HOST_API_KEY"] = "PRIVKEY"
@response = "Successfully registered gem: freebird (1.0.1)"
- @fetcher.data["#{@host}/api/v1/gems"] = [@response, 200, 'OK']
+ @fetcher.data["#{@host}/api/v1/gems"] = [@response, 200, 'OK']
send_battery
end
@@ -237,7 +241,7 @@ class TestGemCommandsPushCommand < Gem::TestCase
FileUtils.rm Gem.configuration.credentials_path
@response = "Successfully registered gem: freebird (1.0.1)"
- @fetcher.data["#{@host}/api/v1/gems"] = [@response, 200, 'OK']
+ @fetcher.data["#{@host}/api/v1/gems"] = [@response, 200, 'OK']
send_battery
end
@@ -311,7 +315,7 @@ class TestGemCommandsPushCommand < Gem::TestCase
FileUtils.rm Gem.configuration.credentials_path
@response = "Successfully registered gem: freebird (1.0.1)"
- @fetcher.data["#{host}/api/v1/gems"] = [@response, 200, 'OK']
+ @fetcher.data["#{host}/api/v1/gems"] = [@response, 200, 'OK']
# do not set @host
use_ui(@ui) { @cmd.send_gem(@path) }
diff --git a/test/rubygems/test_gem_commands_query_command.rb b/test/rubygems/test_gem_commands_query_command.rb
index 7957689db4..71cf386026 100644
--- a/test/rubygems/test_gem_commands_query_command.rb
+++ b/test/rubygems/test_gem_commands_query_command.rb
@@ -19,6 +19,7 @@ module TestGemCommandsQueryCommandSetup
end
class TestGemCommandsQueryCommandWithInstalledGems < Gem::TestCase
+
include TestGemCommandsQueryCommandSetup
def test_execute
@@ -585,9 +586,11 @@ pl (1 i386-linux)
fetcher.spec 'a', '3.a'
end
end
+
end
class TestGemCommandsQueryCommandWithoutInstalledGems < Gem::TestCase
+
include TestGemCommandsQueryCommandSetup
def test_execute_platform
@@ -829,4 +832,5 @@ othergem (1.2.3)
fetcher.download 'a', '3.a'
end
end
+
end
diff --git a/test/rubygems/test_gem_commands_setup_command.rb b/test/rubygems/test_gem_commands_setup_command.rb
index 4f34112099..569091a8a7 100644
--- a/test/rubygems/test_gem_commands_setup_command.rb
+++ b/test/rubygems/test_gem_commands_setup_command.rb
@@ -23,17 +23,36 @@ class TestGemCommandsSetupCommand < Gem::TestCase
FileUtils.mkdir_p 'bin'
FileUtils.mkdir_p 'lib/rubygems/ssl_certs/rubygems.org'
- File.open 'bin/gem', 'w' do |io| io.puts '# gem' end
- File.open 'lib/rubygems.rb', 'w' do |io| io.puts '# rubygems.rb' end
- File.open 'lib/rubygems/test_case.rb', 'w' do |io| io.puts '# test_case.rb' end
- File.open 'lib/rubygems/ssl_certs/rubygems.org/foo.pem', 'w' do |io| io.puts 'PEM' end
+ File.open 'bin/gem', 'w' do
+ |io| io.puts '# gem'
+ end
+
+ File.open 'lib/rubygems.rb', 'w' do |io|
+ io.puts '# rubygems.rb'
+ end
+
+ File.open 'lib/rubygems/test_case.rb', 'w' do |io|
+ io.puts '# test_case.rb'
+ end
+
+ File.open 'lib/rubygems/ssl_certs/rubygems.org/foo.pem', 'w' do |io|
+ io.puts 'PEM'
+ end
FileUtils.mkdir_p 'bundler/exe'
FileUtils.mkdir_p 'bundler/lib/bundler'
- File.open 'bundler/exe/bundle', 'w' do |io| io.puts '# bundle' end
- File.open 'bundler/lib/bundler.rb', 'w' do |io| io.puts '# bundler.rb' end
- File.open 'bundler/lib/bundler/b.rb', 'w' do |io| io.puts '# b.rb' end
+ File.open 'bundler/exe/bundle', 'w' do |io|
+ io.puts '# bundle'
+ end
+
+ File.open 'bundler/lib/bundler.rb', 'w' do |io|
+ io.puts '# bundler.rb'
+ end
+
+ File.open 'bundler/lib/bundler/b.rb', 'w' do |io|
+ io.puts '# b.rb'
+ end
FileUtils.mkdir_p 'default/gems'
@@ -220,14 +239,29 @@ class TestGemCommandsSetupCommand < Gem::TestCase
FileUtils.mkdir_p lib_rubygems_defaults
FileUtils.mkdir_p lib_bundler
- File.open securerandom_rb, 'w' do |io| io.puts '# securerandom.rb' end
+ File.open securerandom_rb, 'w' do |io|
+ io.puts '# securerandom.rb'
+ end
+
+ File.open old_builder_rb, 'w' do |io|
+ io.puts '# builder.rb'
+ end
+
+ File.open old_format_rb, 'w' do |io|
+ io.puts '# format.rb'
+ end
- File.open old_builder_rb, 'w' do |io| io.puts '# builder.rb' end
- File.open old_format_rb, 'w' do |io| io.puts '# format.rb' end
- File.open old_bundler_c_rb, 'w' do |io| io.puts '# c.rb' end
+ File.open old_bundler_c_rb, 'w' do |io|
+ io.puts '# c.rb'
+ end
- File.open engine_defaults_rb, 'w' do |io| io.puts '# jruby.rb' end
- File.open os_defaults_rb, 'w' do |io| io.puts '# operating_system.rb' end
+ File.open engine_defaults_rb, 'w' do |io|
+ io.puts '# jruby.rb'
+ end
+
+ File.open os_defaults_rb, 'w' do |io|
+ io.puts '# operating_system.rb'
+ end
@cmd.remove_old_lib_files lib
diff --git a/test/rubygems/test_gem_commands_signin_command.rb b/test/rubygems/test_gem_commands_signin_command.rb
index afcb8d6d99..6276ea0264 100644
--- a/test/rubygems/test_gem_commands_signin_command.rb
+++ b/test/rubygems/test_gem_commands_signin_command.rb
@@ -26,7 +26,7 @@ class TestGemCommandsSigninCommand < Gem::TestCase
end
def test_execute_when_already_signed_in_with_same_host
- host = 'http://some-gemcutter-compatible-host.org'
+ host = 'http://some-gemcutter-compatible-host.org'
util_capture(nil, host) { @cmd.execute }
old_credentials = YAML.load_file Gem.configuration.credentials_path
@@ -38,10 +38,10 @@ class TestGemCommandsSigninCommand < Gem::TestCase
end
def test_execute_when_already_signed_in_with_different_host
- api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf04045xxxx'
+ api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf04045xxxx'
util_capture(nil, nil, api_key) { @cmd.execute }
- host = 'http://some-gemcutter-compatible-host.org'
+ host = 'http://some-gemcutter-compatible-host.org'
util_capture(nil, host, api_key) { @cmd.execute }
credentials = YAML.load_file Gem.configuration.credentials_path
@@ -95,4 +95,5 @@ class TestGemCommandsSigninCommand < Gem::TestCase
sign_in_ui
end
+
end
diff --git a/test/rubygems/test_gem_commands_sources_command.rb b/test/rubygems/test_gem_commands_sources_command.rb
index ad92c26073..1e58643566 100644
--- a/test/rubygems/test_gem_commands_sources_command.rb
+++ b/test/rubygems/test_gem_commands_sources_command.rb
@@ -40,9 +40,9 @@ class TestGemCommandsSourcesCommand < Gem::TestCase
fetcher.spec 'a', 1
end
- specs = Gem::Specification.map { |spec|
+ specs = Gem::Specification.map do |spec|
[spec.name, spec.version, spec.original_platform]
- }
+ end
specs_dump_gz = StringIO.new
Zlib::GzipWriter.wrap specs_dump_gz do |io|
@@ -167,9 +167,9 @@ source http://gems.example.com/ already present in the cache
fetcher.spec 'a', 1
end
- specs = Gem::Specification.map { |spec|
+ specs = Gem::Specification.map do |spec|
[spec.name, spec.version, spec.original_platform]
- }
+ end
specs_dump_gz = StringIO.new
Zlib::GzipWriter.wrap specs_dump_gz do |io|
diff --git a/test/rubygems/test_gem_commands_uninstall_command.rb b/test/rubygems/test_gem_commands_uninstall_command.rb
index 407d2451a6..efe5a768ef 100644
--- a/test/rubygems/test_gem_commands_uninstall_command.rb
+++ b/test/rubygems/test_gem_commands_uninstall_command.rb
@@ -54,7 +54,10 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
util_build_gem c
installer = util_installer c, @gemhome
- use_ui @ui do installer.install end
+
+ use_ui @ui do
+ installer.install
+ end
ui = Gem::MockGemUi.new
@@ -92,7 +95,9 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
# Evil hack to prevent false removal success
FileUtils.rm_f @executable
- File.open @executable, "wb+" do |f| f.puts "binary" end
+ File.open @executable, "wb+" do |f|
+ f.puts "binary"
+ end
@cmd.options[:executables] = true
@cmd.options[:args] = [@spec.name]
@@ -366,4 +371,5 @@ WARNING: Use your OS package manager to uninstall vendor gems
assert_empty @ui.output
assert_match %r!Error: unable to successfully uninstall '#{@spec.name}'!, @ui.error
end
+
end
diff --git a/test/rubygems/test_gem_commands_update_command.rb b/test/rubygems/test_gem_commands_update_command.rb
index 549e34c218..0247a03477 100644
--- a/test/rubygems/test_gem_commands_update_command.rb
+++ b/test/rubygems/test_gem_commands_update_command.rb
@@ -66,7 +66,9 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
def test_execute_system
spec_fetcher do |fetcher|
- fetcher.download 'rubygems-update', 9 do |s| s.files = %w[setup.rb] end
+ fetcher.download 'rubygems-update', 9 do |s|
+ s.files = %w[setup.rb]
+ end
end
@cmd.options[:args] = []
@@ -107,8 +109,13 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
def test_execute_system_multiple
spec_fetcher do |fetcher|
- fetcher.download 'rubygems-update', 8 do |s| s.files = %w[setup.rb] end
- fetcher.download 'rubygems-update', 9 do |s| s.files = %w[setup.rb] end
+ fetcher.download 'rubygems-update', 8 do |s|
+ s.files = %w[setup.rb]
+ end
+
+ fetcher.download 'rubygems-update', 9 do |s|
+ s.files = %w[setup.rb]
+ end
end
@cmd.options[:args] = []
@@ -128,8 +135,13 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
def test_execute_system_specific
spec_fetcher do |fetcher|
- fetcher.download 'rubygems-update', 8 do |s| s.files = %w[setup.rb] end
- fetcher.download 'rubygems-update', 9 do |s| s.files = %w[setup.rb] end
+ fetcher.download 'rubygems-update', 8 do |s|
+ s.files = %w[setup.rb]
+ end
+
+ fetcher.download 'rubygems-update', 9 do |s|
+ s.files = %w[setup.rb]
+ end
end
@cmd.options[:args] = []
@@ -149,8 +161,13 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
def test_execute_system_specifically_to_latest_version
spec_fetcher do |fetcher|
- fetcher.download 'rubygems-update', 8 do |s| s.files = %w[setup.rb] end
- fetcher.download 'rubygems-update', 9 do |s| s.files = %w[setup.rb] end
+ fetcher.download 'rubygems-update', 8 do |s|
+ s.files = %w[setup.rb]
+ end
+
+ fetcher.download 'rubygems-update', 9 do |s|
+ s.files = %w[setup.rb]
+ end
end
@cmd.options[:args] = []
@@ -387,7 +404,10 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
specs = spec_fetcher do |fetcher|
fetcher.spec 'a', 1
fetcher.spec 'a', 2
- fetcher.spec 'a', 2 do |s| s.platform = platform end
+
+ fetcher.spec 'a', 2 do |s|
+ s.platform = platform
+ end
end
expected = [
@@ -522,4 +542,5 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
assert_equal " a-2", out.shift
assert_empty out
end
+
end
diff --git a/test/rubygems/test_gem_commands_yank_command.rb b/test/rubygems/test_gem_commands_yank_command.rb
index d30c386aa6..666779a4ac 100644
--- a/test/rubygems/test_gem_commands_yank_command.rb
+++ b/test/rubygems/test_gem_commands_yank_command.rb
@@ -3,6 +3,7 @@ require 'rubygems/test_case'
require 'rubygems/commands/yank_command'
class TestGemCommandsYankCommand < Gem::TestCase
+
def setup
super
@@ -12,7 +13,7 @@ class TestGemCommandsYankCommand < Gem::TestCase
@fetcher = Gem::RemoteFetcher.fetcher
Gem.configuration.rubygems_api_key = 'key'
- Gem.configuration.api_keys[:KEY] = 'other'
+ Gem.configuration.api_keys[:KEY] = 'other'
end
def test_handle_options
diff --git a/test/rubygems/test_gem_config_file.rb b/test/rubygems/test_gem_config_file.rb
index 192699aaba..858d268d79 100644
--- a/test/rubygems/test_gem_config_file.rb
+++ b/test/rubygems/test_gem_config_file.rb
@@ -489,4 +489,5 @@ if you believe they were disclosed to a third party.
util_config_file
assert_equal(true, @cfg.disable_default_gem_server)
end
+
end
diff --git a/test/rubygems/test_gem_dependency_installer.rb b/test/rubygems/test_gem_dependency_installer.rb
index 74b7a6a83e..bf65cf9ed3 100644
--- a/test/rubygems/test_gem_dependency_installer.rb
+++ b/test/rubygems/test_gem_dependency_installer.rb
@@ -26,18 +26,22 @@ class TestGemDependencyInstaller < Gem::TestCase
end
def util_setup_gems
- @a1, @a1_gem = util_gem 'a', '1' do |s| s.executables << 'a_bin' end
+ @a1, @a1_gem = util_gem 'a', '1' do |s|
+ s.executables << 'a_bin'
+ end
+
@a1_pre, @a1_pre_gem = util_gem 'a', '1.a'
+
@b1, @b1_gem = util_gem 'b', '1' do |s|
s.add_dependency 'a'
s.add_development_dependency 'aa'
end
- @c1, @c1_gem = util_gem 'c', '1' do |s|
+ @c1, @c1_gem = util_gem 'c', '1' do |s|
s.add_development_dependency 'b'
end
- @d1, @d1_gem = util_gem 'd', '1' do |s|
+ @d1, @d1_gem = util_gem 'd', '1' do |s|
s.add_development_dependency 'c'
end
@@ -872,8 +876,13 @@ class TestGemDependencyInstaller < Gem::TestCase
a1_data = nil
a2_o_data = nil
- File.open @a1_gem, 'rb' do |fp| a1_data = fp.read end
- File.open a2_o_gem, 'rb' do |fp| a2_o_data = fp.read end
+ File.open @a1_gem, 'rb' do |fp|
+ a1_data = fp.read
+ end
+
+ File.open a2_o_gem, 'rb' do |fp|
+ a2_o_data = fp.read
+ end
@fetcher.data["http://gems.example.com/gems/#{@a1.file_name}"] =
a1_data
@@ -1235,4 +1244,5 @@ class TestGemDependencyInstaller < Gem::TestCase
util_clear_gems
end
+
end
diff --git a/test/rubygems/test_gem_dependency_list.rb b/test/rubygems/test_gem_dependency_list.rb
index 9bd6ceb6f3..019cb33973 100644
--- a/test/rubygems/test_gem_dependency_list.rb
+++ b/test/rubygems/test_gem_dependency_list.rb
@@ -16,13 +16,23 @@ class TestGemDependencyList < Gem::TestCase
@a2 = util_spec 'a', '2'
@a3 = util_spec 'a', '3'
- @b1 = util_spec 'b', '1' do |s| s.add_dependency 'a', '>= 1' end
- @b2 = util_spec 'b', '2' do |s| s.add_dependency 'a', '>= 1' end
+ @b1 = util_spec 'b', '1' do |s|
+ s.add_dependency 'a', '>= 1'
+ end
+
+ @b2 = util_spec 'b', '2' do |s|
+ s.add_dependency 'a', '>= 1'
+ end
+
+ @c1 = util_spec 'c', '1' do |s|
+ s.add_dependency 'b', '>= 1'
+ end
- @c1 = util_spec 'c', '1' do |s| s.add_dependency 'b', '>= 1' end
@c2 = util_spec 'c', '2'
- @d1 = util_spec 'd', '1' do |s| s.add_dependency 'c', '>= 1' end
+ @d1 = util_spec 'd', '1' do |s|
+ s.add_dependency 'c', '>= 1'
+ end
end
def test_active_count
@@ -165,8 +175,13 @@ class TestGemDependencyList < Gem::TestCase
a1 = util_spec 'a', '1'
a2 = util_spec 'a', '2'
- b = util_spec 'b', '1' do |s| s.add_dependency 'a', '= 1' end
- c = util_spec 'c', '1' do |s| s.add_dependency 'a', '= 2' end
+ b = util_spec 'b', '1' do |s|
+ s.add_dependency 'a', '= 1'
+ end
+
+ c = util_spec 'c', '1' do |s|
+ s.add_dependency 'a', '= 2'
+ end
d = util_spec 'd', '1' do |s|
s.add_dependency 'b'
diff --git a/test/rubygems/test_gem_ext_builder.rb b/test/rubygems/test_gem_ext_builder.rb
index ce04762e84..46a4385750 100644
--- a/test/rubygems/test_gem_ext_builder.rb
+++ b/test/rubygems/test_gem_ext_builder.rb
@@ -134,6 +134,7 @@ install:
def test_build_extensions_install_ext_only
class << Gem
+
alias orig_install_extension_in_lib install_extension_in_lib
remove_method :install_extension_in_lib
@@ -141,6 +142,7 @@ install:
def Gem.install_extension_in_lib
false
end
+
end
@spec.extensions << 'ext/extconf.rb'
@@ -177,9 +179,11 @@ install:
refute_path_exists File.join @spec.gem_dir, 'lib', 'a', 'b.rb'
ensure
class << Gem
+
remove_method :install_extension_in_lib
alias install_extension_in_lib orig_install_extension_in_lib
+
end
end
diff --git a/test/rubygems/test_gem_ext_rake_builder.rb b/test/rubygems/test_gem_ext_rake_builder.rb
index 6b647293a8..c86ff07649 100644
--- a/test/rubygems/test_gem_ext_rake_builder.rb
+++ b/test/rubygems/test_gem_ext_rake_builder.rb
@@ -3,6 +3,7 @@ require 'rubygems/test_case'
require 'rubygems/ext'
class TestGemExtRakeBuilder < Gem::TestCase
+
def setup
super
@@ -90,4 +91,5 @@ class TestGemExtRakeBuilder < Gem::TestCase
EO_MKRF
end
end
+
end
diff --git a/test/rubygems/test_gem_gemcutter_utilities.rb b/test/rubygems/test_gem_gemcutter_utilities.rb
index 4315090a3d..03bb78271b 100644
--- a/test/rubygems/test_gem_gemcutter_utilities.rb
+++ b/test/rubygems/test_gem_gemcutter_utilities.rb
@@ -90,7 +90,7 @@ class TestGemGemcutterUtilities < Gem::TestCase
end
def test_sign_in
- api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903'
+ api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903'
util_sign_in [api_key, 200, 'OK']
assert_match %r{Enter your RubyGems.org credentials.}, @sign_in_ui.output
@@ -102,7 +102,7 @@ class TestGemGemcutterUtilities < Gem::TestCase
end
def test_sign_in_with_host
- api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903'
+ api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903'
util_sign_in [api_key, 200, 'OK'], 'http://example.com', ['http://example.com']
@@ -116,7 +116,7 @@ class TestGemGemcutterUtilities < Gem::TestCase
end
def test_sign_in_with_host_nil
- api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903'
+ api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903'
util_sign_in [api_key, 200, 'OK'], nil, [nil]
@@ -130,7 +130,7 @@ class TestGemGemcutterUtilities < Gem::TestCase
end
def test_sign_in_with_host_ENV
- api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903'
+ api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903'
util_sign_in [api_key, 200, 'OK'], 'http://example.com'
assert_match "Enter your http://example.com credentials.",
@@ -143,7 +143,7 @@ class TestGemGemcutterUtilities < Gem::TestCase
end
def test_sign_in_skips_with_existing_credentials
- api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903'
+ api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903'
Gem.configuration.rubygems_api_key = api_key
util_sign_in [api_key, 200, 'OK']
@@ -152,8 +152,8 @@ class TestGemGemcutterUtilities < Gem::TestCase
end
def test_sign_in_skips_with_key_override
- api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903'
- Gem.configuration.api_keys[:KEY] = 'other'
+ api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903'
+ Gem.configuration.api_keys[:KEY] = 'other'
@cmd.options[:key] = :KEY
util_sign_in [api_key, 200, 'OK']
@@ -173,7 +173,7 @@ class TestGemGemcutterUtilities < Gem::TestCase
assert_match %r{Enter your RubyGems.org credentials.}, @sign_in_ui.output
assert_match %r{Signed in.}, @sign_in_ui.output
- credentials = YAML.load_file Gem.configuration.credentials_path
+ credentials = YAML.load_file Gem.configuration.credentials_path
assert_equal api_key, credentials[:rubygems_api_key]
assert_equal other_api_key, credentials[:other_api_key]
end
diff --git a/test/rubygems/test_gem_indexer.rb b/test/rubygems/test_gem_indexer.rb
index 9f27744d48..cc83cdd81e 100644
--- a/test/rubygems/test_gem_indexer.rb
+++ b/test/rubygems/test_gem_indexer.rb
@@ -37,6 +37,13 @@ class TestGemIndexer < Gem::TestCase
@indexer = Gem::Indexer.new(@tempdir)
end
+ def teardown
+ super
+
+ util_clear_gems
+ util_clear_default_gems
+ end
+
def test_initialize
assert_equal @tempdir, @indexer.dest_directory
assert_match %r{#{Dir.mktmpdir('gem_generate_index').match(/.*-/)}}, @indexer.directory
diff --git a/test/rubygems/test_gem_install_update_options.rb b/test/rubygems/test_gem_install_update_options.rb
index 65eaf7275f..dd6bd08dde 100644
--- a/test/rubygems/test_gem_install_update_options.rb
+++ b/test/rubygems/test_gem_install_update_options.rb
@@ -180,4 +180,5 @@ class TestGemInstallUpdateOptions < Gem::InstallerTestCase
assert_equal true, @cmd.options[:post_install_message]
end
+
end
diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb
index 23c153d69b..ebf23ecfcc 100644
--- a/test/rubygems/test_gem_installer.rb
+++ b/test/rubygems/test_gem_installer.rb
@@ -2,6 +2,7 @@
require 'rubygems/installer_test_case'
class TestGemInstaller < Gem::InstallerTestCase
+
@@symlink_supported = nil
def symlink_supported?
@@ -163,6 +164,8 @@ gem 'other', version
wrapper = File.read installed_exec
assert_match %r|generated by RubyGems|, wrapper
+ ensure
+ Gem::Installer.exec_format = nil
end
def test_check_executable_overwrite_other_gem
@@ -699,7 +702,10 @@ gem 'other', version
end
def test_initialize
- spec = util_spec 'a' do |s| s.platform = Gem::Platform.new 'mswin32' end
+ spec = util_spec 'a' do |s|
+ s.platform = Gem::Platform.new 'mswin32'
+ end
+
gem = File.join @tempdir, spec.file_name
Dir.mkdir util_inst_bindir
@@ -945,7 +951,10 @@ gem 'other', version
# Morph spec to have lib/other.rb instead of code.rb and recreate
@spec.files = File.join('lib', 'other.rb')
Dir.chdir @tempdir do
- File.open File.join('lib', 'other.rb'), 'w' do |f| f.puts '1' end
+ File.open File.join('lib', 'other.rb'), 'w' do |f|
+ f.puts '1'
+ end
+
use_ui ui do
FileUtils.rm @gem
Gem::Package.build @spec
@@ -1282,9 +1291,9 @@ gem 'other', version
end
# empty depend file for no auto dependencies
- @spec.files += %W"depend #{@spec.name}.c".each {|file|
+ @spec.files += %W"depend #{@spec.name}.c".each do |file|
write_file File.join(@tempdir, file)
- }
+ end
so = File.join(@spec.gem_dir, "#{@spec.name}.#{RbConfig::CONFIG["DLEXT"]}")
refute_path_exists so
@@ -1768,4 +1777,5 @@ gem 'other', version
def mask
0100755 & (~File.umask)
end
+
end
diff --git a/test/rubygems/test_gem_package.rb b/test/rubygems/test_gem_package.rb
index dfb6ea40d1..17e288998f 100644
--- a/test/rubygems/test_gem_package.rb
+++ b/test/rubygems/test_gem_package.rb
@@ -129,8 +129,13 @@ class TestGemPackage < Gem::Package::TarTestCase
FileUtils.mkdir_p 'lib/empty'
- File.open 'lib/code.rb', 'w' do |io| io.write '# lib/code.rb' end
- File.open 'lib/extra.rb', 'w' do |io| io.write '# lib/extra.rb' end
+ File.open 'lib/code.rb', 'w' do |io|
+ io.write '# lib/code.rb'
+ end
+
+ File.open 'lib/extra.rb', 'w' do |io|
+ io.write '# lib/extra.rb'
+ end
package = Gem::Package.new 'bogus.gem'
package.spec = spec
@@ -157,7 +162,10 @@ class TestGemPackage < Gem::Package::TarTestCase
spec.files = %w[lib/code.rb lib/code_sym.rb lib/code_sym2.rb]
FileUtils.mkdir_p 'lib'
- File.open 'lib/code.rb', 'w' do |io| io.write '# lib/code.rb' end
+
+ File.open 'lib/code.rb', 'w' do |io|
+ io.write '# lib/code.rb'
+ end
# NOTE: 'code.rb' is correct, because it's relative to lib/code_sym.rb
begin
@@ -433,7 +441,7 @@ class TestGemPackage < Gem::Package::TarTestCase
end
def test_extract_files_empty
- data_tgz = util_tar_gz do end
+ data_tgz = util_tar_gz { }
gem = util_tar do |tar|
tar.add_file 'data.tar.gz', 0644 do |io|
@@ -462,7 +470,9 @@ class TestGemPackage < Gem::Package::TarTestCase
package = Gem::Package.new @gem
tgz_io = util_tar_gz do |tar|
- tar.add_file '/absolute.rb', 0644 do |io| io.write 'hi' end
+ tar.add_file '/absolute.rb', 0644 do |io|
+ io.write 'hi'
+ end
end
e = assert_raises Gem::Package::PathError do
@@ -477,7 +487,10 @@ class TestGemPackage < Gem::Package::TarTestCase
package = Gem::Package.new @gem
tgz_io = util_tar_gz do |tar|
- tar.add_file 'relative.rb', 0644 do |io| io.write 'hi' end
+ tar.add_file 'relative.rb', 0644 do |io|
+ io.write 'hi'
+ end
+
tar.mkdir 'lib', 0755
tar.add_symlink 'lib/foo.rb', '../relative.rb', 0644
end
@@ -506,7 +519,9 @@ class TestGemPackage < Gem::Package::TarTestCase
tgz_io = util_tar_gz do |tar|
tar.mkdir 'lib', 0755
tar.add_symlink 'lib/link', '../..', 0644
- tar.add_file 'lib/link/outside.txt', 0644 do |io| io.write 'hi' end
+ tar.add_file 'lib/link/outside.txt', 0644 do |io|
+ io.write 'hi'
+ end
end
# Extract into a subdirectory of @destination; if this test fails it writes
@@ -534,7 +549,9 @@ class TestGemPackage < Gem::Package::TarTestCase
tgz_io = util_tar_gz do |tar|
tar.mkdir 'lib', 0755
- tar.add_file 'lib/foo.rb', 0644 do |io| io.write 'hi' end
+ tar.add_file 'lib/foo.rb', 0644 do |io|
+ io.write 'hi'
+ end
tar.mkdir 'lib/foo', 0755
end
@@ -551,7 +568,9 @@ class TestGemPackage < Gem::Package::TarTestCase
package = Gem::Package.new @gem
tgz_io = util_tar_gz do |tar|
- tar.add_file './dot_slash.rb', 0644 do |io| io.write 'hi' end
+ tar.add_file './dot_slash.rb', 0644 do |io|
+ io.write 'hi'
+ end
end
package.extract_tar_gz tgz_io, @destination
@@ -564,7 +583,9 @@ class TestGemPackage < Gem::Package::TarTestCase
package = Gem::Package.new @gem
tgz_io = util_tar_gz do |tar|
- tar.add_file '.dot_file.rb', 0644 do |io| io.write 'hi' end
+ tar.add_file '.dot_file.rb', 0644 do |io|
+ io.write 'hi'
+ end
end
package.extract_tar_gz tgz_io, @destination
@@ -578,7 +599,9 @@ class TestGemPackage < Gem::Package::TarTestCase
package = Gem::Package.new @gem
tgz_io = util_tar_gz do |tar|
- tar.add_file 'foo/file.rb', 0644 do |io| io.write 'hi' end
+ tar.add_file 'foo/file.rb', 0644 do |io|
+ io.write 'hi'
+ end
end
package.extract_tar_gz tgz_io, @destination.upcase
@@ -1043,7 +1066,9 @@ class TestGemPackage < Gem::Package::TarTestCase
tgz_io = StringIO.new
# can't wrap TarWriter because it seeks
- Zlib::GzipWriter.wrap tgz_io do |io| io.write tar_io.string end
+ Zlib::GzipWriter.wrap tgz_io do |io|
+ io.write tar_io.string
+ end
StringIO.new tgz_io.string
end
diff --git a/test/rubygems/test_gem_package_tar_reader_entry.rb b/test/rubygems/test_gem_package_tar_reader_entry.rb
index ef088e32be..4627c230d9 100644
--- a/test/rubygems/test_gem_package_tar_reader_entry.rb
+++ b/test/rubygems/test_gem_package_tar_reader_entry.rb
@@ -43,19 +43,19 @@ class TestGemPackageTarReaderEntry < Gem::Package::TarTestCase
assert @entry.bytes_read
- e = assert_raises IOError do @entry.eof? end
+ e = assert_raises(IOError) { @entry.eof? }
assert_equal 'closed Gem::Package::TarReader::Entry', e.message
- e = assert_raises IOError do @entry.getc end
+ e = assert_raises(IOError) { @entry.getc }
assert_equal 'closed Gem::Package::TarReader::Entry', e.message
- e = assert_raises IOError do @entry.pos end
+ e = assert_raises(IOError) { @entry.pos }
assert_equal 'closed Gem::Package::TarReader::Entry', e.message
- e = assert_raises IOError do @entry.read end
+ e = assert_raises(IOError) { @entry.read }
assert_equal 'closed Gem::Package::TarReader::Entry', e.message
- e = assert_raises IOError do @entry.rewind end
+ e = assert_raises(IOError) { @entry.rewind }
assert_equal 'closed Gem::Package::TarReader::Entry', e.message
end
diff --git a/test/rubygems/test_gem_package_tar_writer.rb b/test/rubygems/test_gem_package_tar_writer.rb
index 517320c011..6a940ed902 100644
--- a/test/rubygems/test_gem_package_tar_writer.rb
+++ b/test/rubygems/test_gem_package_tar_writer.rb
@@ -25,7 +25,9 @@ class TestGemPackageTarWriter < Gem::Package::TarTestCase
def test_add_file
Time.stub :now, Time.at(1458518157) do
- @tar_writer.add_file 'x', 0644 do |f| f.write 'a' * 10 end
+ @tar_writer.add_file 'x', 0644 do |f|
+ f.write 'a' * 10
+ end
assert_headers_equal(tar_file_header('x', '', 0644, 10, Time.now),
@io.string[0, 512])
@@ -160,7 +162,9 @@ class TestGemPackageTarWriter < Gem::Package::TarTestCase
def test_add_file_simple
Time.stub :now, Time.at(1458518157) do
- @tar_writer.add_file_simple 'x', 0644, 10 do |io| io.write "a" * 10 end
+ @tar_writer.add_file_simple 'x', 0644, 10 do |io|
+ io.write "a" * 10
+ end
assert_headers_equal(tar_file_header('x', '', 0644, 10, Time.now),
@io.string[0, 512])
@@ -173,7 +177,9 @@ class TestGemPackageTarWriter < Gem::Package::TarTestCase
def test_add_file_simple_source_date_epoch
ENV["SOURCE_DATE_EPOCH"] = "123456789"
Time.stub :now, Time.at(1458518157) do
- @tar_writer.add_file_simple 'x', 0644, 10 do |io| io.write "a" * 10 end
+ @tar_writer.add_file_simple 'x', 0644, 10 do |io|
+ io.write "a" * 10
+ end
assert_headers_equal(tar_file_header('x', '', 0644, 10, Time.at(ENV["SOURCE_DATE_EPOCH"].to_i).utc),
@io.string[0, 512])
@@ -195,7 +201,7 @@ class TestGemPackageTarWriter < Gem::Package::TarTestCase
@tar_writer.add_file_simple("lib/foo/bar", 0, 10) { |f| f.write @data }
@tar_writer.flush
- assert_equal @data + ("\0" * (512-@data.size)),
+ assert_equal @data + ("\0" * (512 - @data.size)),
@io.string[512, 512]
end
@@ -295,7 +301,7 @@ class TestGemPackageTarWriter < Gem::Package::TarTestCase
# note, GNU tar 1.28 is unable to handle this case too,
# tested with "tar --format=ustar -cPf /tmp/foo.tartar -- /aaaaaa....a"
- name = '/' + 'a' * 100
+ name = '/' + 'a' * 100
exception = assert_raises Gem::Package::TooLongFileName do
@tar_writer.split_name name
end
diff --git a/test/rubygems/test_gem_path_support.rb b/test/rubygems/test_gem_path_support.rb
index 551ec28781..1f9cfe2c57 100644
--- a/test/rubygems/test_gem_path_support.rb
+++ b/test/rubygems/test_gem_path_support.rb
@@ -4,6 +4,7 @@ require 'rubygems'
require 'fileutils'
class TestGemPathSupport < Gem::TestCase
+
def setup
super
@@ -135,4 +136,5 @@ class TestGemPathSupport < Gem::TestCase
assert_equal dir, ps.home
assert_equal [dir, not_existing], ps.path
end
+
end
diff --git a/test/rubygems/test_gem_platform.rb b/test/rubygems/test_gem_platform.rb
index fc8b7030fb..61d1966119 100644
--- a/test/rubygems/test_gem_platform.rb
+++ b/test/rubygems/test_gem_platform.rb
@@ -211,13 +211,13 @@ class TestGemPlatform < Gem::TestCase
assert((arm === Gem::Platform.local), 'arm === armv5')
assert((armv5 === Gem::Platform.local), 'armv5 === armv5')
refute((armv7 === Gem::Platform.local), 'armv7 === armv5')
- refute((Gem::Platform.local === arm), 'armv5 === arm')
+ refute((Gem::Platform.local === arm), 'armv5 === arm')
util_set_arch 'armv7-linux'
assert((arm === Gem::Platform.local), 'arm === armv7')
refute((armv5 === Gem::Platform.local), 'armv5 === armv7')
assert((armv7 === Gem::Platform.local), 'armv7 === armv7')
- refute((Gem::Platform.local === arm), 'armv7 === arm')
+ refute((Gem::Platform.local === arm), 'armv7 === arm')
end
def test_equals3_version
@@ -304,4 +304,5 @@ class TestGemPlatform < Gem::TestCase
def refute_local_match(name)
refute_match Gem::Platform.local, name
end
+
end
diff --git a/test/rubygems/test_gem_rdoc.rb b/test/rubygems/test_gem_rdoc.rb
index 073578527d..6184d4b457 100644
--- a/test/rubygems/test_gem_rdoc.rb
+++ b/test/rubygems/test_gem_rdoc.rb
@@ -4,8 +4,8 @@ require 'rubygems/test_case'
require 'rubygems/rdoc'
class TestGemRDoc < Gem::TestCase
+
Gem::RDoc.load_rdoc
- rdoc_4 = Gem::Requirement.new('> 3').satisfied_by?(Gem::RDoc.rdoc_version)
def setup
super
@@ -31,29 +31,8 @@ class TestGemRDoc < Gem::TestCase
Gem.configuration[:rdoc] = nil
end
- ##
- # RDoc 4 ships with its own Gem::RDoc which overrides this one which is
- # shipped for backwards compatibility.
-
- def rdoc_4?
- Gem::Requirement.new('>= 4.0.0.preview2').satisfied_by? \
- @hook.class.rdoc_version
- end
-
- def rdoc_3?
- Gem::Requirement.new('~> 3.0').satisfied_by? @hook.class.rdoc_version
- end
-
- def rdoc_3_8_or_better?
- Gem::Requirement.new('>= 3.8').satisfied_by? @hook.class.rdoc_version
- end
-
def test_initialize
- if rdoc_4?
- refute @hook.generate_rdoc
- else
- assert @hook.generate_rdoc
- end
+ refute @hook.generate_rdoc
assert @hook.generate_ri
rdoc = Gem::RDoc.new @a, false, false
@@ -75,67 +54,6 @@ class TestGemRDoc < Gem::TestCase
assert_empty args
end
- def test_document
- skip 'RDoc 3 required' unless rdoc_3?
-
- options = RDoc::Options.new
- options.files = []
-
- rdoc = @hook.new_rdoc
- @hook.instance_variable_set :@rdoc, rdoc
- @hook.instance_variable_set :@file_info, []
-
- @hook.document 'darkfish', options, @a.doc_dir('rdoc')
-
- assert @hook.rdoc_installed?
- end unless rdoc_4
-
- def test_generate
- skip 'RDoc 3 required' unless rdoc_3?
-
- FileUtils.mkdir_p @a.doc_dir
- FileUtils.mkdir_p File.join(@a.gem_dir, 'lib')
-
- @hook.generate
-
- assert @hook.rdoc_installed?
- assert @hook.ri_installed?
-
- rdoc = @hook.instance_variable_get :@rdoc
-
- refute rdoc.options.hyperlink_all
- end unless rdoc_4
-
- def test_generate_configuration_rdoc_array
- skip 'RDoc 3 required' unless rdoc_3?
-
- Gem.configuration[:rdoc] = %w[-A]
-
- FileUtils.mkdir_p @a.doc_dir
- FileUtils.mkdir_p File.join(@a.gem_dir, 'lib')
-
- @hook.generate
-
- rdoc = @hook.instance_variable_get :@rdoc
-
- assert rdoc.options.hyperlink_all
- end unless rdoc_4
-
- def test_generate_configuration_rdoc_string
- skip 'RDoc 3 required' unless rdoc_3?
-
- Gem.configuration[:rdoc] = '-A'
-
- FileUtils.mkdir_p @a.doc_dir
- FileUtils.mkdir_p File.join(@a.gem_dir, 'lib')
-
- @hook.generate
-
- rdoc = @hook.instance_variable_get :@rdoc
-
- assert rdoc.options.hyperlink_all
- end unless rdoc_4
-
def test_generate_disabled
@hook.generate_rdoc = false
@hook.generate_ri = false
@@ -146,57 +64,6 @@ class TestGemRDoc < Gem::TestCase
refute @hook.ri_installed?
end
- def test_generate_force
- skip 'RDoc 3 required' unless rdoc_3?
-
- FileUtils.mkdir_p @a.doc_dir 'ri'
- FileUtils.mkdir_p @a.doc_dir 'rdoc'
- FileUtils.mkdir_p File.join(@a.gem_dir, 'lib')
-
- @hook.force = true
-
- @hook.generate
-
- assert_path_exists File.join(@a.doc_dir('rdoc'), 'index.html')
- assert_path_exists File.join(@a.doc_dir('ri'), 'cache.ri')
- end unless rdoc_4
-
- def test_generate_no_overwrite
- skip 'RDoc 3 required' unless rdoc_3?
-
- FileUtils.mkdir_p @a.doc_dir 'ri'
- FileUtils.mkdir_p @a.doc_dir 'rdoc'
- FileUtils.mkdir_p File.join(@a.gem_dir, 'lib')
-
- @hook.generate
-
- refute_path_exists File.join(@a.doc_dir('rdoc'), 'index.html')
- refute_path_exists File.join(@a.doc_dir('ri'), 'cache.ri')
- end unless rdoc_4
-
- def test_generate_legacy
- skip 'RDoc < 3.8 required' if rdoc_3_8_or_better?
-
- FileUtils.mkdir_p @a.doc_dir
- FileUtils.mkdir_p File.join(@a.gem_dir, 'lib')
-
- @hook.generate_legacy
-
- assert @hook.rdoc_installed?
- assert @hook.ri_installed?
- end unless rdoc_4
-
- def test_legacy_rdoc
- skip 'RDoc < 3.8 required' if rdoc_3_8_or_better?
-
- FileUtils.mkdir_p @a.doc_dir
- FileUtils.mkdir_p File.join(@a.gem_dir, 'lib')
-
- @hook.legacy_rdoc '--op', @a.doc_dir('rdoc')
-
- assert @hook.rdoc_installed?
- end unless rdoc_4
-
def test_new_rdoc
assert_kind_of RDoc::RDoc, @hook.new_rdoc
end
diff --git a/test/rubygems/test_gem_remote_fetcher.rb b/test/rubygems/test_gem_remote_fetcher.rb
index a725fe205c..a5ff929bd0 100644
--- a/test/rubygems/test_gem_remote_fetcher.rb
+++ b/test/rubygems/test_gem_remote_fetcher.rb
@@ -84,7 +84,7 @@ gems:
# Generated via:
# x = OpenSSL::PKey::DH.new(2048) # wait a while...
# x.to_s => pem
- TEST_KEY_DH2048 = OpenSSL::PKey::DH.new <<-_end_of_pem_
+ TEST_KEY_DH2048 = OpenSSL::PKey::DH.new <<-_end_of_pem_
-----BEGIN DH PARAMETERS-----
MIIBCAKCAQEA3Ze2EHSfYkZLUn557torAmjBgPsqzbodaRaGZtgK1gEU+9nNJaFV
G1JKhmGUiEDyIW7idsBpe4sX/Wqjnp48Lr8IeI/SlEzLdoGpf05iRYXC8Cm9o8aM
@@ -117,7 +117,10 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
FileUtils.mkdir @gems_dir
# TODO: why does the remote fetcher need it written to disk?
- @a1, @a1_gem = util_gem 'a', '1' do |s| s.executables << 'a_bin' end
+ @a1, @a1_gem = util_gem 'a', '1' do |s|
+ s.executables << 'a_bin'
+ end
+
@a1.loaded_from = File.join(@gemhome, 'specifications', @a1.full_name)
Gem::RemoteFetcher.fetcher = nil
@@ -786,7 +789,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
ssl_server = self.class.start_ssl_server({
:SSLVerifyClient =>
- OpenSSL::SSL::VERIFY_PEER|OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT})
+ OpenSSL::SSL::VERIFY_PEER | OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT})
temp_ca_cert = File.join(DIR, 'ca_cert.pem')
temp_client_cert = File.join(DIR, 'client.pem')
@@ -803,7 +806,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
ssl_server = self.class.start_ssl_server({
:SSLVerifyClient =>
- OpenSSL::SSL::VERIFY_PEER|OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT})
+ OpenSSL::SSL::VERIFY_PEER | OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT})
temp_ca_cert = File.join(DIR, 'ca_cert.pem')
temp_client_cert = File.join(DIR, 'invalid_client.pem')
@@ -895,11 +898,14 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
end
class NilLog < WEBrick::Log
+
def log(level, data) #Do nothing
end
+
end
class << self
+
attr_reader :normal_server, :proxy_server
attr_accessor :enable_zip, :enable_yaml
@@ -959,12 +965,12 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
:SSLVerifyClient => nil,
:SSLCertName => nil
}.merge(config))
- server.mount_proc("/yaml") { |req, res|
+ server.mount_proc("/yaml") do |req, res|
res.body = "--- true\n"
- }
- server.mount_proc("/insecure_redirect") { |req, res|
+ end
+ server.mount_proc("/insecure_redirect") do |req, res|
res.set_redirect(WEBrick::HTTPStatus::MovedPermanently, req.query['to'])
- }
+ end
server.ssl_context.tmp_dh_callback = proc { TEST_KEY_DH2048 }
t = Thread.new do
begin
@@ -999,7 +1005,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
:AccessLog => null_logger
)
s.mount_proc("/kill") { |req, res| s.shutdown }
- s.mount_proc("/yaml") { |req, res|
+ s.mount_proc("/yaml") do |req, res|
if req["X-Captain"]
res.body = req["X-Captain"]
elsif @enable_yaml
@@ -1011,8 +1017,8 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
res.body = "<h1>NOT FOUND</h1>"
res['Content-Type'] = 'text/html'
end
- }
- s.mount_proc("/yaml.Z") { |req, res|
+ end
+ s.mount_proc("/yaml.Z") do |req, res|
if @enable_zip
res.body = Zlib::Deflate.deflate(data)
res['Content-Type'] = 'text/plain'
@@ -1021,7 +1027,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
res.body = "<h1>NOT FOUND</h1>"
res['Content-Type'] = 'text/html'
end
- }
+ end
th = Thread.new do
begin
s.start
@@ -1042,6 +1048,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
def key(filename)
OpenSSL::PKey::RSA.new(File.read(File.join(DIR, filename)))
end
+
end
def test_correct_for_windows_path
diff --git a/test/rubygems/test_gem_request.rb b/test/rubygems/test_gem_request.rb
index 0577eb6f99..5f7d7bb7be 100644
--- a/test/rubygems/test_gem_request.rb
+++ b/test/rubygems/test_gem_request.rb
@@ -93,11 +93,11 @@ class TestGemRequest < Gem::TestCase
def test_configure_connection_for_https
connection = Net::HTTP.new 'localhost', 443
- request = Class.new(Gem::Request) {
+ request = Class.new(Gem::Request) do
def self.get_cert_files
[TestGemRequest::PUBLIC_CERT_FILE]
end
- }.create_with_proxy URI('https://example'), nil, nil, nil
+ end.create_with_proxy URI('https://example'), nil, nil, nil
Gem::Request.configure_connection_for_https connection, request.cert_files
@@ -112,11 +112,11 @@ class TestGemRequest < Gem::TestCase
connection = Net::HTTP.new 'localhost', 443
- request = Class.new(Gem::Request) {
+ request = Class.new(Gem::Request) do
def self.get_cert_files
[TestGemRequest::PUBLIC_CERT_FILE]
end
- }.create_with_proxy URI('https://example'), nil, nil, nil
+ end.create_with_proxy URI('https://example'), nil, nil, nil
Gem::Request.configure_connection_for_https connection, request.cert_files
@@ -486,6 +486,7 @@ ERROR: Certificate is an invalid CA certificate
end
class Conn
+
attr_accessor :payload
def new(*args); self; end
@@ -504,6 +505,7 @@ ERROR: Certificate is an invalid CA certificate
self.payload = req
@response
end
+
end
end if defined?(OpenSSL::SSL)
diff --git a/test/rubygems/test_gem_request_connection_pools.rb b/test/rubygems/test_gem_request_connection_pools.rb
index eb48ba45d2..f8d2095167 100644
--- a/test/rubygems/test_gem_request_connection_pools.rb
+++ b/test/rubygems/test_gem_request_connection_pools.rb
@@ -4,12 +4,15 @@ require 'rubygems/request'
require 'timeout'
class TestGemRequestConnectionPool < Gem::TestCase
+
class FakeHttp
+
def initialize(*args)
end
def start
end
+
end
def setup
@@ -139,12 +142,13 @@ class TestGemRequestConnectionPool < Gem::TestCase
pool.checkout
- Thread.new {
+ Thread.new do
assert_raises(Timeout::Error) do
Timeout.timeout(1) do
pool.checkout
end
end
- }.join
+ end.join
end
+
end
diff --git a/test/rubygems/test_gem_request_set.rb b/test/rubygems/test_gem_request_set.rb
index 86986f2287..ac344015e7 100644
--- a/test/rubygems/test_gem_request_set.rb
+++ b/test/rubygems/test_gem_request_set.rb
@@ -3,6 +3,7 @@ require 'rubygems/test_case'
require 'rubygems/request_set'
class TestGemRequestSet < Gem::TestCase
+
def setup
super
@@ -311,8 +312,14 @@ ruby "0"
end
def test_resolve_development_shallow
- a = util_spec 'a', 1 do |s| s.add_development_dependency 'b' end
- b = util_spec 'b', 1 do |s| s.add_development_dependency 'c' end
+ a = util_spec 'a', 1 do |s|
+ s.add_development_dependency 'b'
+ end
+
+ b = util_spec 'b', 1 do |s|
+ s.add_development_dependency 'c'
+ end
+
c = util_spec 'c', 1
a_spec = Gem::Resolver::SpecSpecification.new nil, a
@@ -528,8 +535,14 @@ ruby "0"
end
def test_sorted_requests_development_shallow
- a = util_spec 'a', 1 do |s| s.add_development_dependency 'b' end
- b = util_spec 'b', 1 do |s| s.add_development_dependency 'c' end
+ a = util_spec 'a', 1 do |s|
+ s.add_development_dependency 'b'
+ end
+
+ b = util_spec 'b', 1 do |s|
+ s.add_development_dependency 'c'
+ end
+
c = util_spec 'c', 1
rs = Gem::RequestSet.new
@@ -547,8 +560,14 @@ ruby "0"
end
def test_tsort_each_child_development
- a = util_spec 'a', 1 do |s| s.add_development_dependency 'b' end
- b = util_spec 'b', 1 do |s| s.add_development_dependency 'c' end
+ a = util_spec 'a', 1 do |s|
+ s.add_development_dependency 'b'
+ end
+
+ b = util_spec 'b', 1 do |s|
+ s.add_development_dependency 'c'
+ end
+
c = util_spec 'c', 1
rs = Gem::RequestSet.new
@@ -570,8 +589,14 @@ ruby "0"
end
def test_tsort_each_child_development_shallow
- a = util_spec 'a', 1 do |s| s.add_development_dependency 'b' end
- b = util_spec 'b', 1 do |s| s.add_development_dependency 'c' end
+ a = util_spec 'a', 1 do |s|
+ s.add_development_dependency 'b'
+ end
+
+ b = util_spec 'b', 1 do |s|
+ s.add_development_dependency 'c'
+ end
+
c = util_spec 'c', 1
rs = Gem::RequestSet.new
diff --git a/test/rubygems/test_gem_request_set_gem_dependency_api.rb b/test/rubygems/test_gem_request_set_gem_dependency_api.rb
index 0e597f2b11..0df0bef215 100644
--- a/test/rubygems/test_gem_request_set_gem_dependency_api.rb
+++ b/test/rubygems/test_gem_request_set_gem_dependency_api.rb
@@ -283,6 +283,14 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
refute_empty set.dependencies
end
+ with_engine_version 'truffleruby', '2.0.0' do
+ set = Gem::RequestSet.new
+ gda = @GDA.new set, 'gem.deps.rb'
+ gda.gem 'a', :platforms => :ruby
+
+ refute_empty set.dependencies
+ end
+
with_engine_version 'jruby', '1.7.6' do
set = Gem::RequestSet.new
gda = @GDA.new set, 'gem.deps.rb'
@@ -310,6 +318,12 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
assert_empty @set.dependencies
end
+
+ with_engine_version 'truffleruby', '1.2.3' do
+ @gda.gem 'a', :platforms => :mri
+
+ assert_empty @set.dependencies
+ end
end
def test_gem_platforms_maglev
@@ -332,6 +346,22 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
Gem.win_platform = win_platform
end
+ def test_gem_platforms_truffleruby
+ with_engine_version 'truffleruby', '1.0.0' do
+ set = Gem::RequestSet.new
+ gda = @GDA.new set, 'gem.deps.rb'
+ gda.gem 'a', :platforms => :truffleruby
+
+ refute_empty set.dependencies
+
+ set = Gem::RequestSet.new
+ gda = @GDA.new set, 'gem.deps.rb'
+ gda.gem 'a', :platforms => :maglev
+
+ assert_empty set.dependencies
+ end
+ end
+
def test_gem_platforms_multiple
win_platform, Gem.win_platform = Gem.win_platform?, false
@@ -738,6 +768,12 @@ end
:engine => 'jruby', :engine_version => '1.7.6'
end
+
+ with_engine_version 'truffleruby', '1.0.0-rc11' do
+ assert @gda.ruby RUBY_VERSION,
+ :engine => 'truffleruby', :engine_version => '1.0.0-rc11'
+
+ end
end
def test_ruby_engine_mismatch_engine
diff --git a/test/rubygems/test_gem_request_set_lockfile.rb b/test/rubygems/test_gem_request_set_lockfile.rb
index 9ac691ebdd..7c5e256a2d 100644
--- a/test/rubygems/test_gem_request_set_lockfile.rb
+++ b/test/rubygems/test_gem_request_set_lockfile.rb
@@ -466,4 +466,5 @@ DEPENDENCIES
assert_equal 'hello', File.read(gem_deps_lock_file)
end
+
end
diff --git a/test/rubygems/test_gem_request_set_lockfile_parser.rb b/test/rubygems/test_gem_request_set_lockfile_parser.rb
index 27ee519ea7..c07a8c2a3d 100644
--- a/test/rubygems/test_gem_request_set_lockfile_parser.rb
+++ b/test/rubygems/test_gem_request_set_lockfile_parser.rb
@@ -6,6 +6,7 @@ require 'rubygems/request_set/lockfile/tokenizer'
require 'rubygems/request_set/lockfile/parser'
class TestGemRequestSetLockfileParser < Gem::TestCase
+
def setup
super
@gem_deps_file = 'gem.deps.rb'
@@ -541,4 +542,5 @@ DEPENDENCIES
parser = tokenizer.make_parser set, platforms
parser.parse
end
+
end
diff --git a/test/rubygems/test_gem_request_set_lockfile_tokenizer.rb b/test/rubygems/test_gem_request_set_lockfile_tokenizer.rb
index 48e66cf56a..aa91fc4468 100644
--- a/test/rubygems/test_gem_request_set_lockfile_tokenizer.rb
+++ b/test/rubygems/test_gem_request_set_lockfile_tokenizer.rb
@@ -6,6 +6,7 @@ require 'rubygems/request_set/lockfile/tokenizer'
require 'rubygems/request_set/lockfile/parser'
class TestGemRequestSetLockfileTokenizer < Gem::TestCase
+
def setup
super
@@ -303,4 +304,5 @@ GEM
def tokenize_lockfile
Gem::RequestSet::Lockfile::Tokenizer.from_file(@lock_file).to_a
end
+
end
diff --git a/test/rubygems/test_gem_requirement.rb b/test/rubygems/test_gem_requirement.rb
index 7a59243b6a..96acb24703 100644
--- a/test/rubygems/test_gem_requirement.rb
+++ b/test/rubygems/test_gem_requirement.rb
@@ -416,4 +416,5 @@ class TestGemRequirement < Gem::TestCase
refute req(requirement).satisfied_by?(v(version)),
"#{requirement} is not satisfied by #{version}"
end
+
end
diff --git a/test/rubygems/test_gem_resolver.rb b/test/rubygems/test_gem_resolver.rb
index fa1c595afd..74dc647a17 100644
--- a/test/rubygems/test_gem_resolver.rb
+++ b/test/rubygems/test_gem_resolver.rb
@@ -71,7 +71,7 @@ class TestGemResolver < Gem::TestCase
end
def test_self_compose_sets_nil
- index_set = @DR::IndexSet.new
+ index_set = @DR::IndexSet.new
composed = @DR.compose_sets index_set, nil
@@ -85,7 +85,7 @@ class TestGemResolver < Gem::TestCase
end
def test_self_compose_sets_single
- index_set = @DR::IndexSet.new
+ index_set = @DR::IndexSet.new
composed = @DR.compose_sets index_set
@@ -151,16 +151,31 @@ class TestGemResolver < Gem::TestCase
def test_resolve_conservative
a1_spec = util_spec 'a', 1
+
a2_spec = util_spec 'a', 2 do |s|
s.add_dependency 'b', 2
s.add_dependency 'c'
end
+
b1_spec = util_spec 'b', 1
b2_spec = util_spec 'b', 2
- c1_spec = util_spec 'c', 1 do |s| s.add_dependency 'd', 2 end
- c2_spec = util_spec 'c', 2 do |s| s.add_dependency 'd', 2 end
- d1_spec = util_spec 'd', 1 do |s| s.add_dependency 'e' end
- d2_spec = util_spec 'd', 2 do |s| s.add_dependency 'e' end
+
+ c1_spec = util_spec 'c', 1 do |s|
+ s.add_dependency 'd', 2
+ end
+
+ c2_spec = util_spec 'c', 2 do |s|
+ s.add_dependency 'd', 2
+ end
+
+ d1_spec = util_spec 'd', 1 do |s|
+ s.add_dependency 'e'
+ end
+
+ d2_spec = util_spec 'd', 2 do |s|
+ s.add_dependency 'e'
+ end
+
e1_spec = util_spec 'e', 1
e2_spec = util_spec 'e', 2
@@ -177,7 +192,7 @@ class TestGemResolver < Gem::TestCase
# With the following gems already installed:
# a-1, b-1, c-1, e-1
- res.skip_gems = {'a'=>[a1_spec], 'b'=>[b1_spec], 'c'=>[c1_spec], 'e'=>[e1_spec]}
+ res.skip_gems = {'a' => [a1_spec], 'b' => [b1_spec], 'c' => [c1_spec], 'e' => [e1_spec]}
# Make sure the following gems end up getting used/installed/upgraded:
# a-2 (upgraded)
@@ -189,8 +204,14 @@ class TestGemResolver < Gem::TestCase
end
def test_resolve_development
- a_spec = util_spec 'a', 1 do |s| s.add_development_dependency 'b' end
- b_spec = util_spec 'b', 1 do |s| s.add_development_dependency 'c' end
+ a_spec = util_spec 'a', 1 do |s|
+ s.add_development_dependency 'b'
+ end
+
+ b_spec = util_spec 'b', 1 do
+ |s| s.add_development_dependency 'c'
+ end
+
c_spec = util_spec 'c', 1
a_dep = make_dep 'a', '= 1'
@@ -212,10 +233,16 @@ class TestGemResolver < Gem::TestCase
s.add_runtime_dependency 'd'
end
- b_spec = util_spec 'b', 1 do |s| s.add_development_dependency 'c' end
+ b_spec = util_spec 'b', 1 do |s|
+ s.add_development_dependency 'c'
+ end
+
c_spec = util_spec 'c', 1
- d_spec = util_spec 'd', 1 do |s| s.add_development_dependency 'e' end
+ d_spec = util_spec 'd', 1 do |s|
+ s.add_development_dependency 'e'
+ end
+
e_spec = util_spec 'e', 1
a_dep = make_dep 'a', '= 1'
@@ -300,8 +327,14 @@ class TestGemResolver < Gem::TestCase
spec_fetcher do |fetcher|
fetcher.spec 'a', 2
- a2_p1 = fetcher.spec 'a', 2 do |s| s.platform = Gem::Platform.local end
- a3_p2 = fetcher.spec 'a', 3 do |s| s.platform = unknown end
+
+ a2_p1 = fetcher.spec 'a', 2 do |s|
+ s.platform = Gem::Platform.local
+ end
+
+ a3_p2 = fetcher.spec 'a', 3 do |s|
+ s.platform = unknown
+ end
end
v2 = v(2)
@@ -709,8 +742,14 @@ class TestGemResolver < Gem::TestCase
r = Gem::Resolver.new nil, nil
a1 = util_spec 'a', 1
- a1_p1 = util_spec 'a', 1 do |s| s.platform = Gem::Platform.local end
- a1_p2 = util_spec 'a', 1 do |s| s.platform = 'unknown' end
+
+ a1_p1 = util_spec 'a', 1 do |s|
+ s.platform = Gem::Platform.local
+ end
+
+ a1_p2 = util_spec 'a', 1 do |s|
+ s.platform = 'unknown'
+ end
selected = r.select_local_platforms [a1, a1_p1, a1_p2]
@@ -719,8 +758,14 @@ class TestGemResolver < Gem::TestCase
def test_search_for_local_platform_partial_string_match
a1 = util_spec 'a', 1
- a1_p1 = util_spec 'a', 1 do |s| s.platform = Gem::Platform.local.os end
- a1_p2 = util_spec 'a', 1 do |s| s.platform = 'unknown' end
+
+ a1_p1 = util_spec 'a', 1 do |s|
+ s.platform = Gem::Platform.local.os
+ end
+
+ a1_p2 = util_spec 'a', 1 do |s|
+ s.platform = 'unknown'
+ end
s = set(a1_p1, a1_p2, a1)
d = [make_dep('a')]
diff --git a/test/rubygems/test_gem_resolver_index_specification.rb b/test/rubygems/test_gem_resolver_index_specification.rb
index 3768dd9bae..43e8efd8b6 100644
--- a/test/rubygems/test_gem_resolver_index_specification.rb
+++ b/test/rubygems/test_gem_resolver_index_specification.rb
@@ -55,7 +55,9 @@ class TestGemResolverIndexSpecification < Gem::TestCase
def test_spec
specs = spec_fetcher do |fetcher|
fetcher.spec 'a', 2
- fetcher.spec 'a', 2 do |s| s.platform = Gem::Platform.local end
+ fetcher.spec 'a', 2 do |s|
+ s.platform = Gem::Platform.local
+ end
end
source = Gem::Source.new @gem_repo
@@ -71,7 +73,10 @@ class TestGemResolverIndexSpecification < Gem::TestCase
end
def test_spec_local
- a_2_p = util_spec 'a', 2 do |s| s.platform = Gem::Platform.local end
+ a_2_p = util_spec 'a', 2 do |s|
+ s.platform = Gem::Platform.local
+ end
+
Gem::Package.build a_2_p
source = Gem::Source::Local.new
diff --git a/test/rubygems/test_gem_resolver_installer_set.rb b/test/rubygems/test_gem_resolver_installer_set.rb
index 50350e2d3d..5138743cdf 100644
--- a/test/rubygems/test_gem_resolver_installer_set.rb
+++ b/test/rubygems/test_gem_resolver_installer_set.rb
@@ -173,7 +173,9 @@ class TestGemResolverInstallerSet < Gem::TestCase
def test_load_spec
specs = spec_fetcher do |fetcher|
fetcher.spec 'a', 2
- fetcher.spec 'a', 2 do |s| s.platform = Gem::Platform.local end
+ fetcher.spec 'a', 2 do |s|
+ s.platform = Gem::Platform.local
+ end
end
source = Gem::Source.new @gem_repo
diff --git a/test/rubygems/test_gem_resolver_specification.rb b/test/rubygems/test_gem_resolver_specification.rb
index c184cea352..e663ff1837 100644
--- a/test/rubygems/test_gem_resolver_specification.rb
+++ b/test/rubygems/test_gem_resolver_specification.rb
@@ -4,6 +4,7 @@ require 'rubygems/test_case'
class TestGemResolverSpecification < Gem::TestCase
class TestSpec < Gem::Resolver::Specification
+
attr_writer :source
attr_reader :spec
@@ -12,6 +13,7 @@ class TestGemResolverSpecification < Gem::TestCase
@spec = spec
end
+
end
def test_install
diff --git a/test/rubygems/test_gem_security.rb b/test/rubygems/test_gem_security.rb
index b5a887abb8..1ba3fa7d9c 100644
--- a/test/rubygems/test_gem_security.rb
+++ b/test/rubygems/test_gem_security.rb
@@ -280,7 +280,7 @@ class TestGemSecurity < Gem::TestCase
assert_path_exists path
- key_from_file = OpenSSL::PKey::RSA.new File.read(path), passphrase
+ key_from_file = OpenSSL::PKey::RSA.new File.read(path), passphrase
assert_equal key.to_pem, key_from_file.to_pem
end
diff --git a/test/rubygems/test_gem_server.rb b/test/rubygems/test_gem_server.rb
index 8a3e6410ae..31ae344784 100644
--- a/test/rubygems/test_gem_server.rb
+++ b/test/rubygems/test_gem_server.rb
@@ -4,10 +4,13 @@ require 'rubygems/server'
require 'stringio'
class Gem::Server
+
attr_reader :server
+
end
class TestGemServer < Gem::TestCase
+
def process_based_port
0
end
@@ -242,7 +245,9 @@ class TestGemServer < Gem::TestCase
end
def test_quick_marshal_a_1_mswin32_gemspec_rz
- quick_gem 'a', '1' do |s| s.platform = Gem::Platform.local end
+ quick_gem 'a', '1' do |s|
+ s.platform = Gem::Platform.local
+ end
data = StringIO.new "GET /quick/Marshal.#{Gem.marshal_version}/a-1-#{Gem::Platform.local}.gemspec.rz HTTP/1.0\r\n\r\n"
@req.parse data
@@ -604,4 +609,5 @@ class TestGemServer < Gem::TestCase
@server.instance_variable_set :@server, webrick
end
+
end
diff --git a/test/rubygems/test_gem_silent_ui.rb b/test/rubygems/test_gem_silent_ui.rb
index 497e2c0eb1..d49166ff6f 100644
--- a/test/rubygems/test_gem_silent_ui.rb
+++ b/test/rubygems/test_gem_silent_ui.rb
@@ -114,4 +114,5 @@ class TestGemSilentUI < Gem::TestCase
assert_empty out, 'No output'
assert_empty err, 'No output'
end
+
end
diff --git a/test/rubygems/test_gem_source.rb b/test/rubygems/test_gem_source.rb
index f8cd031c72..2ed9fc78e7 100644
--- a/test/rubygems/test_gem_source.rb
+++ b/test/rubygems/test_gem_source.rb
@@ -199,16 +199,16 @@ class TestGemSource < Gem::TestCase
installed = Gem::Source::Installed.new
local = Gem::Source::Local.new
- assert_equal( 0, remote. <=>(remote), 'remote <=> remote')
+ assert_equal(0, remote. <=>(remote), 'remote <=> remote')
assert_equal(-1, remote. <=>(specific), 'remote <=> specific')
- assert_equal( 1, specific. <=>(remote), 'specific <=> remote')
+ assert_equal(1, specific. <=>(remote), 'specific <=> remote')
assert_equal(-1, remote. <=>(local), 'remote <=> local')
- assert_equal( 1, local. <=>(remote), 'local <=> remote')
+ assert_equal(1, local. <=>(remote), 'local <=> remote')
assert_equal(-1, remote. <=>(installed), 'remote <=> installed')
- assert_equal( 1, installed.<=>(remote), 'installed <=> remote')
+ assert_equal(1, installed.<=>(remote), 'installed <=> remote')
no_uri = @source.dup
no_uri.instance_variable_set :@uri, nil
@@ -220,9 +220,9 @@ class TestGemSource < Gem::TestCase
sourceA = Gem::Source.new "http://example.com/a"
sourceB = Gem::Source.new "http://example.com/b"
- assert_equal( 0, sourceA. <=>(sourceA), 'sourceA <=> sourceA')
- assert_equal( 1, sourceA. <=>(sourceB), 'sourceA <=> sourceB')
- assert_equal( 1, sourceB. <=>(sourceA), 'sourceB <=> sourceA')
+ assert_equal(0, sourceA. <=>(sourceA), 'sourceA <=> sourceA')
+ assert_equal(1, sourceA. <=>(sourceB), 'sourceA <=> sourceB')
+ assert_equal(1, sourceB. <=>(sourceA), 'sourceB <=> sourceA')
end
def test_update_cache_eh
diff --git a/test/rubygems/test_gem_source_fetch_problem.rb b/test/rubygems/test_gem_source_fetch_problem.rb
index f3b57e8384..65b182890a 100644
--- a/test/rubygems/test_gem_source_fetch_problem.rb
+++ b/test/rubygems/test_gem_source_fetch_problem.rb
@@ -24,4 +24,5 @@ class TestGemSourceFetchProblem < Gem::TestCase
refute_match sf.wordy, 'secret'
end
+
end
diff --git a/test/rubygems/test_gem_source_git.rb b/test/rubygems/test_gem_source_git.rb
index 586e71bae6..2dafcacc8e 100644
--- a/test/rubygems/test_gem_source_git.rb
+++ b/test/rubygems/test_gem_source_git.rb
@@ -208,16 +208,16 @@ class TestGemSourceGit < Gem::TestCase
installed = Gem::Source::Installed.new
vendor = Gem::Source::Vendor.new 'vendor/foo'
- assert_equal( 0, git. <=>(git), 'git <=> git')
+ assert_equal(0, git. <=>(git), 'git <=> git')
- assert_equal( 1, git. <=>(remote), 'git <=> remote')
+ assert_equal(1, git. <=>(remote), 'git <=> remote')
assert_equal(-1, remote. <=>(git), 'remote <=> git')
- assert_equal( 1, git. <=>(installed), 'git <=> installed')
+ assert_equal(1, git. <=>(installed), 'git <=> installed')
assert_equal(-1, installed.<=>(git), 'installed <=> git')
assert_equal(-1, git. <=>(vendor), 'git <=> vendor')
- assert_equal( 1, vendor. <=>(git), 'vendor <=> git')
+ assert_equal(1, vendor. <=>(git), 'vendor <=> git')
end
def test_specs
diff --git a/test/rubygems/test_gem_source_installed.rb b/test/rubygems/test_gem_source_installed.rb
index b469f842fc..b4a75d8d4f 100644
--- a/test/rubygems/test_gem_source_installed.rb
+++ b/test/rubygems/test_gem_source_installed.rb
@@ -15,21 +15,21 @@ class TestGemSourceInstalled < Gem::TestCase
git = Gem::Source::Git.new 'a', 'a', 'master'
vendor = Gem::Source::Vendor.new 'a'
- assert_equal( 0, installed.<=>(installed), 'installed <=> installed')
+ assert_equal(0, installed.<=>(installed), 'installed <=> installed')
assert_equal(-1, remote. <=>(installed), 'remote <=> installed')
- assert_equal( 1, installed.<=>(remote), 'installed <=> remote')
+ assert_equal(1, installed.<=>(remote), 'installed <=> remote')
- assert_equal( 1, installed.<=>(local), 'installed <=> local')
+ assert_equal(1, installed.<=>(local), 'installed <=> local')
assert_equal(-1, local. <=>(installed), 'local <=> installed')
assert_equal(-1, specific. <=>(installed), 'specific <=> installed')
- assert_equal( 1, installed.<=>(specific), 'installed <=> specific')
+ assert_equal(1, installed.<=>(specific), 'installed <=> specific')
- assert_equal( 1, git. <=>(installed), 'git <=> installed')
+ assert_equal(1, git. <=>(installed), 'git <=> installed')
assert_equal(-1, installed.<=>(git), 'installed <=> git')
- assert_equal( 1, vendor. <=>(installed), 'vendor <=> installed')
+ assert_equal(1, vendor. <=>(installed), 'vendor <=> installed')
assert_equal(-1, installed.<=>(vendor), 'installed <=> vendor')
end
diff --git a/test/rubygems/test_gem_source_list.rb b/test/rubygems/test_gem_source_list.rb
index c93e0a8697..b05703f0ba 100644
--- a/test/rubygems/test_gem_source_list.rb
+++ b/test/rubygems/test_gem_source_list.rb
@@ -3,6 +3,7 @@ require 'rubygems/source_list'
require 'rubygems/test_case'
class TestGemSourceList < Gem::TestCase
+
def setup
super
diff --git a/test/rubygems/test_gem_source_local.rb b/test/rubygems/test_gem_source_local.rb
index 7a42cbc76f..2f796f0ed7 100644
--- a/test/rubygems/test_gem_source_local.rb
+++ b/test/rubygems/test_gem_source_local.rb
@@ -5,6 +5,7 @@ require 'rubygems/source'
require 'fileutils'
class TestGemSourceLocal < Gem::TestCase
+
def setup
super
@@ -92,16 +93,16 @@ class TestGemSourceLocal < Gem::TestCase
installed = Gem::Source::Installed.new
local = Gem::Source::Local.new
- assert_equal( 0, local. <=>(local), 'local <=> local')
+ assert_equal(0, local. <=>(local), 'local <=> local')
assert_equal(-1, remote. <=>(local), 'remote <=> local')
- assert_equal( 1, local. <=>(remote), 'local <=> remote')
+ assert_equal(1, local. <=>(remote), 'local <=> remote')
- assert_equal( 1, installed.<=>(local), 'installed <=> local')
+ assert_equal(1, installed.<=>(local), 'installed <=> local')
assert_equal(-1, local. <=>(installed), 'local <=> installed')
assert_equal(-1, specific. <=>(local), 'specific <=> local')
- assert_equal( 1, local. <=>(specific), 'local <=> specific')
+ assert_equal(1, local. <=>(specific), 'local <=> specific')
end
end
diff --git a/test/rubygems/test_gem_source_lock.rb b/test/rubygems/test_gem_source_lock.rb
index 6edfb00e1a..953941b01a 100644
--- a/test/rubygems/test_gem_source_lock.rb
+++ b/test/rubygems/test_gem_source_lock.rb
@@ -40,25 +40,25 @@ class TestGemSourceLock < Gem::TestCase
vendor = Gem::Source::Vendor.new 'vendor/a'
v_lock = Gem::Source::Lock.new vendor
- assert_equal( 0, g_lock.<=>(g_lock), 'g_lock <=> g_lock')
- assert_equal( 0, i_lock.<=>(i_lock), 'i_lock <=> i_lock')
- assert_equal( 0, v_lock.<=>(v_lock), 'v_lock <=> v_lock')
+ assert_equal(0, g_lock.<=>(g_lock), 'g_lock <=> g_lock')
+ assert_equal(0, i_lock.<=>(i_lock), 'i_lock <=> i_lock')
+ assert_equal(0, v_lock.<=>(v_lock), 'v_lock <=> v_lock')
- assert_equal( 1, g_lock.<=>(i_lock), 'g_lock <=> i_lock')
+ assert_equal(1, g_lock.<=>(i_lock), 'g_lock <=> i_lock')
assert_equal(-1, i_lock.<=>(g_lock), 'i_lock <=> g_lock')
assert_equal(-1, g_lock.<=>(v_lock), 'g_lock <=> v_lock')
- assert_equal( 1, v_lock.<=>(g_lock), 'v_lock <=> g_lock')
+ assert_equal(1, v_lock.<=>(g_lock), 'v_lock <=> g_lock')
assert_equal(-1, i_lock.<=>(v_lock), 'i_lock <=> v_lock')
- assert_equal( 1, v_lock.<=>(i_lock), 'i_lock <=> v_lock')
+ assert_equal(1, v_lock.<=>(i_lock), 'i_lock <=> v_lock')
end
def test_spaceship_git
git = Gem::Source::Git.new 'a', 'git/a', 'master', false
lock = Gem::Source::Lock.new git
- assert_equal( 1, lock.<=>(git), 'lock <=> git')
+ assert_equal(1, lock.<=>(git), 'lock <=> git')
assert_equal(-1, git .<=>(lock), 'git <=> lock')
end
@@ -66,7 +66,7 @@ class TestGemSourceLock < Gem::TestCase
installed = Gem::Source::Installed.new
lock = Gem::Source::Lock.new installed
- assert_equal( 1, lock. <=>(installed), 'lock <=> installed')
+ assert_equal(1, lock. <=>(installed), 'lock <=> installed')
assert_equal(-1, installed.<=>(lock), 'installed <=> lock')
end
@@ -74,7 +74,7 @@ class TestGemSourceLock < Gem::TestCase
local = Gem::Source::Local.new
lock = Gem::Source::Lock.new local # nonsense
- assert_equal( 1, lock. <=>(local), 'lock <=> local')
+ assert_equal(1, lock. <=>(local), 'lock <=> local')
assert_equal(-1, local.<=>(lock), 'local <=> lock')
end
@@ -82,7 +82,7 @@ class TestGemSourceLock < Gem::TestCase
remote = Gem::Source.new @gem_repo
lock = Gem::Source::Lock.new remote
- assert_equal( 1, lock. <=>(remote), 'lock <=> remote')
+ assert_equal(1, lock. <=>(remote), 'lock <=> remote')
assert_equal(-1, remote.<=>(lock), 'remote <=> lock')
end
@@ -92,7 +92,7 @@ class TestGemSourceLock < Gem::TestCase
specific = Gem::Source::SpecificFile.new gem
lock = Gem::Source::Lock.new specific # nonsense
- assert_equal( 1, lock .<=>(specific), 'lock <=> specific')
+ assert_equal(1, lock .<=>(specific), 'lock <=> specific')
assert_equal(-1, specific.<=>(lock), 'specific <=> lock')
end
@@ -100,7 +100,7 @@ class TestGemSourceLock < Gem::TestCase
vendor = Gem::Source::Vendor.new 'vendor/a'
lock = Gem::Source::Lock.new vendor
- assert_equal( 1, lock. <=>(vendor), 'lock <=> vendor')
+ assert_equal(1, lock. <=>(vendor), 'lock <=> vendor')
assert_equal(-1, vendor.<=>(lock), 'vendor <=> lock')
end
diff --git a/test/rubygems/test_gem_source_specific_file.rb b/test/rubygems/test_gem_source_specific_file.rb
index 5199f0d1b0..9e4ebaa9c3 100644
--- a/test/rubygems/test_gem_source_specific_file.rb
+++ b/test/rubygems/test_gem_source_specific_file.rb
@@ -3,6 +3,7 @@ require 'rubygems/test_case'
require 'rubygems/source'
class TestGemSourceSpecificFile < Gem::TestCase
+
def setup
super
@@ -45,16 +46,16 @@ class TestGemSourceSpecificFile < Gem::TestCase
installed = Gem::Source::Installed.new
local = Gem::Source::Local.new
- assert_equal( 0, specific. <=>(specific), 'specific <=> specific')
+ assert_equal(0, specific. <=>(specific), 'specific <=> specific')
assert_equal(-1, remote. <=>(specific), 'remote <=> specific')
- assert_equal( 1, specific. <=>(remote), 'specific <=> remote')
+ assert_equal(1, specific. <=>(remote), 'specific <=> remote')
assert_equal(-1, specific. <=>(local), 'specific <=> local')
- assert_equal( 1, local. <=>(specific), 'local <=> specific')
+ assert_equal(1, local. <=>(specific), 'local <=> specific')
assert_equal(-1, specific. <=>(installed), 'specific <=> installed')
- assert_equal( 1, installed.<=>(specific), 'installed <=> specific')
+ assert_equal(1, installed.<=>(specific), 'installed <=> specific')
a2 = quick_gem 'a', '2'
util_build_gem a2
@@ -69,8 +70,8 @@ class TestGemSourceSpecificFile < Gem::TestCase
assert_nil a1_source.<=>(b1_source), 'a1_source <=> b1_source'
assert_equal(-1, a1_source.<=>(a2_source), 'a1_source <=> a2_source')
- assert_equal( 0, a1_source.<=>(a1_source), 'a1_source <=> a1_source')
- assert_equal( 1, a2_source.<=>(a1_source), 'a2_source <=> a1_source')
+ assert_equal(0, a1_source.<=>(a1_source), 'a1_source <=> a1_source')
+ assert_equal(1, a2_source.<=>(a1_source), 'a2_source <=> a1_source')
end
end
diff --git a/test/rubygems/test_gem_source_vendor.rb b/test/rubygems/test_gem_source_vendor.rb
index 3082bb7e68..fafe1a1907 100644
--- a/test/rubygems/test_gem_source_vendor.rb
+++ b/test/rubygems/test_gem_source_vendor.rb
@@ -16,15 +16,15 @@ class TestGemSourceVendor < Gem::TestCase
git = Gem::Source::Git.new 'a', 'a', 'master'
installed = Gem::Source::Installed.new
- assert_equal( 0, vendor. <=>(vendor), 'vendor <=> vendor')
+ assert_equal(0, vendor. <=>(vendor), 'vendor <=> vendor')
- assert_equal( 1, vendor. <=>(remote), 'vendor <=> remote')
+ assert_equal(1, vendor. <=>(remote), 'vendor <=> remote')
assert_equal(-1, remote. <=>(vendor), 'remote <=> vendor')
- assert_equal( 1, vendor. <=>(git), 'vendor <=> git')
+ assert_equal(1, vendor. <=>(git), 'vendor <=> git')
assert_equal(-1, git. <=>(vendor), 'git <=> vendor')
- assert_equal( 1, vendor. <=>(installed), 'vendor <=> installed')
+ assert_equal(1, vendor. <=>(installed), 'vendor <=> installed')
assert_equal(-1, installed.<=>(vendor), 'installed <=> vendor')
end
diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb
index 797e34cd92..75b8b8ed1f 100644
--- a/test/rubygems/test_gem_specification.rb
+++ b/test/rubygems/test_gem_specification.rb
@@ -143,9 +143,9 @@ end
num_of_version_per_pkg = 3
packages = (0..num_of_pkg).map do |pkgi|
(0..num_of_version_per_pkg).map do |pkg_version|
- deps = Hash[((pkgi + 1)..num_of_pkg).map { |deppkgi|
+ deps = Hash[((pkgi + 1)..num_of_pkg).map do |deppkgi|
["pkg#{deppkgi}", ">= 0"]
- }]
+ end]
util_spec "pkg#{pkgi}", pkg_version.to_s, deps
end
end
@@ -156,9 +156,9 @@ end
install_specs base
base.activate
- tms = Benchmark.measure {
+ tms = Benchmark.measure do
assert_raises(LoadError) { require 'no_such_file_foo' }
- }
+ end
assert_operator tms.total, :<=, 10
end
end
@@ -384,7 +384,7 @@ end
# [B] ~> 1.0 (satisfied by 1.0)
def test_self_activate_checks_dependencies
- a = util_spec 'a', '1.0'
+ a = util_spec 'a', '1.0'
a.add_dependency 'c', '= 1.0'
a.add_dependency 'b', '~> 1.0'
@@ -1823,6 +1823,7 @@ dependencies: []
RbConfig::CONFIG['ENABLE_SHARED'], 'no'
class << Gem
+
alias orig_default_ext_dir_for default_ext_dir_for
remove_method :default_ext_dir_for
@@ -1830,6 +1831,7 @@ dependencies: []
def Gem.default_ext_dir_for(base_dir)
'elsewhere'
end
+
end
ext_spec
@@ -1843,9 +1845,11 @@ dependencies: []
RbConfig::CONFIG['ENABLE_SHARED'] = enable_shared
class << Gem
+
remove_method :default_ext_dir_for
alias default_ext_dir_for orig_default_ext_dir_for
+
end
end
@@ -2135,9 +2139,11 @@ dependencies: []
def test_require_paths_default_ext_dir_for
class << Gem
+
send :alias_method, :orig_default_ext_dir_for, :default_ext_dir_for
remove_method :default_ext_dir_for
+
end
def Gem.default_ext_dir_for(base_dir)
@@ -2153,9 +2159,11 @@ dependencies: []
end
ensure
class << Gem
+
send :remove_method, :default_ext_dir_for
send :alias_method, :default_ext_dir_for, :orig_default_ext_dir_for
send :remove_method, :orig_default_ext_dir_for
+
end
end
@@ -2316,8 +2324,8 @@ dependencies: []
s2 = util_spec 'b', '1'
assert_equal(-1, (s1 <=> s2))
- assert_equal( 0, (s1 <=> s1))
- assert_equal( 1, (s2 <=> s1))
+ assert_equal(0, (s1 <=> s1))
+ assert_equal(1, (s2 <=> s1))
end
def test_spaceship_platform
@@ -2326,18 +2334,18 @@ dependencies: []
s.platform = Gem::Platform.new 'x86-my_platform1'
end
- assert_equal( -1, (s1 <=> s2))
- assert_equal( 0, (s1 <=> s1))
- assert_equal( 1, (s2 <=> s1))
+ assert_equal(-1, (s1 <=> s2))
+ assert_equal(0, (s1 <=> s1))
+ assert_equal(1, (s2 <=> s1))
end
def test_spaceship_version
s1 = util_spec 'a', '1'
s2 = util_spec 'a', '2'
- assert_equal( -1, (s1 <=> s2))
- assert_equal( 0, (s1 <=> s1))
- assert_equal( 1, (s2 <=> s1))
+ assert_equal(-1, (s1 <=> s2))
+ assert_equal(0, (s1 <=> s1))
+ assert_equal(1, (s2 <=> s1))
end
def test_spec_file
@@ -2870,7 +2878,7 @@ duplicate dependency on c (>= 1.2.3, development), (~> 1.2) use:
util_setup_validate
FileUtils.mkdir_p File.join(@tempdir, 'bin')
- File.open File.join(@tempdir, 'bin', 'exec'), 'w' do end
+ File.open File.join(@tempdir, 'bin', 'exec'), 'w'
FileUtils.mkdir_p File.join(@tempdir, 'exec')
use_ui @ui do
@@ -3811,4 +3819,5 @@ end
ensure
$VERBOSE = old_verbose
end
+
end
diff --git a/test/rubygems/test_gem_stream_ui.rb b/test/rubygems/test_gem_stream_ui.rb
index 342b7071a6..9b44f3e242 100644
--- a/test/rubygems/test_gem_stream_ui.rb
+++ b/test/rubygems/test_gem_stream_ui.rb
@@ -4,6 +4,7 @@ require 'rubygems/user_interaction'
require 'timeout'
class TestGemStreamUI < Gem::TestCase
+
SHORT_TIMEOUT = (defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled?) ? 1.0 : 0.1 # increase timeout with MJIT for --jit-wait testing
module IsTty
@@ -219,4 +220,5 @@ class TestGemStreamUI < Gem::TestCase
reporter.fetch 'a.gem', 1024
assert_equal "", @out.string
end
+
end
diff --git a/test/rubygems/test_gem_stub_specification.rb b/test/rubygems/test_gem_stub_specification.rb
index 3988206944..13a952d0bd 100644
--- a/test/rubygems/test_gem_stub_specification.rb
+++ b/test/rubygems/test_gem_stub_specification.rb
@@ -3,6 +3,7 @@ require "rubygems/test_case"
require "rubygems/stub_specification"
class TestStubSpecification < Gem::TestCase
+
SPECIFICATIONS = File.expand_path(File.join("..", "specifications"), __FILE__)
FOO = File.join SPECIFICATIONS, "foo-0.0.1-x86-mswin32.gemspec"
BAR = File.join SPECIFICATIONS, "bar-0.0.2.gemspec"
diff --git a/test/rubygems/test_gem_text.rb b/test/rubygems/test_gem_text.rb
index 0249c47f83..4315d358b1 100644
--- a/test/rubygems/test_gem_text.rb
+++ b/test/rubygems/test_gem_text.rb
@@ -3,6 +3,7 @@ require 'rubygems/test_case'
require "rubygems/text"
class TestGemText < Gem::TestCase
+
include Gem::Text
def test_format_text
@@ -89,4 +90,5 @@ Without the wrapping, the text might not look good in the RSS feed.
s = "ab" * 500_001
assert_equal "Truncating desc to 1,000,000 characters:\n#{s[0, 1_000_000]}", truncate_text(s, "desc", 1_000_000)
end
+
end
diff --git a/test/rubygems/test_gem_uninstaller.rb b/test/rubygems/test_gem_uninstaller.rb
index a53526c0bc..126011be99 100644
--- a/test/rubygems/test_gem_uninstaller.rb
+++ b/test/rubygems/test_gem_uninstaller.rb
@@ -368,7 +368,10 @@ create_makefile '#{@spec.name}'
end
def test_uninstall_prompts_about_broken_deps
- quick_gem 'r', '1' do |s| s.add_dependency 'q', '= 1' end
+ quick_gem 'r', '1' do |s|
+ s.add_dependency 'q', '= 1'
+ end
+
quick_gem 'q', '1'
un = Gem::Uninstaller.new('q')
@@ -390,8 +393,14 @@ create_makefile '#{@spec.name}'
end
def test_uninstall_only_lists_unsatisfied_deps
- quick_gem 'r', '1' do |s| s.add_dependency 'q', '~> 1.0' end
- quick_gem 'x', '1' do |s| s.add_dependency 'q', '= 1.0' end
+ quick_gem 'r', '1' do |s|
+ s.add_dependency 'q', '~> 1.0'
+ end
+
+ quick_gem 'x', '1' do |s|
+ s.add_dependency 'q', '= 1.0'
+ end
+
quick_gem 'q', '1.0'
quick_gem 'q', '1.1'
@@ -414,7 +423,10 @@ create_makefile '#{@spec.name}'
end
def test_uninstall_doesnt_prompt_when_other_gem_satisfies_requirement
- quick_gem 'r', '1' do |s| s.add_dependency 'q', '~> 1.0' end
+ quick_gem 'r', '1' do |s|
+ s.add_dependency 'q', '~> 1.0'
+ end
+
quick_gem 'q', '1.0'
quick_gem 'q', '1.1'
@@ -431,7 +443,10 @@ create_makefile '#{@spec.name}'
end
def test_uninstall_doesnt_prompt_when_removing_a_dev_dep
- quick_gem 'r', '1' do |s| s.add_development_dependency 'q', '= 1.0' end
+ quick_gem 'r', '1' do |s|
+ s.add_development_dependency 'q', '= 1.0'
+ end
+
quick_gem 'q', '1.0'
un = Gem::Uninstaller.new('q', :version => "1.0")
@@ -447,7 +462,10 @@ create_makefile '#{@spec.name}'
end
def test_uninstall_doesnt_prompt_and_raises_when_abort_on_dependent_set
- quick_gem 'r', '1' do |s| s.add_dependency 'q', '= 1' end
+ quick_gem 'r', '1' do |s|
+ s.add_dependency 'q', '= 1'
+ end
+
quick_gem 'q', '1'
un = Gem::Uninstaller.new('q', :abort_on_dependent => true)
@@ -502,4 +520,5 @@ create_makefile '#{@spec.name}'
end
end
end
+
end
diff --git a/test/rubygems/test_gem_util.rb b/test/rubygems/test_gem_util.rb
index 88afc62976..a48d275d28 100644
--- a/test/rubygems/test_gem_util.rb
+++ b/test/rubygems/test_gem_util.rb
@@ -51,9 +51,9 @@ class TestGemUtil < Gem::TestCase
end
def test_linked_list_find
- list = [1,2,3,4,5].inject(Gem::List.new(0)) { |m,o|
+ list = [1,2,3,4,5].inject(Gem::List.new(0)) do |m,o|
Gem::List.new o, m
- }
+ end
assert_equal 5, list.find { |x| x == 5 }
assert_equal 4, list.find { |x| x == 4 }
end
diff --git a/test/rubygems/test_gem_version.rb b/test/rubygems/test_gem_version.rb
index 939360c7a2..6d3893c256 100644
--- a/test/rubygems/test_gem_version.rb
+++ b/test/rubygems/test_gem_version.rb
@@ -148,14 +148,14 @@ class TestGemVersion < Gem::TestCase
end
def test_spaceship
- assert_equal( 0, v("1.0") <=> v("1.0.0"))
- assert_equal( 1, v("1.0") <=> v("1.0.a"))
- assert_equal( 1, v("1.8.2") <=> v("0.0.0"))
- assert_equal( 1, v("1.8.2") <=> v("1.8.2.a"))
- assert_equal( 1, v("1.8.2.b") <=> v("1.8.2.a"))
- assert_equal(-1, v("1.8.2.a") <=> v("1.8.2"))
- assert_equal( 1, v("1.8.2.a10") <=> v("1.8.2.a9"))
- assert_equal( 0, v("") <=> v("0"))
+ assert_equal(0, v("1.0") <=> v("1.0.0"))
+ assert_equal(1, v("1.0") <=> v("1.0.a"))
+ assert_equal(1, v("1.8.2") <=> v("0.0.0"))
+ assert_equal(1, v("1.8.2") <=> v("1.8.2.a"))
+ assert_equal(1, v("1.8.2.b") <=> v("1.8.2.a"))
+ assert_equal(-1, v("1.8.2.a") <=> v("1.8.2"))
+ assert_equal(1, v("1.8.2.a10") <=> v("1.8.2.a9"))
+ assert_equal(0, v("") <=> v("0"))
assert_nil v("1.0") <=> "whatever"
end
@@ -284,4 +284,5 @@ class TestGemVersion < Gem::TestCase
def refute_version_equal(unexpected, actual)
refute_equal v(unexpected), v(actual)
end
+
end
diff --git a/test/rubygems/test_kernel.rb b/test/rubygems/test_kernel.rb
index f7d3988ce3..b9f9b5e254 100644
--- a/test/rubygems/test_kernel.rb
+++ b/test/rubygems/test_kernel.rb
@@ -120,4 +120,5 @@ class TestKernel < Gem::TestCase
assert $:.any? { |p| %r{bundler-1/lib} =~ p }
end
end
+
end
diff --git a/test/rubygems/test_remote_fetch_error.rb b/test/rubygems/test_remote_fetch_error.rb
index 432c48b878..780e5e79f7 100644
--- a/test/rubygems/test_remote_fetch_error.rb
+++ b/test/rubygems/test_remote_fetch_error.rb
@@ -17,4 +17,5 @@ class TestRemoteFetchError < Gem::TestCase
error = Gem::RemoteFetcher::FetchError.new('There was an error fetching', 'https://gemsource.org')
assert_equal error.to_s, 'There was an error fetching (https://gemsource.org)'
end
+
end
diff --git a/test/rubygems/test_require.rb b/test/rubygems/test_require.rb
index e3bdc218f7..846826c3f1 100644
--- a/test/rubygems/test_require.rb
+++ b/test/rubygems/test_require.rb
@@ -3,7 +3,9 @@ require 'rubygems/test_case'
require 'rubygems'
class TestGemRequire < Gem::TestCase
+
class Latch
+
def initialize(count = 1)
@count = count
@lock = Monitor.new
@@ -22,6 +24,7 @@ class TestGemRequire < Gem::TestCase
@cv.wait_while { @count > 0 }
end
end
+
end
def setup
@@ -331,8 +334,10 @@ class TestGemRequire < Gem::TestCase
def test_try_activate_error_unlocks_require_monitor
silence_warnings do
class << ::Gem
+
alias old_try_activate try_activate
def try_activate(*); raise 'raised from try_activate'; end
+
end
end
@@ -343,7 +348,9 @@ class TestGemRequire < Gem::TestCase
ensure
silence_warnings do
class << ::Gem
+
alias try_activate old_try_activate
+
end
end
Kernel::RUBYGEMS_ACTIVATION_MONITOR.exit
@@ -436,4 +443,5 @@ class TestGemRequire < Gem::TestCase
ensure
$VERBOSE = old_verbose
end
+
end