summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/bundler/cli.rb8
-rw-r--r--lib/bundler/cli/install.rb7
-rw-r--r--lib/bundler/cli/outdated.rb15
-rw-r--r--lib/bundler/cli/platform.rb2
-rw-r--r--lib/bundler/definition.rb72
-rw-r--r--lib/bundler/fetcher.rb12
-rw-r--r--lib/bundler/gem_helpers.rb8
-rw-r--r--lib/bundler/incomplete_specification.rb12
-rw-r--r--lib/bundler/installer.rb9
-rw-r--r--lib/bundler/installer/standalone.rb2
-rw-r--r--lib/bundler/lazy_specification.rb42
-rw-r--r--lib/bundler/man/bundle-cache.16
-rw-r--r--lib/bundler/man/bundle-cache.1.ronn7
-rw-r--r--lib/bundler/man/bundle-config.14
-rw-r--r--lib/bundler/man/bundle-config.1.ronn6
-rw-r--r--lib/bundler/man/bundle-install.14
-rw-r--r--lib/bundler/man/bundle-install.1.ronn6
-rw-r--r--lib/bundler/man/bundle-platform.120
-rw-r--r--lib/bundler/man/bundle-platform.1.ronn21
-rw-r--r--lib/bundler/man/bundle.19
-rw-r--r--lib/bundler/man/bundle.1.ronn7
-rw-r--r--lib/bundler/resolver.rb3
-rw-r--r--lib/bundler/ruby_dsl.rb2
-rw-r--r--lib/bundler/ruby_version.rb10
-rw-r--r--lib/bundler/rubygems_ext.rb13
-rw-r--r--lib/bundler/source/metadata.rb2
-rw-r--r--lib/bundler/source_list.rb4
-rw-r--r--lib/bundler/spec_set.rb43
-rw-r--r--lib/bundler/version.rb2
-rw-r--r--lib/rubygems.rb16
-rw-r--r--lib/rubygems/available_set.rb6
-rw-r--r--lib/rubygems/basic_specification.rb4
-rw-r--r--lib/rubygems/command.rb12
-rw-r--r--lib/rubygems/commands/cert_command.rb2
-rw-r--r--lib/rubygems/commands/cleanup_command.rb2
-rw-r--r--lib/rubygems/commands/contents_command.rb2
-rw-r--r--lib/rubygems/commands/dependency_command.rb8
-rw-r--r--lib/rubygems/commands/fetch_command.rb4
-rw-r--r--lib/rubygems/commands/generate_index_command.rb4
-rw-r--r--lib/rubygems/commands/install_command.rb14
-rw-r--r--lib/rubygems/commands/pristine_command.rb10
-rw-r--r--lib/rubygems/commands/setup_command.rb8
-rw-r--r--lib/rubygems/commands/sources_command.rb6
-rw-r--r--lib/rubygems/commands/specification_command.rb4
-rw-r--r--lib/rubygems/commands/uninstall_command.rb8
-rw-r--r--lib/rubygems/commands/update_command.rb10
-rw-r--r--lib/rubygems/commands/which_command.rb2
-rw-r--r--lib/rubygems/config_file.rb14
-rw-r--r--lib/rubygems/core_ext/kernel_warn.rb2
-rw-r--r--lib/rubygems/defaults.rb2
-rw-r--r--lib/rubygems/dependency.rb10
-rw-r--r--lib/rubygems/dependency_installer.rb10
-rw-r--r--lib/rubygems/dependency_list.rb8
-rw-r--r--lib/rubygems/doctor.rb8
-rw-r--r--lib/rubygems/exceptions.rb2
-rw-r--r--lib/rubygems/ext/ext_conf_builder.rb4
-rw-r--r--lib/rubygems/gemcutter_utilities.rb2
-rw-r--r--lib/rubygems/indexer.rb6
-rw-r--r--lib/rubygems/installer.rb18
-rw-r--r--lib/rubygems/name_tuple.rb6
-rw-r--r--lib/rubygems/package.rb27
-rw-r--r--lib/rubygems/package/tar_header.rb34
-rw-r--r--lib/rubygems/package/tar_writer.rb2
-rw-r--r--lib/rubygems/platform.rb30
-rw-r--r--lib/rubygems/query_utils.rb12
-rw-r--r--lib/rubygems/remote_fetcher.rb6
-rw-r--r--lib/rubygems/request.rb2
-rw-r--r--lib/rubygems/request/connection_pools.rb4
-rw-r--r--lib/rubygems/request/http_pool.rb2
-rw-r--r--lib/rubygems/request_set.rb6
-rw-r--r--lib/rubygems/request_set/gem_dependency_api.rb6
-rw-r--r--lib/rubygems/request_set/lockfile/parser.rb24
-rw-r--r--lib/rubygems/request_set/lockfile/tokenizer.rb4
-rw-r--r--lib/rubygems/requirement.rb2
-rw-r--r--lib/rubygems/resolver.rb8
-rw-r--r--lib/rubygems/resolver/api_specification.rb8
-rw-r--r--lib/rubygems/resolver/best_set.rb6
-rw-r--r--lib/rubygems/resolver/conflict.rb6
-rw-r--r--lib/rubygems/resolver/git_specification.rb6
-rw-r--r--lib/rubygems/resolver/index_specification.rb5
-rw-r--r--lib/rubygems/resolver/installed_specification.rb4
-rw-r--r--lib/rubygems/resolver/installer_set.rb19
-rw-r--r--lib/rubygems/resolver/lock_set.rb2
-rw-r--r--lib/rubygems/resolver/lock_specification.rb2
-rw-r--r--lib/rubygems/resolver/vendor_specification.rb6
-rw-r--r--lib/rubygems/security.rb2
-rw-r--r--lib/rubygems/security/policy.rb12
-rw-r--r--lib/rubygems/security/signer.rb2
-rw-r--r--lib/rubygems/source.rb2
-rw-r--r--lib/rubygems/source/git.rb8
-rw-r--r--lib/rubygems/spec_fetcher.rb2
-rw-r--r--lib/rubygems/specification.rb50
-rw-r--r--lib/rubygems/specification_policy.rb8
-rw-r--r--lib/rubygems/uninstaller.rb8
-rw-r--r--lib/rubygems/user_interaction.rb4
-rw-r--r--lib/rubygems/version.rb16
-rw-r--r--spec/bundler/bundler/ruby_version_spec.rb10
-rw-r--r--spec/bundler/commands/install_spec.rb32
-rw-r--r--spec/bundler/commands/lock_spec.rb4
-rw-r--r--spec/bundler/commands/outdated_spec.rb205
-rw-r--r--spec/bundler/commands/platform_spec.rb (renamed from spec/bundler/other/platform_spec.rb)18
-rw-r--r--spec/bundler/commands/update_spec.rb10
-rw-r--r--spec/bundler/install/gemfile/ruby_spec.rb14
-rw-r--r--spec/bundler/install/gemfile/specific_platform_spec.rb118
-rw-r--r--spec/bundler/install/gems/resolving_spec.rb101
-rw-r--r--spec/bundler/install/gems/standalone_spec.rb28
-rw-r--r--spec/bundler/install/gemspecs_spec.rb3
-rw-r--r--spec/bundler/install/yanked_spec.rb57
-rw-r--r--spec/bundler/lock/lockfile_spec.rb4
-rw-r--r--spec/bundler/resolver/basic_spec.rb2
-rw-r--r--spec/bundler/support/helpers.rb2
-rw-r--r--spec/bundler/support/platforms.rb2
-rw-r--r--test/rubygems/helper.rb10
-rw-r--r--test/rubygems/test_gem_config_file.rb22
-rw-r--r--test/rubygems/test_gem_dependency_installer.rb4
-rw-r--r--test/rubygems/test_gem_ext_cargo_builder/custom_name/Cargo.lock8
-rw-r--r--test/rubygems/test_gem_ext_cargo_builder/custom_name/Cargo.toml2
-rw-r--r--test/rubygems/test_gem_ext_cargo_builder/custom_name/build.rb2
-rw-r--r--test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.lock8
-rw-r--r--test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.toml2
-rw-r--r--test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/build.rb2
-rw-r--r--test/rubygems/test_gem_installer.rb9
-rw-r--r--test/rubygems/test_gem_package.rb22
-rw-r--r--test/rubygems/test_gem_package_tar_reader.rb2
-rw-r--r--test/rubygems/test_gem_requirement.rb12
-rw-r--r--test/rubygems/test_gem_resolver_index_specification.rb2
-rw-r--r--test/rubygems/test_gem_resolver_installer_set.rb44
-rw-r--r--test/rubygems/test_gem_specification.rb13
-rw-r--r--test/rubygems/test_gem_version.rb11
-rw-r--r--test/rubygems/test_require.rb2
-rw-r--r--test/rubygems/utilities.rb8
-rw-r--r--tool/bundler/dev_gems.rb.lock2
-rw-r--r--tool/bundler/rubocop_gems.rb.lock2
-rw-r--r--tool/bundler/standard_gems.rb.lock2
-rw-r--r--tool/bundler/test_gems.rb.lock2
135 files changed, 1120 insertions, 602 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index e1c284130b..5bf0f4fa3a 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -218,6 +218,8 @@ module Bundler
"Specify the number of jobs to run in parallel"
method_option "local", :type => :boolean, :banner =>
"Do not attempt to fetch gems remotely and use the gem cache instead"
+ method_option "prefer-local", :type => :boolean, :banner =>
+ "Only attempt to fetch gems remotely if not present locally, even if newer versions are available remotely"
method_option "no-cache", :type => :boolean, :banner =>
"Don't update the existing gem cache."
method_option "redownload", :type => :boolean, :aliases => "--force", :banner =>
@@ -236,7 +238,7 @@ module Bundler
"Install to the system location ($BUNDLE_PATH or $GEM_HOME) even if the bundle was previously installed somewhere else for this application"
method_option "trust-policy", :alias => "P", :type => :string, :banner =>
"Gem trust policy (like gem install -P). Must be one of " +
- Bundler.rubygems.security_policy_keys.join("|")
+ Bundler.rubygems.security_policy_keys.join("|")
method_option "without", :type => :array, :banner =>
"Exclude gems that are part of the specified named group."
method_option "with", :type => :array, :banner =>
@@ -399,9 +401,9 @@ module Bundler
"Do not attempt to fetch gems remotely and use the gem cache instead"
method_option "pre", :type => :boolean, :banner => "Check for newer pre-release gems"
method_option "source", :type => :array, :banner => "Check against a specific source"
- method_option "filter-strict", :type => :boolean, :banner =>
+ method_option "filter-strict", :type => :boolean, :aliases => "--strict", :banner =>
"Only list newer versions allowed by your Gemfile requirements"
- method_option "strict", :type => :boolean, :aliases => "--update-strict", :banner =>
+ method_option "update-strict", :type => :boolean, :banner =>
"Strict conservative resolution, do not allow any gem to be updated past latest --patch | --minor | --major"
method_option "minor", :type => :boolean, :banner => "Prefer updating only to next minor version"
method_option "major", :type => :boolean, :banner => "Prefer updating to next major version (default)"
diff --git a/lib/bundler/cli/install.rb b/lib/bundler/cli/install.rb
index e9b85f7f6f..851ae9b840 100644
--- a/lib/bundler/cli/install.rb
+++ b/lib/bundler/cli/install.rb
@@ -147,8 +147,11 @@ module Bundler
def normalize_settings
Bundler.settings.set_command_option :path, nil if options[:system]
Bundler.settings.set_command_option_if_given :path, options[:path]
- Bundler.settings.temporary(:path_relative_to_cwd => false) do
- Bundler.settings.set_command_option :path, "bundle" if options["standalone"] && Bundler.settings[:path].nil?
+
+ if options["standalone"] && Bundler.settings[:path].nil? && !options["local"]
+ Bundler.settings.temporary(:path_relative_to_cwd => false) do
+ Bundler.settings.set_command_option :path, "bundle"
+ end
end
bin_option = options["binstubs"]
diff --git a/lib/bundler/cli/outdated.rb b/lib/bundler/cli/outdated.rb
index d5183b060b..e9f93fec39 100644
--- a/lib/bundler/cli/outdated.rb
+++ b/lib/bundler/cli/outdated.rb
@@ -46,7 +46,7 @@ module Bundler
Bundler::CLI::Common.configure_gem_version_promoter(
Bundler.definition,
- options
+ options.merge(:strict => @strict)
)
definition_resolution = proc do
@@ -129,6 +129,12 @@ module Bundler
private
+ def loaded_from_for(spec)
+ return unless spec.respond_to?(:loaded_from)
+
+ spec.loaded_from
+ end
+
def groups_text(group_text, groups)
"#{group_text}#{groups.split(",").size > 1 ? "s" : ""} \"#{groups}\""
end
@@ -184,7 +190,10 @@ module Bundler
def print_gem(current_spec, active_spec, dependency, groups)
spec_version = "#{active_spec.version}#{active_spec.git_version}"
- spec_version += " (from #{active_spec.loaded_from})" if Bundler.ui.debug? && active_spec.loaded_from
+ if Bundler.ui.debug?
+ loaded_from = loaded_from_for(active_spec)
+ spec_version += " (from #{loaded_from})" if loaded_from
+ end
current_version = "#{current_spec.version}#{current_spec.git_version}"
if dependency && dependency.specific?
@@ -211,7 +220,7 @@ module Bundler
dependency = dependency.requirement if dependency
ret_val = [active_spec.name, current_version, spec_version, dependency.to_s, groups.to_s]
- ret_val << active_spec.loaded_from.to_s if Bundler.ui.debug?
+ ret_val << loaded_from_for(active_spec).to_s if Bundler.ui.debug?
ret_val
end
diff --git a/lib/bundler/cli/platform.rb b/lib/bundler/cli/platform.rb
index 068c765aad..16d4e0145a 100644
--- a/lib/bundler/cli/platform.rb
+++ b/lib/bundler/cli/platform.rb
@@ -9,7 +9,7 @@ module Bundler
def run
platforms, ruby_version = Bundler.ui.silence do
- locked_ruby_version = Bundler.locked_gems && Bundler.locked_gems.ruby_version
+ locked_ruby_version = Bundler.locked_gems && Bundler.locked_gems.ruby_version.gsub(/p\d+\Z/, "")
gemfile_ruby_version = Bundler.definition.ruby_version && Bundler.definition.ruby_version.single_version_string
[Bundler.definition.platforms.map {|p| "* #{p}" },
locked_ruby_version || gemfile_ruby_version]
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index d55ee29ebc..21c06e55ba 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -70,6 +70,7 @@ module Bundler
@unlock = unlock
@optional_groups = optional_groups
@remote = false
+ @prefer_local = false
@specs = nil
@ruby_version = ruby_version
@gemfiles = gemfiles
@@ -170,6 +171,13 @@ module Bundler
resolve
end
+ def resolve_prefering_local!
+ @prefer_local = true
+ @remote = true
+ sources.remote!
+ resolve
+ end
+
def resolve_with_cache!
sources.cached!
resolve
@@ -476,6 +484,7 @@ module Bundler
def reresolve
last_resolve = converge_locked_specs
+ remove_ruby_from_platforms_if_necessary!(dependencies)
expanded_dependencies = expand_dependencies(dependencies + metadata_dependencies, true)
Resolver.resolve(expanded_dependencies, source_requirements, last_resolve, gem_version_promoter, additional_base_requirements_for_resolve, platforms)
end
@@ -516,10 +525,8 @@ module Bundler
end
end
- unless specs["bundler"].any?
- bundler = sources.metadata_source.specs.search(Gem::Dependency.new("bundler", VERSION)).last
- specs["bundler"] = bundler
- end
+ bundler = sources.metadata_source.specs.search(Gem::Dependency.new("bundler", VERSION)).last
+ specs["bundler"] = bundler
specs
end
@@ -528,6 +535,19 @@ module Bundler
@remote && sources.non_global_rubygems_sources.all?(&:dependency_api_available?) && !sources.aggregate_global_source?
end
+ def pin_locally_available_names(source_requirements)
+ source_requirements.each_with_object({}) do |(name, original_source), new_source_requirements|
+ local_source = original_source.dup
+ local_source.local_only!
+
+ new_source_requirements[name] = if local_source.specs.search(name).any?
+ local_source
+ else
+ original_source
+ end
+ end
+ end
+
def current_ruby_platform_locked?
return false unless generic_local_platform == Gem::Platform::RUBY
return false if Bundler.settings[:force_ruby_platform] && !@platforms.include?(Gem::Platform::RUBY)
@@ -719,16 +739,24 @@ module Bundler
specs[dep].any? {|s| s.satisfies?(dep) && (!dep.source || s.source.include?(dep.source)) }
end
+ @specs_that_changed_sources = []
+
specs.each do |s|
- # Replace the locked dependency's source with the equivalent source from the Gemfile
dep = @dependencies.find {|d| s.satisfies?(d) }
- s.source = (dep && dep.source) || sources.get(s.source) || sources.default_source
+ # Replace the locked dependency's source with the equivalent source from the Gemfile
+ s.source = if dep && dep.source
+ gemfile_source = dep.source
+ lockfile_source = s.source
- next if @unlock[:sources].include?(s.source.name)
+ @specs_that_changed_sources << s if gemfile_source != lockfile_source
- # If the spec is from a path source and it doesn't exist anymore
- # then we unlock it.
+ gemfile_source
+ else
+ sources.get_with_fallback(s.source)
+ end
+
+ next if @unlock[:sources].include?(s.source.name)
# Path sources have special logic
if s.source.instance_of?(Source::Path) || s.source.instance_of?(Source::Gemspec)
@@ -765,7 +793,7 @@ module Bundler
def metadata_dependencies
@metadata_dependencies ||= [
- Dependency.new("Ruby\0", RubyVersion.system.gem_version),
+ Dependency.new("Ruby\0", Gem.ruby_version),
Dependency.new("RubyGems\0", Gem::VERSION),
]
end
@@ -792,7 +820,9 @@ module Bundler
# specs will be available later when the resolver knows where to
# look for that gemspec (or its dependencies)
source_requirements = if precompute_source_requirements_for_indirect_dependencies?
- { :default => sources.default_source }.merge(source_map.all_requirements)
+ all_requirements = source_map.all_requirements
+ all_requirements = pin_locally_available_names(all_requirements) if @prefer_local
+ { :default => sources.default_source }.merge(all_requirements)
else
{ :default => Source::RubygemsAggregate.new(sources, source_map) }.merge(source_map.direct_requirements)
end
@@ -802,9 +832,18 @@ module Bundler
end
source_requirements[:default_bundler] = source_requirements["bundler"] || sources.default_source
source_requirements["bundler"] = sources.metadata_source # needs to come last to override
+ verify_changed_sources!
source_requirements
end
+ def verify_changed_sources!
+ @specs_that_changed_sources.each do |s|
+ if s.source.specs.search(s.name).empty?
+ raise GemNotFound, "Could not find gem '#{s.name}' in #{s.source}"
+ end
+ end
+ end
+
def requested_groups
values = groups - Bundler.settings[:without] - @optional_groups + Bundler.settings[:with]
values &= Bundler.settings[:only] unless Bundler.settings[:only].empty?
@@ -844,6 +883,17 @@ module Bundler
end
end
+ def remove_ruby_from_platforms_if_necessary!(dependencies)
+ return if Bundler.frozen_bundle? ||
+ Bundler.local_platform == Gem::Platform::RUBY ||
+ !platforms.include?(Gem::Platform::RUBY) ||
+ (@new_platform && platforms.last == Gem::Platform::RUBY) ||
+ !@originally_locked_specs.incomplete_ruby_specs?(dependencies)
+
+ remove_platform(Gem::Platform::RUBY)
+ add_current_platform
+ end
+
def source_map
@source_map ||= SourceMap.new(sources, dependencies, @locked_specs)
end
diff --git a/lib/bundler/fetcher.rb b/lib/bundler/fetcher.rb
index e9d5dd505c..e399a50cfd 100644
--- a/lib/bundler/fetcher.rb
+++ b/lib/bundler/fetcher.rb
@@ -240,8 +240,8 @@ module Bundler
def connection
@connection ||= begin
needs_ssl = remote_uri.scheme == "https" ||
- Bundler.settings[:ssl_verify_mode] ||
- Bundler.settings[:ssl_client_cert]
+ Bundler.settings[:ssl_verify_mode] ||
+ Bundler.settings[:ssl_client_cert]
raise SSLError if needs_ssl && !defined?(OpenSSL::SSL)
con = PersistentHTTP.new :name => "bundler", :proxy => :ENV
@@ -256,8 +256,8 @@ module Bundler
end
ssl_client_cert = Bundler.settings[:ssl_client_cert] ||
- (Gem.configuration.ssl_client_cert if
- Gem.configuration.respond_to?(:ssl_client_cert))
+ (Gem.configuration.ssl_client_cert if
+ Gem.configuration.respond_to?(:ssl_client_cert))
if ssl_client_cert
pem = File.read(ssl_client_cert)
con.cert = OpenSSL::X509::Certificate.new(pem)
@@ -288,8 +288,8 @@ module Bundler
def bundler_cert_store
store = OpenSSL::X509::Store.new
ssl_ca_cert = Bundler.settings[:ssl_ca_cert] ||
- (Gem.configuration.ssl_ca_cert if
- Gem.configuration.respond_to?(:ssl_ca_cert))
+ (Gem.configuration.ssl_ca_cert if
+ Gem.configuration.respond_to?(:ssl_ca_cert))
if ssl_ca_cert
if File.directory? ssl_ca_cert
store.add_path ssl_ca_cert
diff --git a/lib/bundler/gem_helpers.rb b/lib/bundler/gem_helpers.rb
index 6bc4fb4991..0d50d8687b 100644
--- a/lib/bundler/gem_helpers.rb
+++ b/lib/bundler/gem_helpers.rb
@@ -44,6 +44,12 @@ module Bundler
def select_best_platform_match(specs, platform)
matching = specs.select {|spec| spec.match_platform(platform) }
+
+ sort_best_platform_match(matching, platform)
+ end
+ module_function :select_best_platform_match
+
+ def sort_best_platform_match(matching, platform)
exact = matching.select {|spec| spec.platform == platform }
return exact if exact.any?
@@ -52,7 +58,7 @@ module Bundler
sorted_matching.take_while {|spec| same_specificity(platform, spec, exemplary_spec) && same_deps(spec, exemplary_spec) }
end
- module_function :select_best_platform_match
+ module_function :sort_best_platform_match
class PlatformMatch
def self.specificity_score(spec_platform, user_platform)
diff --git a/lib/bundler/incomplete_specification.rb b/lib/bundler/incomplete_specification.rb
new file mode 100644
index 0000000000..6d0b9b901c
--- /dev/null
+++ b/lib/bundler/incomplete_specification.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+module Bundler
+ class IncompleteSpecification
+ attr_reader :name, :platform
+
+ def initialize(name, platform)
+ @name = name
+ @platform = platform
+ end
+ end
+end
diff --git a/lib/bundler/installer.rb b/lib/bundler/installer.rb
index f195d36600..b7b0e36dfd 100644
--- a/lib/bundler/installer.rb
+++ b/lib/bundler/installer.rb
@@ -268,7 +268,14 @@ module Bundler
return false if @definition.nothing_changed? && !@definition.missing_specs?
end
- options["local"] ? @definition.resolve_with_cache! : @definition.resolve_remotely!
+ if options["local"]
+ @definition.resolve_with_cache!
+ elsif options["prefer-local"]
+ @definition.resolve_prefering_local!
+ else
+ @definition.resolve_remotely!
+ end
+
true
end
diff --git a/lib/bundler/installer/standalone.rb b/lib/bundler/installer/standalone.rb
index 248b677233..2756626f8a 100644
--- a/lib/bundler/installer/standalone.rb
+++ b/lib/bundler/installer/standalone.rb
@@ -47,7 +47,7 @@ module Bundler
end
def bundler_path
- Bundler.root.join(Bundler.settings[:path], "bundler")
+ Bundler.root.join(Bundler.settings[:path].to_s, "bundler")
end
def gem_path(path, spec)
diff --git a/lib/bundler/lazy_specification.rb b/lib/bundler/lazy_specification.rb
index 21e75d2126..5b40bec5a8 100644
--- a/lib/bundler/lazy_specification.rb
+++ b/lib/bundler/lazy_specification.rb
@@ -76,35 +76,35 @@ module Bundler
end
def materialize_for_installation
- __materialize__(ruby_platform_materializes_to_ruby_platform? ? platform : Bundler.local_platform)
- end
+ source.local!
+
+ candidates = if source.is_a?(Source::Path) || !ruby_platform_materializes_to_ruby_platform?
+ target_platform = ruby_platform_materializes_to_ruby_platform? ? platform : Bundler.local_platform
+
+ source.specs.search(Dependency.new(name, version)).select do |spec|
+ MatchPlatform.platforms_match?(spec.platform, target_platform)
+ end
+ else
+ source.specs.search(self)
+ end
- def materialize_for_resolution
- return self unless Gem::Platform.match_spec?(self)
+ return self if candidates.empty?
- __materialize__(platform)
+ __materialize__(candidates)
end
- def __materialize__(platform)
- @specification = if source.is_a?(Source::Gemspec) && source.gemspec.name == name
- source.gemspec.tap {|s| s.source = source }
- else
- search_object = if source.is_a?(Source::Path)
- Dependency.new(name, version)
- else
- ruby_platform_materializes_to_ruby_platform? ? self : Dependency.new(name, version)
- end
- candidates = source.specs.search(search_object)
- same_platform_candidates = candidates.select do |spec|
- MatchPlatform.platforms_match?(spec.platform, platform)
- end
- installable_candidates = same_platform_candidates.select do |spec|
+ def __materialize__(candidates)
+ @specification = begin
+ search = candidates.reverse.find do |spec|
spec.is_a?(StubSpecification) ||
(spec.required_ruby_version.satisfied_by?(Gem.ruby_version) &&
spec.required_rubygems_version.satisfied_by?(Gem.rubygems_version))
end
- search = installable_candidates.last || same_platform_candidates.last
- search.dependencies = dependencies if search && (search.is_a?(RemoteSpecification) || search.is_a?(EndpointSpecification))
+ if search.nil? && Bundler.frozen_bundle?
+ search = candidates.last
+ else
+ search.dependencies = dependencies if search && search.full_name == full_name && (search.is_a?(RemoteSpecification) || search.is_a?(EndpointSpecification))
+ end
search
end
end
diff --git a/lib/bundler/man/bundle-cache.1 b/lib/bundler/man/bundle-cache.1
index 4903015881..fdaaa3b92a 100644
--- a/lib/bundler/man/bundle-cache.1
+++ b/lib/bundler/man/bundle-cache.1
@@ -9,6 +9,9 @@
.SH "SYNOPSIS"
\fBbundle cache\fR
.
+.P
+alias: \fBpackage\fR, \fBpack\fR
+.
.SH "DESCRIPTION"
Copy all of the \fB\.gem\fR files needed to run the application into the \fBvendor/cache\fR directory\. In the future, when running [bundle install(1)][bundle\-install], use the gems in the cache in preference to the ones on \fBrubygems\.org\fR\.
.
@@ -53,3 +56,6 @@ One way to be sure that you have the right platformed versions of all your gems
.
.P
By default, bundle cache(1) \fIbundle\-cache\.1\.html\fR fetches and also installs the gems to the default location\. To package the dependencies to \fBvendor/cache\fR without installing them to the local install location, you can run \fBbundle cache \-\-no\-install\fR\.
+.
+.SH "HISTORY"
+In Bundler 2\.1, \fBcache\fR took in the functionalities of \fBpackage\fR and now \fBpackage\fR and \fBpack\fR are aliases of \fBcache\fR\.
diff --git a/lib/bundler/man/bundle-cache.1.ronn b/lib/bundler/man/bundle-cache.1.ronn
index 383adb2ba3..46906d2b48 100644
--- a/lib/bundler/man/bundle-cache.1.ronn
+++ b/lib/bundler/man/bundle-cache.1.ronn
@@ -5,6 +5,8 @@ bundle-cache(1) -- Package your needed `.gem` files into your application
`bundle cache`
+alias: `package`, `pack`
+
## DESCRIPTION
Copy all of the `.gem` files needed to run the application into the
@@ -70,3 +72,8 @@ By default, [bundle cache(1)](bundle-cache.1.html) fetches and also
installs the gems to the default location. To package the
dependencies to `vendor/cache` without installing them to the
local install location, you can run `bundle cache --no-install`.
+
+## HISTORY
+
+In Bundler 2.1, `cache` took in the functionalities of `package` and now
+`package` and `pack` are aliases of `cache`.
diff --git a/lib/bundler/man/bundle-config.1 b/lib/bundler/man/bundle-config.1
index b5cee57f29..9f7887ca91 100644
--- a/lib/bundler/man/bundle-config.1
+++ b/lib/bundler/man/bundle-config.1
@@ -51,7 +51,7 @@ Executing \fBbundle config unset <name>\fR will delete the configuration in both
Executing \fBbundle config unset \-\-global <name>\fR will delete the configuration only from the user configuration\.
.
.P
-Executing \fBbundle config unset \-\-local <name> <value>\fR will delete the configuration only from the local application\.
+Executing \fBbundle config unset \-\-local <name>\fR will delete the configuration only from the local application\.
.
.P
Executing bundle with the \fBBUNDLE_IGNORE_CONFIG\fR environment variable set will cause it to ignore all configuration\.
@@ -298,7 +298,7 @@ The following is a list of all configuration keys and their purpose\. You can le
.IP "" 0
.
.P
-In general, you should set these settings per\-application by using the applicable flag to the bundle install(1) \fIbundle\-install\.1\.html\fR or bundle package(1) \fIbundle\-package\.1\.html\fR command\.
+In general, you should set these settings per\-application by using the applicable flag to the bundle install(1) \fIbundle\-install\.1\.html\fR or bundle cache(1) \fIbundle\-cache\.1\.html\fR command\.
.
.P
You can set them globally either via environment variables or \fBbundle config\fR, whichever is preferable for your setup\. If you use both, environment variables will take preference over global settings\.
diff --git a/lib/bundler/man/bundle-config.1.ronn b/lib/bundler/man/bundle-config.1.ronn
index e2af773141..905c85fcd9 100644
--- a/lib/bundler/man/bundle-config.1.ronn
+++ b/lib/bundler/man/bundle-config.1.ronn
@@ -43,8 +43,8 @@ local and global sources.
Executing `bundle config unset --global <name>` will delete the configuration
only from the user configuration.
-Executing `bundle config unset --local <name> <value>` will delete the
-configuration only from the local application.
+Executing `bundle config unset --local <name>` will delete the configuration
+only from the local application.
Executing bundle with the `BUNDLE_IGNORE_CONFIG` environment variable set will
cause it to ignore all configuration.
@@ -280,7 +280,7 @@ learn more about their operation in [bundle install(1)](bundle-install.1.html).
A `:`-separated list of groups whose gems bundler should not install.
In general, you should set these settings per-application by using the applicable
-flag to the [bundle install(1)](bundle-install.1.html) or [bundle package(1)](bundle-package.1.html) command.
+flag to the [bundle install(1)](bundle-install.1.html) or [bundle cache(1)](bundle-cache.1.html) command.
You can set them globally either via environment variables or `bundle config`,
whichever is preferable for your setup. If you use both, environment variables
diff --git a/lib/bundler/man/bundle-install.1 b/lib/bundler/man/bundle-install.1
index c742efd142..8e94fe2437 100644
--- a/lib/bundler/man/bundle-install.1
+++ b/lib/bundler/man/bundle-install.1
@@ -70,6 +70,10 @@ The maximum number of parallel download and install jobs\. The default is the nu
Do not attempt to connect to \fBrubygems\.org\fR\. Instead, Bundler will use the gems already present in Rubygems\' cache or in \fBvendor/cache\fR\. Note that if an appropriate platform\-specific gem exists on \fBrubygems\.org\fR it will not be found\.
.
.TP
+\fB\-\-prefer\-local\fR
+Force using locally installed gems, or gems already present in Rubygems\' cache or in \fBvendor/cache\fR, when resolving, even if newer versions are available remotely\. Only attempt to connect to \fBrubygems\.org\fR for gems that are not present locally\.
+.
+.TP
\fB\-\-no\-cache\fR
Do not update the cache in \fBvendor/cache\fR with the newly bundled gems\. This does not remove any gems in the cache but keeps the newly bundled gems from being cached during the install\.
.
diff --git a/lib/bundler/man/bundle-install.1.ronn b/lib/bundler/man/bundle-install.1.ronn
index bec05187f3..47200ac2d5 100644
--- a/lib/bundler/man/bundle-install.1.ronn
+++ b/lib/bundler/man/bundle-install.1.ronn
@@ -109,6 +109,12 @@ automatically and that requires `bundler` to silently remember them. Since
appropriate platform-specific gem exists on `rubygems.org` it will not be
found.
+* `--prefer-local`:
+ Force using locally installed gems, or gems already present in Rubygems' cache
+ or in `vendor/cache`, when resolving, even if newer versions are available
+ remotely. Only attempt to connect to `rubygems.org` for gems that are not
+ present locally.
+
* `--no-cache`:
Do not update the cache in `vendor/cache` with the newly bundled gems. This
does not remove any gems in the cache but keeps the newly bundled gems from
diff --git a/lib/bundler/man/bundle-platform.1 b/lib/bundler/man/bundle-platform.1
index 344ad93083..f5a90c59e9 100644
--- a/lib/bundler/man/bundle-platform.1
+++ b/lib/bundler/man/bundle-platform.1
@@ -10,7 +10,7 @@
\fBbundle platform\fR [\-\-ruby]
.
.SH "DESCRIPTION"
-\fBplatform\fR will display information from your Gemfile, Gemfile\.lock, and Ruby VM about your platform\.
+\fBplatform\fR displays information from your Gemfile, Gemfile\.lock, and Ruby VM about your platform\.
.
.P
For instance, using this Gemfile(5):
@@ -21,7 +21,7 @@ For instance, using this Gemfile(5):
source "https://rubygems\.org"
-ruby "1\.9\.3"
+ruby "3\.1\.2"
gem "rack"
.
@@ -30,7 +30,7 @@ gem "rack"
.IP "" 0
.
.P
-If you run \fBbundle platform\fR on Ruby 1\.9\.3, it will display the following output:
+If you run \fBbundle platform\fR on Ruby 3\.1\.2, it displays the following output:
.
.IP "" 4
.
@@ -39,10 +39,13 @@ If you run \fBbundle platform\fR on Ruby 1\.9\.3, it will display the following
Your platform is: x86_64\-linux
Your app has gems that work on these platforms:
+* arm64\-darwin\-21
* ruby
+* x64\-mingw\-ucrt
+* x86_64\-linux
Your Gemfile specifies a Ruby version requirement:
-* ruby 1\.9\.3
+* ruby 3\.1\.2
Your current platform satisfies the Ruby version requirement\.
.
@@ -51,11 +54,18 @@ Your current platform satisfies the Ruby version requirement\.
.IP "" 0
.
.P
-\fBplatform\fR will list all the platforms in your \fBGemfile\.lock\fR as well as the \fBruby\fR directive if applicable from your Gemfile(5)\. It will also let you know if the \fBruby\fR directive requirement has been met\. If \fBruby\fR directive doesn\'t match the running Ruby VM, it will tell you what part does not\.
+\fBplatform\fR lists all the platforms in your \fBGemfile\.lock\fR as well as the \fBruby\fR directive if applicable from your Gemfile(5)\. It also lets you know if the \fBruby\fR directive requirement has been met\. If \fBruby\fR directive doesn\'t match the running Ruby VM, it tells you what part does not\.
.
.SH "OPTIONS"
.
.TP
\fB\-\-ruby\fR
It will display the ruby directive information, so you don\'t have to parse it from the Gemfile(5)\.
+.
+.SH "SEE ALSO"
+.
+.IP "\(bu" 4
+bundle\-lock(1) \fIbundle\-lock\.1\.ronn\fR
+.
+.IP "" 0
diff --git a/lib/bundler/man/bundle-platform.1.ronn b/lib/bundler/man/bundle-platform.1.ronn
index b5d3283fb6..eb9baa1c62 100644
--- a/lib/bundler/man/bundle-platform.1.ronn
+++ b/lib/bundler/man/bundle-platform.1.ronn
@@ -7,36 +7,43 @@ bundle-platform(1) -- Displays platform compatibility information
## DESCRIPTION
-`platform` will display information from your Gemfile, Gemfile.lock, and Ruby
+`platform` displays information from your Gemfile, Gemfile.lock, and Ruby
VM about your platform.
For instance, using this Gemfile(5):
source "https://rubygems.org"
- ruby "1.9.3"
+ ruby "3.1.2"
gem "rack"
-If you run `bundle platform` on Ruby 1.9.3, it will display the following output:
+If you run `bundle platform` on Ruby 3.1.2, it displays the following output:
Your platform is: x86_64-linux
Your app has gems that work on these platforms:
+ * arm64-darwin-21
* ruby
+ * x64-mingw-ucrt
+ * x86_64-linux
Your Gemfile specifies a Ruby version requirement:
- * ruby 1.9.3
+ * ruby 3.1.2
Your current platform satisfies the Ruby version requirement.
-`platform` will list all the platforms in your `Gemfile.lock` as well as the
-`ruby` directive if applicable from your Gemfile(5). It will also let you know
+`platform` lists all the platforms in your `Gemfile.lock` as well as the
+`ruby` directive if applicable from your Gemfile(5). It also lets you know
if the `ruby` directive requirement has been met. If `ruby` directive doesn't
-match the running Ruby VM, it will tell you what part does not.
+match the running Ruby VM, it tells you what part does not.
## OPTIONS
* `--ruby`:
It will display the ruby directive information, so you don't have to
parse it from the Gemfile(5).
+
+## SEE ALSO
+
+* [bundle-lock(1)](bundle-lock.1.ronn)
diff --git a/lib/bundler/man/bundle.1 b/lib/bundler/man/bundle.1
index c46c37c708..f683e78cc6 100644
--- a/lib/bundler/man/bundle.1
+++ b/lib/bundler/man/bundle.1
@@ -43,8 +43,8 @@ Install the gems specified by the \fBGemfile\fR or \fBGemfile\.lock\fR
Update dependencies to their latest versions
.
.TP
-\fBbundle package(1)\fR \fIbundle\-package\.1\.html\fR
-Package the \.gem files required by your application into the \fBvendor/cache\fR directory
+\fBbundle cache(1)\fR \fIbundle\-cache\.1\.html\fR
+Package the \.gem files required by your application into the \fBvendor/cache\fR directory (aliases: \fBbundle package\fR, \fBbundle pack\fR)
.
.TP
\fBbundle exec(1)\fR \fIbundle\-exec\.1\.html\fR
@@ -81,7 +81,7 @@ Show the source location of a particular gem in the bundle
Show all of the outdated gems in the current bundle
.
.TP
-\fBbundle console(1)\fR
+\fBbundle console(1)\fR (deprecated)
Start an IRB session in the current bundle
.
.TP
@@ -127,9 +127,6 @@ When running a command that isn\'t listed in PRIMARY COMMANDS or UTILITIES, Bund
These commands are obsolete and should no longer be used:
.
.IP "\(bu" 4
-\fBbundle cache(1)\fR
-.
-.IP "\(bu" 4
\fBbundle inject(1)\fR
.
.IP "" 0
diff --git a/lib/bundler/man/bundle.1.ronn b/lib/bundler/man/bundle.1.ronn
index fa247ab365..8f0159eee5 100644
--- a/lib/bundler/man/bundle.1.ronn
+++ b/lib/bundler/man/bundle.1.ronn
@@ -36,9 +36,9 @@ We divide `bundle` subcommands into primary commands and utilities:
* [`bundle update(1)`](bundle-update.1.html):
Update dependencies to their latest versions
-* [`bundle package(1)`](bundle-package.1.html):
+* [`bundle cache(1)`](bundle-cache.1.html):
Package the .gem files required by your application into the
- `vendor/cache` directory
+ `vendor/cache` directory (aliases: `bundle package`, `bundle pack`)
* [`bundle exec(1)`](bundle-exec.1.html):
Execute a script in the current bundle
@@ -67,7 +67,7 @@ We divide `bundle` subcommands into primary commands and utilities:
* [`bundle outdated(1)`](bundle-outdated.1.html):
Show all of the outdated gems in the current bundle
-* `bundle console(1)`:
+* `bundle console(1)` (deprecated):
Start an IRB session in the current bundle
* [`bundle open(1)`](bundle-open.1.html):
@@ -107,5 +107,4 @@ and execute it, passing down any extra arguments to it.
These commands are obsolete and should no longer be used:
-* `bundle cache(1)`
* `bundle inject(1)`
diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb
index 40bc247b32..ca1bdbda7b 100644
--- a/lib/bundler/resolver.rb
+++ b/lib/bundler/resolver.rb
@@ -28,10 +28,11 @@ module Bundler
def initialize(source_requirements, base, gem_version_promoter, additional_base_requirements, platforms, metadata_requirements)
@source_requirements = source_requirements
@metadata_requirements = metadata_requirements
+ @base = base
@resolver = Molinillo::Resolver.new(self, self)
@search_for = {}
@base_dg = Molinillo::DependencyGraph.new
- @base = base.materialized_for_resolution do |ls|
+ base.each do |ls|
dep = Dependency.new(ls.name, ls.version)
@base_dg.add_vertex(ls.name, DepProxy.get_proxy(dep, ls.platform), true)
end
diff --git a/lib/bundler/ruby_dsl.rb b/lib/bundler/ruby_dsl.rb
index f6ba220cd5..3b3a0583a5 100644
--- a/lib/bundler/ruby_dsl.rb
+++ b/lib/bundler/ruby_dsl.rb
@@ -9,7 +9,7 @@ module Bundler
raise GemfileError, "Please define :engine" if options[:engine_version] && options[:engine].nil?
if options[:engine] == "ruby" && options[:engine_version] &&
- ruby_version != Array(options[:engine_version])
+ ruby_version != Array(options[:engine_version])
raise GemfileEvalError, "ruby_version must match the :engine_version for MRI"
end
@ruby_version = RubyVersion.new(ruby_version, options[:patchlevel], options[:engine], options[:engine_version])
diff --git a/lib/bundler/ruby_version.rb b/lib/bundler/ruby_version.rb
index 3f51cf4528..9161c6afde 100644
--- a/lib/bundler/ruby_version.rb
+++ b/lib/bundler/ruby_version.rb
@@ -32,12 +32,12 @@ module Bundler
@engine = engine && engine.to_s || "ruby"
@engine_versions = (engine_version && Array(engine_version)) || @versions
@engine_gem_version = Gem::Requirement.create(@engine_versions.first).requirements.first.last
- @patchlevel = patchlevel
+ @patchlevel = patchlevel || (@gem_version.prerelease? ? "-1" : nil)
end
def to_s(versions = self.versions)
output = String.new("ruby #{versions_string(versions)}")
- output << "p#{patchlevel}" if patchlevel
+ output << "p#{patchlevel}" if patchlevel && patchlevel != "-1"
output << " (#{engine} #{versions_string(engine_versions)})" unless engine == "ruby"
output
@@ -46,7 +46,7 @@ module Bundler
# @private
PATTERN = /
ruby\s
- ([\d.]+) # ruby version
+ (\d+\.\d+\.\d+(?:\.\S+)?) # ruby version
(?:p(-?\d+))? # optional patchlevel
(?:\s\((\S+)\s(.+)\))? # optional engine info
/xo.freeze
@@ -103,8 +103,8 @@ module Bundler
def self.system
ruby_engine = RUBY_ENGINE.dup
- ruby_version = RUBY_VERSION.dup
- ruby_engine_version = RUBY_ENGINE_VERSION.dup
+ ruby_version = Gem.ruby_version.to_s
+ ruby_engine_version = RUBY_ENGINE == "ruby" ? ruby_version : RUBY_ENGINE_VERSION.dup
patchlevel = RUBY_PATCHLEVEL.to_s
@ruby_version ||= RubyVersion.new(ruby_version, patchlevel, ruby_engine, ruby_engine_version)
diff --git a/lib/bundler/rubygems_ext.rb b/lib/bundler/rubygems_ext.rb
index a47692d1f2..938c58e64d 100644
--- a/lib/bundler/rubygems_ext.rb
+++ b/lib/bundler/rubygems_ext.rb
@@ -17,6 +17,15 @@ require "rubygems/source"
require_relative "match_platform"
+# Cherry-pick fixes to `Gem.ruby_version` to be useful for modern Bundler
+# versions and ignore patchlevels
+# (https://github.com/rubygems/rubygems/pull/5472,
+# https://github.com/rubygems/rubygems/pull/5486). May be removed once RubyGems
+# 3.3.12 support is dropped.
+unless Gem.ruby_version.to_s == RUBY_VERSION || RUBY_PATCHLEVEL == -1
+ Gem.instance_variable_set(:@ruby_version, Gem::Version.new(RUBY_VERSION))
+end
+
module Gem
class Specification
include ::Bundler::MatchPlatform
@@ -146,6 +155,10 @@ module Gem
alias_method :eql?, :==
+ def force_ruby_platform
+ false
+ end
+
def encode_with(coder)
to_yaml_properties.each do |ivar|
coder[ivar.to_s.sub(/^@/, "")] = instance_variable_get(ivar)
diff --git a/lib/bundler/source/metadata.rb b/lib/bundler/source/metadata.rb
index 185fe70824..23531b8bd4 100644
--- a/lib/bundler/source/metadata.rb
+++ b/lib/bundler/source/metadata.rb
@@ -5,7 +5,7 @@ module Bundler
class Metadata < Source
def specs
@specs ||= Index.build do |idx|
- idx << Gem::Specification.new("Ruby\0", RubyVersion.system.gem_version)
+ idx << Gem::Specification.new("Ruby\0", Gem.ruby_version)
idx << Gem::Specification.new("RubyGems\0", Gem::VERSION) do |s|
s.required_rubygems_version = Gem::Requirement.default
end
diff --git a/lib/bundler/source_list.rb b/lib/bundler/source_list.rb
index a4773397c7..6ea2910d18 100644
--- a/lib/bundler/source_list.rb
+++ b/lib/bundler/source_list.rb
@@ -101,6 +101,10 @@ module Bundler
source_list_for(source).find {|s| equivalent_source?(source, s) }
end
+ def get_with_fallback(source)
+ get(source) || default_source
+ end
+
def lock_sources
lock_other_sources + lock_rubygems_sources
end
diff --git a/lib/bundler/spec_set.rb b/lib/bundler/spec_set.rb
index a7a95e49bc..14733269d6 100644
--- a/lib/bundler/spec_set.rb
+++ b/lib/bundler/spec_set.rb
@@ -13,14 +13,16 @@ module Bundler
def for(dependencies, check = false, platforms = [nil])
handled = ["bundler"].product(platforms).map {|k| [k, true] }.to_h
- deps = dependencies.product(platforms).map {|dep, platform| [dep.name, platform && dep.force_ruby_platform ? Gem::Platform::RUBY : platform] }
+ deps = dependencies.product(platforms)
specs = []
loop do
break unless dep = deps.shift
- next if handled.key?(dep)
- handled[dep] = true
+ key = [dep[0].name, dep[1]]
+ next if handled.key?(key)
+
+ handled[key] = true
specs_for_dep = specs_for_dependency(*dep)
if specs_for_dep.any?
@@ -28,17 +30,13 @@ module Bundler
specs_for_dep.first.dependencies.each do |d|
next if d.type == :development
- deps << [d.name, dep[1]]
+ deps << [d, dep[1]]
end
elsif check
- specs << IncompleteSpecification.new(*dep)
+ specs << IncompleteSpecification.new(*key)
end
end
- if spec = lookup["bundler"].first
- specs << spec
- end
-
specs
end
@@ -66,13 +64,8 @@ module Bundler
end
def materialize(deps)
- materialized = self.for(deps, true).uniq
+ materialized = self.for(deps, true)
- materialized.map! do |s|
- next s unless s.is_a?(LazySpecification)
- s.source.local!
- s.materialize_for_installation || s
- end
SpecSet.new(materialized)
end
@@ -82,7 +75,6 @@ module Bundler
def materialized_for_all_platforms
@specs.map do |s|
next s unless s.is_a?(LazySpecification)
- s.source.local!
s.source.remote!
spec = s.materialize_for_installation
raise GemNotFound, "Could not find #{s.full_name} in any of the sources" unless spec
@@ -90,13 +82,8 @@ module Bundler
end
end
- def materialized_for_resolution
- materialized = @specs.map do |s|
- spec = s.materialize_for_resolution
- yield spec if spec
- spec
- end.compact
- SpecSet.new(materialized)
+ def incomplete_ruby_specs?(deps)
+ self.class.new(self.for(deps, true, [Gem::Platform::RUBY])).incomplete_specs.any?
end
def missing_specs
@@ -181,13 +168,13 @@ module Bundler
@specs.sort_by(&:name).each {|s| yield s }
end
- def specs_for_dependency(name, platform)
- specs_for_name = lookup[name]
+ def specs_for_dependency(dep, platform)
+ specs_for_name = lookup[dep.name]
if platform.nil?
- GemHelpers.select_best_platform_match(specs_for_name.select {|s| Gem::Platform.match_spec?(s) }, Bundler.local_platform)
+ matching_specs = specs_for_name.map {|s| s.materialize_for_installation if Gem::Platform.match_spec?(s) }.compact
+ GemHelpers.sort_best_platform_match(matching_specs, Bundler.local_platform)
else
- specs_for_name_and_platform = GemHelpers.select_best_platform_match(specs_for_name, platform)
- specs_for_name_and_platform.any? ? specs_for_name_and_platform : specs_for_name
+ GemHelpers.select_best_platform_match(specs_for_name, dep.force_ruby_platform ? Gem::Platform::RUBY : platform)
end
end
diff --git a/lib/bundler/version.rb b/lib/bundler/version.rb
index f01d90b943..f15165f86d 100644
--- a/lib/bundler/version.rb
+++ b/lib/bundler/version.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: false
module Bundler
- VERSION = "2.3.19".freeze
+ VERSION = "2.3.20".freeze
def self.bundler_major_version
@bundler_major_version ||= VERSION.split(".").first.to_i
diff --git a/lib/rubygems.rb b/lib/rubygems.rb
index 8d15c46080..616428475f 100644
--- a/lib/rubygems.rb
+++ b/lib/rubygems.rb
@@ -8,7 +8,7 @@
require "rbconfig"
module Gem
- VERSION = "3.3.19".freeze
+ VERSION = "3.3.20".freeze
end
# Must be first since it unloads the prelude from 1.9.2
@@ -121,7 +121,7 @@ module Gem
# When https://bugs.ruby-lang.org/issues/17259 is available, there is no need to override Kernel#warn
KERNEL_WARN_IGNORES_INTERNAL_ENTRIES = RUBY_ENGINE == "truffleruby" ||
- (RUBY_ENGINE == "ruby" && RUBY_VERSION >= "3.0")
+ (RUBY_ENGINE == "ruby" && RUBY_VERSION >= "3.0")
##
# An Array of Regexps that match windows Ruby platforms.
@@ -741,8 +741,8 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
def self.prefix
prefix = File.dirname RUBYGEMS_DIR
- if prefix != File.expand_path(RbConfig::CONFIG["sitelibdir"]) and
- prefix != File.expand_path(RbConfig::CONFIG["libdir"]) and
+ if prefix != File.expand_path(RbConfig::CONFIG["sitelibdir"]) &&
+ prefix != File.expand_path(RbConfig::CONFIG["libdir"]) &&
"lib" == File.basename(RUBYGEMS_DIR)
prefix
end
@@ -845,8 +845,8 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
# Returns the latest release version of RubyGems.
def self.latest_rubygems_version
- latest_version_for("rubygems-update") or
- raise "Can't find 'rubygems-update' in any repo. Check `gem source list`."
+ latest_version_for("rubygems-update") ||
+ raise("Can't find 'rubygems-update' in any repo. Check `gem source list`.")
end
##
@@ -854,7 +854,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
def self.latest_version_for(name)
spec = latest_spec_for name
- spec and spec.version
+ spec && spec.version
end
##
@@ -944,7 +944,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
".rb",
*%w[DLEXT DLEXT2].map do |key|
val = RbConfig::CONFIG[key]
- next unless val and not val.empty?
+ next unless val && !val.empty?
".#{val}"
end,
].compact.uniq
diff --git a/lib/rubygems/available_set.rb b/lib/rubygems/available_set.rb
index 499483d9e9..58b601f6b0 100644
--- a/lib/rubygems/available_set.rb
+++ b/lib/rubygems/available_set.rb
@@ -26,7 +26,7 @@ class Gem::AvailableSet
s = o.set
when Array
s = o.map do |sp,so|
- if !sp.kind_of?(Gem::Specification) or !so.kind_of?(Gem::Source)
+ if !sp.kind_of?(Gem::Specification) || !so.kind_of?(Gem::Source)
raise TypeError, "Array must be in [[spec, source], ...] form"
end
@@ -149,8 +149,8 @@ class Gem::AvailableSet
@set.reject! do |t|
# already locally installed
Gem::Specification.any? do |installed_spec|
- dep.name == installed_spec.name and
- dep.requirement.satisfied_by? installed_spec.version
+ dep.name == installed_spec.name &&
+ dep.requirement.satisfied_by?(installed_spec.version)
end
end
diff --git a/lib/rubygems/basic_specification.rb b/lib/rubygems/basic_specification.rb
index 526a5069c2..dcc64e6409 100644
--- a/lib/rubygems/basic_specification.rb
+++ b/lib/rubygems/basic_specification.rb
@@ -77,7 +77,7 @@ class Gem::BasicSpecification
if Gem::Platform::RUBY == platform || Gem::Platform.local === platform
warn "Ignoring #{full_name} because its extensions are not built. " +
- "Try: gem pristine #{name} --version #{version}"
+ "Try: gem pristine #{name} --version #{version}"
end
return false
@@ -131,7 +131,7 @@ class Gem::BasicSpecification
# default Ruby platform.
def full_name
- if platform == Gem::Platform::RUBY or platform.nil?
+ if platform == Gem::Platform::RUBY || platform.nil?
"#{name}-#{version}".dup.tap(&Gem::UNTAINT)
else
"#{name}-#{version}-#{platform}".dup.tap(&Gem::UNTAINT)
diff --git a/lib/rubygems/command.rb b/lib/rubygems/command.rb
index 9fc3360fa1..badc21023a 100644
--- a/lib/rubygems/command.rb
+++ b/lib/rubygems/command.rb
@@ -159,11 +159,11 @@ class Gem::Command
gem = "'#{gem_name}' (#{version})"
msg = String.new "Could not find a valid gem #{gem}"
- if errors and !errors.empty?
+ if errors && !errors.empty?
msg << ", here is why:\n"
errors.each {|x| msg << " #{x.wordy}\n" }
else
- if required_by and gem != required_by
+ if required_by && gem != required_by
msg << " (required by #{required_by}) in any repository"
else
msg << " in any repository"
@@ -186,7 +186,7 @@ class Gem::Command
def get_all_gem_names
args = options[:args]
- if args.nil? or args.empty?
+ if args.nil? || args.empty?
raise Gem::CommandLineError,
"Please specify at least one gem name (e.g. gem build GEMNAME)"
end
@@ -216,7 +216,7 @@ class Gem::Command
def get_one_gem_name
args = options[:args]
- if args.nil? or args.empty?
+ if args.nil? || args.empty?
raise Gem::CommandLineError,
"Please specify a gem name on the command line (e.g. gem build GEMNAME)"
end
@@ -554,7 +554,7 @@ class Gem::Command
end
def configure_options(header, option_list)
- return if option_list.nil? or option_list.empty?
+ return if option_list.nil? || option_list.empty?
header = header.to_s.empty? ? "" : "#{header} "
@parser.separator " #{header}Options:"
@@ -586,7 +586,7 @@ class Gem::Command
add_common_option("-V", "--[no-]verbose",
"Set the verbose level of output") do |value, options|
# Set us to "really verbose" so the progress meter works
- if Gem.configuration.verbose and value
+ if Gem.configuration.verbose && value
Gem.configuration.verbose = 1
else
Gem.configuration.verbose = value
diff --git a/lib/rubygems/commands/cert_command.rb b/lib/rubygems/commands/cert_command.rb
index 56bf5ce689..17b1d11b19 100644
--- a/lib/rubygems/commands/cert_command.rb
+++ b/lib/rubygems/commands/cert_command.rb
@@ -152,7 +152,7 @@ class Gem::Commands::CertCommand < Gem::Command
def build_cert(email, key) # :nodoc:
expiration_length_days = options[:expiration_length_days] ||
- Gem.configuration.cert_expiration_length_days
+ Gem.configuration.cert_expiration_length_days
cert = Gem::Security.create_cert_email(
email,
diff --git a/lib/rubygems/commands/cleanup_command.rb b/lib/rubygems/commands/cleanup_command.rb
index 7f143999eb..1ae84924c1 100644
--- a/lib/rubygems/commands/cleanup_command.rb
+++ b/lib/rubygems/commands/cleanup_command.rb
@@ -149,7 +149,7 @@ If no gems are named all gems in GEM_HOME are cleaned.
@primary_gems = {}
Gem::Specification.each do |spec|
- if @primary_gems[spec.name].nil? or
+ if @primary_gems[spec.name].nil? ||
@primary_gems[spec.name].version < spec.version
@primary_gems[spec.name] = spec
end
diff --git a/lib/rubygems/commands/contents_command.rb b/lib/rubygems/commands/contents_command.rb
index 3dd0b16265..c5fdfca31e 100644
--- a/lib/rubygems/commands/contents_command.rb
+++ b/lib/rubygems/commands/contents_command.rb
@@ -77,7 +77,7 @@ prefix or only the files that are requireable.
gem_contents name
end
- terminate_interaction 1 unless found or names.length > 1
+ terminate_interaction 1 unless found || names.length > 1
end
end
diff --git a/lib/rubygems/commands/dependency_command.rb b/lib/rubygems/commands/dependency_command.rb
index c9ddc9af0a..3f69a95e83 100644
--- a/lib/rubygems/commands/dependency_command.rb
+++ b/lib/rubygems/commands/dependency_command.rb
@@ -77,7 +77,7 @@ use with other commands.
name_matches = name_pattern ? name_pattern =~ spec.name : true
version_matches = requirement.satisfied_by?(spec.version)
- name_matches and version_matches
+ name_matches && version_matches
}.map(&:to_spec)
end
@@ -133,7 +133,7 @@ use with other commands.
end
def ensure_local_only_reverse_dependencies # :nodoc:
- if options[:reverse_dependencies] and remote? and not local?
+ if options[:reverse_dependencies] && remote? && !local?
alert_error "Only reverse dependencies for local gems are supported."
terminate_interaction 1
end
@@ -182,7 +182,7 @@ use with other commands.
sp.dependencies.each do |dep|
dep = Gem::Dependency.new(*dep) unless Gem::Dependency === dep
- if spec.name == dep.name and
+ if spec.name == dep.name &&
dep.requirement.satisfied_by?(spec.version)
result << [sp.full_name, dep]
end
@@ -197,7 +197,7 @@ use with other commands.
def name_pattern(args)
return if args.empty?
- if args.length == 1 and args.first =~ /\A(.*)(i)?\z/m
+ if args.length == 1 && args.first =~ /\A(.*)(i)?\z/m
flags = $2 ? Regexp::IGNORECASE : nil
Regexp.new $1, flags
else
diff --git a/lib/rubygems/commands/fetch_command.rb b/lib/rubygems/commands/fetch_command.rb
index 582563ba81..3a8c435d0e 100644
--- a/lib/rubygems/commands/fetch_command.rb
+++ b/lib/rubygems/commands/fetch_command.rb
@@ -52,8 +52,8 @@ then repackaging it.
end
def check_version # :nodoc:
- if options[:version] != Gem::Requirement.default and
- get_all_gem_names.size > 1
+ if options[:version] != Gem::Requirement.default &&
+ get_all_gem_names.size > 1
alert_error "Can't use --version with multiple gems. You can specify multiple gems with" \
" version requirements using `gem fetch 'my_gem:1.0.0' 'my_other_gem:~>2.0.0'`"
terminate_interaction 1
diff --git a/lib/rubygems/commands/generate_index_command.rb b/lib/rubygems/commands/generate_index_command.rb
index 8bb24c9ce3..bc71e60ff0 100644
--- a/lib/rubygems/commands/generate_index_command.rb
+++ b/lib/rubygems/commands/generate_index_command.rb
@@ -68,8 +68,8 @@ Marshal::MINOR_VERSION constants. It is used to ensure compatibility.
# This is always true because it's the only way now.
options[:build_modern] = true
- if not File.exist?(options[:directory]) or
- not File.directory?(options[:directory])
+ if !File.exist?(options[:directory]) ||
+ !File.directory?(options[:directory])
alert_error "unknown directory name #{options[:directory]}."
terminate_interaction 1
else
diff --git a/lib/rubygems/commands/install_command.rb b/lib/rubygems/commands/install_command.rb
index 690f90c2e4..724b4fe51d 100644
--- a/lib/rubygems/commands/install_command.rb
+++ b/lib/rubygems/commands/install_command.rb
@@ -46,8 +46,8 @@ class Gem::Commands::InstallCommand < Gem::Command
def defaults_str # :nodoc:
"--both --version '#{Gem::Requirement.default}' --no-force\n" +
- "--install-dir #{Gem.dir} --lock\n" +
- install_update_defaults_str
+ "--install-dir #{Gem.dir} --lock\n" +
+ install_update_defaults_str
end
def description # :nodoc:
@@ -134,15 +134,15 @@ You can use `i` command instead of `install`.
end
def check_install_dir # :nodoc:
- if options[:install_dir] and options[:user_install]
+ if options[:install_dir] && options[:user_install]
alert_error "Use --install-dir or --user-install but not both"
terminate_interaction 1
end
end
def check_version # :nodoc:
- if options[:version] != Gem::Requirement.default and
- get_all_gem_names.size > 1
+ if options[:version] != Gem::Requirement.default &&
+ get_all_gem_names.size > 1
alert_error "Can't use --version with multiple gems. You can specify multiple gems with" \
" version requirements using `gem install 'my_gem:1.0.0' 'my_other_gem:~>2.0.0'`"
terminate_interaction 1
@@ -191,8 +191,8 @@ You can use `i` command instead of `install`.
end
def install_gem(name, version) # :nodoc:
- return if options[:conservative] and
- not Gem::Dependency.new(name, version).matching_specs.empty?
+ return if options[:conservative] &&
+ !Gem::Dependency.new(name, version).matching_specs.empty?
req = Gem::Requirement.create(version)
diff --git a/lib/rubygems/commands/pristine_command.rb b/lib/rubygems/commands/pristine_command.rb
index d4dadf0736..72db53ef37 100644
--- a/lib/rubygems/commands/pristine_command.rb
+++ b/lib/rubygems/commands/pristine_command.rb
@@ -102,10 +102,10 @@ extensions will be restored.
# `--extensions` must be explicitly given to pristine only gems
# with extensions.
- elsif options[:extensions_set] and
- options[:extensions] and options[:args].empty?
+ elsif options[:extensions_set] &&
+ options[:extensions] && options[:args].empty?
Gem::Specification.select do |spec|
- spec.extensions and not spec.extensions.empty?
+ spec.extensions && !spec.extensions.empty?
end
else
get_all_gem_names.sort.map do |gem_name|
@@ -135,14 +135,14 @@ extensions will be restored.
end
end
- unless spec.extensions.empty? or options[:extensions] or options[:only_executables] or options[:only_plugins]
+ unless spec.extensions.empty? || options[:extensions] || options[:only_executables] || options[:only_plugins]
say "Skipped #{spec.full_name}, it needs to compile an extension"
next
end
gem = spec.cache_file
- unless File.exist? gem or options[:only_executables] or options[:only_plugins]
+ unless File.exist?(gem) || options[:only_executables] || options[:only_plugins]
require_relative "../remote_fetcher"
say "Cached gem for #{spec.full_name} not found, attempting to fetch..."
diff --git a/lib/rubygems/commands/setup_command.rb b/lib/rubygems/commands/setup_command.rb
index 1ed889a713..c782c3618c 100644
--- a/lib/rubygems/commands/setup_command.rb
+++ b/lib/rubygems/commands/setup_command.rb
@@ -329,9 +329,9 @@ By default, this RubyGems will install gem as:
# ignore
end
- if File.writable? gem_doc_dir and
- (not File.exist? rubygems_doc_dir or
- File.writable? rubygems_doc_dir)
+ if File.writable?(gem_doc_dir) &&
+ (!File.exist?(rubygems_doc_dir) ||
+ File.writable?(rubygems_doc_dir))
say "Removing old RubyGems RDoc and ri" if @verbose
Dir[File.join(Gem.dir, "doc", "rubygems-[0-9]*")].each do |dir|
rm_rf dir
@@ -559,7 +559,7 @@ abort "#{deprecation_message}"
history_string = ""
- until versions.length == 0 or
+ until versions.length == 0 ||
versions.shift <= options[:previous_version] do
history_string += version_lines.shift + text.shift
end
diff --git a/lib/rubygems/commands/sources_command.rb b/lib/rubygems/commands/sources_command.rb
index a5f2d022c6..5a8f5af9c3 100644
--- a/lib/rubygems/commands/sources_command.rb
+++ b/lib/rubygems/commands/sources_command.rb
@@ -82,7 +82,7 @@ Do you want to add this source?
def check_rubygems_https(source_uri) # :nodoc:
uri = URI source_uri
- if uri.scheme and uri.scheme.downcase == "http" and
+ if uri.scheme && uri.scheme.downcase == "http" &&
uri.host.downcase == "rubygems.org"
question = <<-QUESTION.chomp
https://rubygems.org is recommended for security over #{uri}
@@ -215,9 +215,9 @@ To remove a source use the --remove argument:
def remove_cache_file(desc, path) # :nodoc:
FileUtils.rm_rf path
- if not File.exist?(path)
+ if !File.exist?(path)
say "*** Removed #{desc} source cache ***"
- elsif not File.writable?(path)
+ elsif !File.writable?(path)
say "*** Unable to remove #{desc} source cache (write protected) ***"
else
say "*** Unable to remove #{desc} source cache ***"
diff --git a/lib/rubygems/commands/specification_command.rb b/lib/rubygems/commands/specification_command.rb
index 6457a755ae..12004a6d56 100644
--- a/lib/rubygems/commands/specification_command.rb
+++ b/lib/rubygems/commands/specification_command.rb
@@ -88,7 +88,7 @@ Specific fields in the specification can be extracted in YAML format:
raise Gem::CommandLineError, "Unsupported version type: '#{v}'"
end
- if !req.none? and options[:all]
+ if !req.none? && options[:all]
alert_error "Specify --all or -v, not both"
terminate_interaction 1
end
@@ -102,7 +102,7 @@ Specific fields in the specification can be extracted in YAML format:
field = get_one_optional_argument
raise Gem::CommandLineError, "--ruby and FIELD are mutually exclusive" if
- field and options[:format] == :ruby
+ field && options[:format] == :ruby
if local?
if File.exist? gem
diff --git a/lib/rubygems/commands/uninstall_command.rb b/lib/rubygems/commands/uninstall_command.rb
index d03a96bf87..3c520826e5 100644
--- a/lib/rubygems/commands/uninstall_command.rb
+++ b/lib/rubygems/commands/uninstall_command.rb
@@ -96,7 +96,7 @@ class Gem::Commands::UninstallCommand < Gem::Command
def defaults_str # :nodoc:
"--version '#{Gem::Requirement.default}' --no-force " +
- "--user-install"
+ "--user-install"
end
def description # :nodoc:
@@ -114,8 +114,8 @@ that is a dependency of an existing gem. You can use the
end
def check_version # :nodoc:
- if options[:version] != Gem::Requirement.default and
- get_all_gem_names.size > 1
+ if options[:version] != Gem::Requirement.default &&
+ get_all_gem_names.size > 1
alert_error "Can't use --version with multiple gems. You can specify multiple gems with" \
" version requirements using `gem uninstall 'my_gem:1.0.0' 'my_other_gem:~>2.0.0'`"
terminate_interaction 1
@@ -125,7 +125,7 @@ that is a dependency of an existing gem. You can use the
def execute
check_version
- if options[:all] and not options[:args].empty?
+ if options[:all] && !options[:args].empty?
uninstall_specific
elsif options[:all]
uninstall_all
diff --git a/lib/rubygems/commands/update_command.rb b/lib/rubygems/commands/update_command.rb
index a079642669..7c24fedcde 100644
--- a/lib/rubygems/commands/update_command.rb
+++ b/lib/rubygems/commands/update_command.rb
@@ -56,7 +56,7 @@ class Gem::Commands::UpdateCommand < Gem::Command
def defaults_str # :nodoc:
"--no-force --install-dir #{Gem.dir}\n" +
- install_update_defaults_str
+ install_update_defaults_str
end
def description # :nodoc:
@@ -155,7 +155,7 @@ command to remove old versions.
Gem::Specification.dirs = Gem.user_dir if options[:user_install]
Gem::Specification.each do |spec|
- if hig[spec.name].nil? or hig[spec.name].version < spec.version
+ if hig[spec.name].nil? || hig[spec.name].version < spec.version
hig[spec.name] = spec
end
end
@@ -292,8 +292,8 @@ command to remove old versions.
args << "--no-document" unless options[:document].include?("rdoc") || options[:document].include?("ri")
args << "--no-format-executable" if options[:no_format_executable]
args << "--previous-version" << Gem::VERSION if
- options[:system] == true or
- Gem::Version.new(options[:system]) >= Gem::Version.new(2)
+ options[:system] == true ||
+ Gem::Version.new(options[:system]) >= Gem::Version.new(2)
args
end
@@ -301,7 +301,7 @@ command to remove old versions.
result = []
highest_installed_gems.each do |l_name, l_spec|
- next if not gem_names.empty? and
+ next if !gem_names.empty? &&
gem_names.none? {|name| name == l_spec.name }
highest_remote_tup = highest_remote_name_tuple l_spec
diff --git a/lib/rubygems/commands/which_command.rb b/lib/rubygems/commands/which_command.rb
index 78493e9380..5b9a79b734 100644
--- a/lib/rubygems/commands/which_command.rb
+++ b/lib/rubygems/commands/which_command.rb
@@ -71,7 +71,7 @@ requiring to see why it does not behave as you expect.
dirs.each do |dir|
Gem.suffixes.each do |ext|
full_path = File.join dir, "#{package_name}#{ext}"
- if File.exist? full_path and not File.directory? full_path
+ if File.exist?(full_path) && !File.directory?(full_path)
result << full_path
return result unless options[:show_all]
end
diff --git a/lib/rubygems/config_file.rb b/lib/rubygems/config_file.rb
index d711a51bd0..c53e209ae8 100644
--- a/lib/rubygems/config_file.rb
+++ b/lib/rubygems/config_file.rb
@@ -39,7 +39,7 @@ require "rbconfig"
class Gem::ConfigFile
include Gem::UserInteraction
- DEFAULT_BACKTRACE = false
+ DEFAULT_BACKTRACE = true
DEFAULT_BULK_THRESHOLD = 1000
DEFAULT_VERBOSITY = true
DEFAULT_UPDATE_SOURCES = true
@@ -368,7 +368,7 @@ if you believe they were disclosed to a third party.
# True if the backtrace option has been specified, or debug is on.
def backtrace
- @backtrace or $DEBUG
+ @backtrace || $DEBUG
end
# The name of the configuration file.
@@ -477,11 +477,11 @@ if you believe they were disclosed to a third party.
end
def ==(other) # :nodoc:
- self.class === other and
- @backtrace == other.backtrace and
- @bulk_threshold == other.bulk_threshold and
- @verbose == other.verbose and
- @update_sources == other.update_sources and
+ self.class === other &&
+ @backtrace == other.backtrace &&
+ @bulk_threshold == other.bulk_threshold &&
+ @verbose == other.verbose &&
+ @update_sources == other.update_sources &&
@hash == other.hash
end
diff --git a/lib/rubygems/core_ext/kernel_warn.rb b/lib/rubygems/core_ext/kernel_warn.rb
index 7df6c48b8f..8f43e00456 100644
--- a/lib/rubygems/core_ext/kernel_warn.rb
+++ b/lib/rubygems/core_ext/kernel_warn.rb
@@ -39,7 +39,7 @@ if RUBY_VERSION >= "2.5" && !Gem::KERNEL_WARN_IGNORES_INTERNAL_ENTRIES
start += 1
if path = loc.path
- unless path.start_with?(rubygems_path) or path.start_with?("<internal:")
+ unless path.start_with?(rubygems_path) || path.start_with?("<internal:")
# Non-rubygems frames
uplevel -= 1
end
diff --git a/lib/rubygems/defaults.rb b/lib/rubygems/defaults.rb
index d27f286265..d5caea7665 100644
--- a/lib/rubygems/defaults.rb
+++ b/lib/rubygems/defaults.rb
@@ -161,7 +161,7 @@ module Gem
path = []
path << user_dir if user_home && File.exist?(user_home)
path << default_dir
- path << vendor_dir if vendor_dir and File.directory? vendor_dir
+ path << vendor_dir if vendor_dir && File.directory?(vendor_dir)
path
end
diff --git a/lib/rubygems/dependency.rb b/lib/rubygems/dependency.rb
index c561db1af2..85f8609677 100644
--- a/lib/rubygems/dependency.rb
+++ b/lib/rubygems/dependency.rb
@@ -115,7 +115,7 @@ class Gem::Dependency
# What does this dependency require?
def requirement
- return @requirement if defined?(@requirement) and @requirement
+ return @requirement if defined?(@requirement) && @requirement
# @version_requirements and @version_requirement are legacy ivar
# names, and supported here because older gems need to keep
@@ -230,10 +230,10 @@ class Gem::Dependency
version = Gem::Version.new version
- return true if requirement.none? and not version.prerelease?
- return false if version.prerelease? and
- not allow_prerelease and
- not prerelease?
+ return true if requirement.none? && !version.prerelease?
+ return false if version.prerelease? &&
+ !allow_prerelease &&
+ !prerelease?
requirement.satisfied_by? version
end
diff --git a/lib/rubygems/dependency_installer.rb b/lib/rubygems/dependency_installer.rb
index acdad6b98f..aa7b66d36b 100644
--- a/lib/rubygems/dependency_installer.rb
+++ b/lib/rubygems/dependency_installer.rb
@@ -109,7 +109,7 @@ class Gem::DependencyInstaller
# gems should be considered.
def consider_local?
- @domain == :both or @domain == :local
+ @domain == :both || @domain == :local
end
##
@@ -117,7 +117,7 @@ class Gem::DependencyInstaller
# gems should be considered.
def consider_remote?
- @domain == :both or @domain == :remote
+ @domain == :both || @domain == :remote
end
##
@@ -197,7 +197,7 @@ class Gem::DependencyInstaller
def in_background(what) # :nodoc:
fork_happened = false
- if @build_docs_in_background and Process.respond_to?(:fork)
+ if @build_docs_in_background && Process.respond_to?(:fork)
begin
Process.fork do
yield
@@ -268,7 +268,7 @@ class Gem::DependencyInstaller
end
def install_development_deps # :nodoc:
- if @development and @dev_shallow
+ if @development && @dev_shallow
:shallow
elsif @development
:all
@@ -289,7 +289,7 @@ class Gem::DependencyInstaller
installer_set.force = @force
if consider_local?
- if dep_or_name =~ /\.gem$/ and File.file? dep_or_name
+ if dep_or_name =~ /\.gem$/ && File.file?(dep_or_name)
src = Gem::Source::SpecificFile.new dep_or_name
installer_set.add_local dep_or_name, src.spec, src
version = src.spec.version if version == Gem::Requirement.default
diff --git a/lib/rubygems/dependency_list.rb b/lib/rubygems/dependency_list.rb
index 3cecb1e536..eaf6702177 100644
--- a/lib/rubygems/dependency_list.rb
+++ b/lib/rubygems/dependency_list.rb
@@ -119,11 +119,11 @@ class Gem::DependencyList
each do |spec|
spec.runtime_dependencies.each do |dep|
inst = Gem::Specification.any? do |installed_spec|
- dep.name == installed_spec.name and
- dep.requirement.satisfied_by? installed_spec.version
+ dep.name == installed_spec.name &&
+ dep.requirement.satisfied_by?(installed_spec.version)
end
- unless inst or @specs.find {|s| s.satisfies_requirement? dep }
+ unless inst || @specs.find {|s| s.satisfies_requirement? dep }
unsatisfied[spec.name] << dep
return unsatisfied if quick
end
@@ -175,7 +175,7 @@ class Gem::DependencyList
def remove_specs_unsatisfied_by(dependencies)
specs.reject! do |spec|
dep = dependencies[spec.name]
- dep and not dep.requirement.satisfied_by? spec.version
+ dep && !dep.requirement.satisfied_by?(spec.version)
end
end
diff --git a/lib/rubygems/doctor.rb b/lib/rubygems/doctor.rb
index 662eff9559..96829227fc 100644
--- a/lib/rubygems/doctor.rb
+++ b/lib/rubygems/doctor.rb
@@ -30,7 +30,7 @@ class Gem::Doctor
missing =
Gem::REPOSITORY_SUBDIRECTORIES.sort -
- REPOSITORY_EXTENSION_MAP.map {|(k,_)| k }.sort
+ REPOSITORY_EXTENSION_MAP.map {|(k,_)| k }.sort
raise "Update REPOSITORY_EXTENSION_MAP, missing: #{missing.join ', '}" unless
missing.empty?
@@ -59,7 +59,7 @@ class Gem::Doctor
# Are we doctoring a gem repository?
def gem_repository?
- not installed_specs.empty?
+ !installed_specs.empty?
end
##
@@ -111,8 +111,8 @@ class Gem::Doctor
basename = File.basename(child, extension)
next if installed_specs.include? basename
next if /^rubygems-\d/ =~ basename
- next if "specifications" == sub_directory and "default" == basename
- next if "plugins" == sub_directory and Gem.plugin_suffix_regexp =~ basename
+ next if "specifications" == sub_directory && "default" == basename
+ next if "plugins" == sub_directory && Gem.plugin_suffix_regexp =~ (basename)
type = File.directory?(child) ? "directory" : "file"
diff --git a/lib/rubygems/exceptions.rb b/lib/rubygems/exceptions.rb
index 5fadbe9bca..974c0173b9 100644
--- a/lib/rubygems/exceptions.rb
+++ b/lib/rubygems/exceptions.rb
@@ -254,7 +254,7 @@ class Gem::UnsatisfiableDependencyError < Gem::DependencyError
# Gem::Resolver::DependencyRequest +dep+
def initialize(dep, platform_mismatch=nil)
- if platform_mismatch and !platform_mismatch.empty?
+ if platform_mismatch && !platform_mismatch.empty?
plats = platform_mismatch.map {|x| x.platform.to_s }.sort.uniq
super "Unable to resolve dependency: No match for '#{dep}' on this platform. Found: #{plats.join(', ')}"
else
diff --git a/lib/rubygems/ext/ext_conf_builder.rb b/lib/rubygems/ext/ext_conf_builder.rb
index f8920596d5..ebe398f56c 100644
--- a/lib/rubygems/ext/ext_conf_builder.rb
+++ b/lib/rubygems/ext/ext_conf_builder.rb
@@ -44,7 +44,7 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder
full_tmp_dest = File.join(extension_dir, tmp_dest_relative)
# TODO remove in RubyGems 4
- if Gem.install_extension_in_lib and lib_dir
+ if Gem.install_extension_in_lib && lib_dir
FileUtils.mkdir_p lib_dir
entries = Dir.entries(full_tmp_dest) - %w[. ..]
entries = entries.map {|entry| File.join full_tmp_dest, entry }
@@ -53,7 +53,7 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder
FileUtils::Entry_.new(full_tmp_dest).traverse do |ent|
destent = ent.class.new(dest_path, ent.rel)
- destent.exist? or FileUtils.mv(ent.path, destent.path)
+ destent.exist? || FileUtils.mv(ent.path, destent.path)
end
ensure
ENV["DESTDIR"] = destdir
diff --git a/lib/rubygems/gemcutter_utilities.rb b/lib/rubygems/gemcutter_utilities.rb
index c46650afb1..a785159196 100644
--- a/lib/rubygems/gemcutter_utilities.rb
+++ b/lib/rubygems/gemcutter_utilities.rb
@@ -71,7 +71,7 @@ module Gem::GemcutterUtilities
begin
env_rubygems_host = ENV["RUBYGEMS_HOST"]
env_rubygems_host = nil if
- env_rubygems_host and env_rubygems_host.empty?
+ env_rubygems_host && env_rubygems_host.empty?
env_rubygems_host || configured_host
end
diff --git a/lib/rubygems/indexer.rb b/lib/rubygems/indexer.rb
index 2299932f45..39653462e9 100644
--- a/lib/rubygems/indexer.rb
+++ b/lib/rubygems/indexer.rb
@@ -149,7 +149,7 @@ class Gem::Indexer
next
end
- platform = Gem::Platform::RUBY if platform.nil? or platform.empty?
+ platform = Gem::Platform::RUBY if platform.nil? || platform.empty?
[spec.name, spec.version, platform]
end
@@ -296,7 +296,7 @@ class Gem::Indexer
files = @files
files.delete @quick_marshal_dir if files.include? @quick_dir
- if files.include? @quick_marshal_dir and not files.include? @quick_dir
+ if files.include?(@quick_marshal_dir) && !files.include?(@quick_dir)
files.delete @quick_marshal_dir
dst_name = File.join(@dest_directory, @quick_marshal_dir_base)
@@ -414,7 +414,7 @@ class Gem::Indexer
index.each do |spec|
platform = spec.original_platform
- platform = Gem::Platform::RUBY if platform.nil? or platform.empty?
+ platform = Gem::Platform::RUBY if platform.nil? || platform.empty?
specs_index << [spec.name, spec.version, platform]
end
diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb
index 52307f6d93..2e29c38751 100644
--- a/lib/rubygems/installer.rb
+++ b/lib/rubygems/installer.rb
@@ -251,7 +251,7 @@ class Gem::Installer
return if spec.name == existing
# somebody has written to RubyGems' directory, overwrite, too bad
- return if Gem.default_bindir != @bin_dir and not ruby_executable
+ return if Gem.default_bindir != @bin_dir && !ruby_executable
question = "#{spec.name}'s executable \"#{filename}\" conflicts with ".dup
@@ -418,10 +418,10 @@ class Gem::Installer
# True if the gems in the system satisfy +dependency+.
def installation_satisfies_dependency?(dependency)
- return true if @options[:development] and dependency.type == :development
+ return true if @options[:development] && dependency.type == :development
return true if installed_specs.detect {|s| dependency.matches_spec? s }
return false if @only_install_dir
- not dependency.matching_specs.empty?
+ !dependency.matching_specs.empty?
end
##
@@ -483,22 +483,14 @@ class Gem::Installer
end
def generate_bin # :nodoc:
- return if spec.executables.nil? or spec.executables.empty?
+ return if spec.executables.nil? || spec.executables.empty?
ensure_writable_dir @bin_dir
spec.executables.each do |filename|
filename.tap(&Gem::UNTAINT)
bin_path = File.join gem_dir, spec.bindir, filename
-
- unless File.exist? bin_path
- if File.symlink? bin_path
- alert_warning "`#{bin_path}` is dangling symlink pointing to `#{File.readlink bin_path}`"
- else
- alert_warning "`#{bin_path}` does not exist, maybe `gem pristine #{spec.name}` will fix it?"
- end
- next
- end
+ next unless File.exist? bin_path
mode = File.stat(bin_path).mode
dir_mode = options[:prog_mode] || (mode | 0111)
diff --git a/lib/rubygems/name_tuple.rb b/lib/rubygems/name_tuple.rb
index b9f330ee4d..767dc1fb45 100644
--- a/lib/rubygems/name_tuple.rb
+++ b/lib/rubygems/name_tuple.rb
@@ -10,7 +10,7 @@ class Gem::NameTuple
@version = version
unless platform.kind_of? Gem::Platform
- platform = "ruby" if !platform or platform.empty?
+ platform = "ruby" if !platform || platform.empty?
end
@platform = platform
@@ -102,8 +102,8 @@ class Gem::NameTuple
def ==(other)
case other
when self.class
- @name == other.name and
- @version == other.version and
+ @name == other.name &&
+ @version == other.version &&
@platform == other.platform
when Array
to_a == other
diff --git a/lib/rubygems/package.rb b/lib/rubygems/package.rb
index 1e87837b0e..084dc5d2d9 100644
--- a/lib/rubygems/package.rb
+++ b/lib/rubygems/package.rb
@@ -68,14 +68,14 @@ class Gem::Package
class PathError < Error
def initialize(destination, destination_dir)
super "installing into parent path %s of %s is not allowed" %
- [destination, destination_dir]
+ [destination, destination_dir]
end
end
class SymlinkError < Error
def initialize(name, destination, destination_dir)
super "installing symlink '%s' pointing to parent path %s of %s is not allowed" %
- [name, destination, destination_dir]
+ [name, destination, destination_dir]
end
end
@@ -409,18 +409,23 @@ EOM
def extract_tar_gz(io, destination_dir, pattern = "*") # :nodoc:
directories = []
+ symlinks = []
+
open_tar_gz io do |tar|
tar.each do |entry|
- next unless File.fnmatch pattern, entry.full_name, File::FNM_DOTMATCH
+ full_name = entry.full_name
+ next unless File.fnmatch pattern, full_name, File::FNM_DOTMATCH
- destination = install_location entry.full_name, destination_dir
+ destination = install_location full_name, destination_dir
if entry.symlink?
link_target = entry.header.linkname
real_destination = link_target.start_with?("/") ? link_target : File.expand_path(link_target, File.dirname(destination))
- raise Gem::Package::SymlinkError.new(entry.full_name, real_destination, destination_dir) unless
+ raise Gem::Package::SymlinkError.new(full_name, real_destination, destination_dir) unless
normalize_path(real_destination).start_with? normalize_path(destination_dir + "/")
+
+ symlinks << [full_name, link_target, destination, real_destination]
end
FileUtils.rm_rf destination
@@ -444,12 +449,18 @@ EOM
FileUtils.chmod file_mode(entry.header.mode), destination
end if entry.file?
- File.symlink(entry.header.linkname, destination) if entry.symlink?
-
verbose destination
end
end
+ symlinks.each do |name, target, destination, real_destination|
+ if File.exist?(real_destination)
+ File.symlink(target, destination)
+ else
+ alert_warning "#{@spec.full_name} ships with a dangling symlink named #{name} pointing to missing #{target} file. Ignoring"
+ end
+ end
+
if dir_mode
File.chmod(dir_mode, *directories)
end
@@ -676,7 +687,7 @@ EOM
"package content (data.tar.gz) is missing", @gem
end
- if duplicates = @files.group_by {|f| f }.select {|k,v| v.size > 1 }.map(&:first) and duplicates.any?
+ if (duplicates = @files.group_by {|f| f }.select {|k,v| v.size > 1 }.map(&:first)) && duplicates.any?
raise Gem::Security::Exception, "duplicate files in the package: (#{duplicates.map(&:inspect).join(', ')})"
end
end
diff --git a/lib/rubygems/package/tar_header.rb b/lib/rubygems/package/tar_header.rb
index fb70765dde..ee515a9e05 100644
--- a/lib/rubygems/package/tar_header.rb
+++ b/lib/rubygems/package/tar_header.rb
@@ -173,23 +173,23 @@ class Gem::Package::TarHeader
end
def ==(other) # :nodoc:
- self.class === other and
- @checksum == other.checksum and
- @devmajor == other.devmajor and
- @devminor == other.devminor and
- @gid == other.gid and
- @gname == other.gname and
- @linkname == other.linkname and
- @magic == other.magic and
- @mode == other.mode and
- @mtime == other.mtime and
- @name == other.name and
- @prefix == other.prefix and
- @size == other.size and
- @typeflag == other.typeflag and
- @uid == other.uid and
- @uname == other.uname and
- @version == other.version
+ self.class === other &&
+ @checksum == other.checksum &&
+ @devmajor == other.devmajor &&
+ @devminor == other.devminor &&
+ @gid == other.gid &&
+ @gname == other.gname &&
+ @linkname == other.linkname &&
+ @magic == other.magic &&
+ @mode == other.mode &&
+ @mtime == other.mtime &&
+ @name == other.name &&
+ @prefix == other.prefix &&
+ @size == other.size &&
+ @typeflag == other.typeflag &&
+ @uid == other.uid &&
+ @uname == other.uname &&
+ @version == other.version
end
def to_s # :nodoc:
diff --git a/lib/rubygems/package/tar_writer.rb b/lib/rubygems/package/tar_writer.rb
index 6f068f50c2..db5242c5e4 100644
--- a/lib/rubygems/package/tar_writer.rb
+++ b/lib/rubygems/package/tar_writer.rb
@@ -314,7 +314,7 @@ class Gem::Package::TarWriter
prefix = parts.join("/")
end
- if name.bytesize > 100 or prefix.empty?
+ if name.bytesize > 100 || prefix.empty?
raise Gem::Package::TooLongFileName.new("File \"#{prefix}/#{name}\" has a too long name (should be 100 or less)")
end
diff --git a/lib/rubygems/platform.rb b/lib/rubygems/platform.rb
index 607e3906d6..ed3571dbff 100644
--- a/lib/rubygems/platform.rb
+++ b/lib/rubygems/platform.rb
@@ -23,9 +23,9 @@ class Gem::Platform
def self.match_platforms?(platform, platforms)
platforms.any? do |local_platform|
- platform.nil? or
- local_platform == platform or
- (local_platform != Gem::Platform::RUBY and local_platform =~ platform)
+ platform.nil? ||
+ local_platform == platform ||
+ (local_platform != Gem::Platform::RUBY && local_platform =~ platform)
end
end
private_class_method :match_platforms?
@@ -70,7 +70,7 @@ class Gem::Platform
when String then
arch = arch.split "-"
- if arch.length > 2 and arch.last !~ /\d/ # reassemble x86-linux-gnu
+ if arch.length > 2 && arch.last !~ (/\d/) # reassemble x86-linux-gnu
extra = arch.pop
arch.last << "-#{extra}"
end
@@ -82,7 +82,7 @@ class Gem::Platform
else cpu
end
- if arch.length == 2 and arch.last =~ /^\d+(\.\d+)?$/ # for command-line
+ if arch.length == 2 && arch.last =~ /^\d+(\.\d+)?$/ # for command-line
@os, @version = arch
return
end
@@ -107,7 +107,7 @@ class Gem::Platform
when /mingw-?(\w+)?/ then [ "mingw", $1 ]
when /(mswin\d+)(\_(\d+))?/ then
os, version = $1, $3
- @cpu = "x86" if @cpu.nil? and os =~ /32$/
+ @cpu = "x86" if @cpu.nil? && os =~ /32$/
[os, version]
when /netbsdelf/ then [ "netbsdelf", nil ]
when /openbsd(\d+\.\d+)?/ then [ "openbsd", $1 ]
@@ -139,7 +139,7 @@ class Gem::Platform
# the same CPU, OS and version.
def ==(other)
- self.class === other and to_a == other.to_a
+ self.class === other && to_a == other.to_a
end
alias :eql? :==
@@ -160,18 +160,18 @@ class Gem::Platform
return nil unless Gem::Platform === other
# universal-mingw32 matches x64-mingw-ucrt
- return true if (@cpu == "universal" or other.cpu == "universal") and
- @os.start_with?("mingw") and other.os.start_with?("mingw")
+ return true if (@cpu == "universal" || other.cpu == "universal") &&
+ @os.start_with?("mingw") && other.os.start_with?("mingw")
# cpu
- ([nil,"universal"].include?(@cpu) or [nil, "universal"].include?(other.cpu) or @cpu == other.cpu or
- (@cpu == "arm" and other.cpu.start_with?("arm"))) and
+ ([nil,"universal"].include?(@cpu) || [nil, "universal"].include?(other.cpu) || @cpu == other.cpu ||
+ (@cpu == "arm" && other.cpu.start_with?("arm"))) &&
- # os
- @os == other.os and
+ # os
+ @os == other.os &&
- # version
- (@version.nil? or other.version.nil? or @version == other.version)
+ # version
+ (@version.nil? || other.version.nil? || @version == other.version)
end
##
diff --git a/lib/rubygems/query_utils.rb b/lib/rubygems/query_utils.rb
index 4601d9374c..a502717f94 100644
--- a/lib/rubygems/query_utils.rb
+++ b/lib/rubygems/query_utils.rb
@@ -112,7 +112,7 @@ module Gem::QueryUtils
end
def display_header(type)
- if (ui.outs.tty? and Gem.configuration.verbose) or both?
+ if (ui.outs.tty? && Gem.configuration.verbose) || both?
say
say "*** #{type} GEMS ***"
say
@@ -132,7 +132,7 @@ module Gem::QueryUtils
name_matches = name ? s.name =~ name : true
version_matches = show_prereleases? || !s.version.prerelease?
- name_matches and version_matches
+ name_matches && version_matches
end
spec_tuples = specs.map do |spec|
@@ -176,7 +176,7 @@ module Gem::QueryUtils
# Check if gem +name+ version +version+ is installed.
def installed?(name, req = Gem::Requirement.default)
- Gem::Specification.any? {|s| s.name =~ name and req =~ s.version }
+ Gem::Specification.any? {|s| s.name =~ name && req =~ s.version }
end
def output_query_results(spec_tuples)
@@ -242,7 +242,7 @@ module Gem::QueryUtils
return unless options[:versions]
list =
- if platforms.empty? or options[:details]
+ if platforms.empty? || options[:details]
name_tuples.map {|n| n.version }.uniq
else
platforms.sort.reverse.map do |version, pls|
@@ -289,13 +289,13 @@ module Gem::QueryUtils
end
def spec_homepage(entry, spec)
- return if spec.homepage.nil? or spec.homepage.empty?
+ return if spec.homepage.nil? || spec.homepage.empty?
entry << "\n" << format_text("Homepage: #{spec.homepage}", 68, 4)
end
def spec_license(entry, spec)
- return if spec.license.nil? or spec.license.empty?
+ return if spec.license.nil? || spec.license.empty?
licenses = "License#{spec.licenses.length > 1 ? 's' : ''}: ".dup
licenses << spec.licenses.join(", ")
diff --git a/lib/rubygems/remote_fetcher.rb b/lib/rubygems/remote_fetcher.rb
index d028739861..0ac6eaa130 100644
--- a/lib/rubygems/remote_fetcher.rb
+++ b/lib/rubygems/remote_fetcher.rb
@@ -114,7 +114,7 @@ class Gem::RemoteFetcher
cache_dir =
if Dir.pwd == install_dir # see fetch_command
install_dir
- elsif File.writable?(install_cache_dir) || (File.writable?(install_dir) && (not File.exist?(install_cache_dir)))
+ elsif File.writable?(install_cache_dir) || (File.writable?(install_dir) && (!File.exist?(install_cache_dir)))
install_cache_dir
else
File.join Gem.user_dir, "cache"
@@ -247,7 +247,7 @@ class Gem::RemoteFetcher
data = send "fetch_#{uri.scheme}", uri, mtime, head
- if data and !head and uri.to_s.end_with?(".gz")
+ if data && !head && uri.to_s.end_with?(".gz")
begin
data = Gem::Util.gunzip data
rescue Zlib::GzipFile::Error
@@ -288,7 +288,7 @@ class Gem::RemoteFetcher
return Gem.read_binary(path)
end
- if update and path
+ if update && path
Gem.write_binary(path, data)
end
diff --git a/lib/rubygems/request.rb b/lib/rubygems/request.rb
index d15ba91209..c3ea46e0eb 100644
--- a/lib/rubygems/request.rb
+++ b/lib/rubygems/request.rb
@@ -173,7 +173,7 @@ class Gem::Request
require "uri"
uri = URI(Gem::UriFormatter.new(env_proxy).normalize)
- if uri and uri.user.nil? and uri.password.nil?
+ if uri && uri.user.nil? && uri.password.nil?
user = ENV["#{_scheme}_proxy_user"] || ENV["#{_SCHEME}_PROXY_USER"]
password = ENV["#{_scheme}_proxy_pass"] || ENV["#{_SCHEME}_PROXY_PASS"]
diff --git a/lib/rubygems/request/connection_pools.rb b/lib/rubygems/request/connection_pools.rb
index a283267674..44280489fb 100644
--- a/lib/rubygems/request/connection_pools.rb
+++ b/lib/rubygems/request/connection_pools.rb
@@ -39,7 +39,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? || env_no_proxy.empty?
env_no_proxy.split(/\s*,\s*/)
end
@@ -78,7 +78,7 @@ class Gem::Request::ConnectionPools # :nodoc:
no_proxy = get_no_proxy_from_env
- if proxy_uri and not no_proxy?(hostname, no_proxy)
+ if proxy_uri && !no_proxy?(hostname, no_proxy)
proxy_hostname = proxy_uri.respond_to?(:hostname) ? proxy_uri.hostname : proxy_uri.host
net_http_args + [
proxy_hostname,
diff --git a/lib/rubygems/request/http_pool.rb b/lib/rubygems/request/http_pool.rb
index f028516db8..7b309eedd3 100644
--- a/lib/rubygems/request/http_pool.rb
+++ b/lib/rubygems/request/http_pool.rb
@@ -26,7 +26,7 @@ class Gem::Request::HTTPPool # :nodoc:
def close_all
until @queue.empty?
- if connection = @queue.pop(true) and connection.started?
+ if (connection = @queue.pop(true)) && connection.started?
connection.finish
end
end
diff --git a/lib/rubygems/request_set.rb b/lib/rubygems/request_set.rb
index df215e4af3..64701a8214 100644
--- a/lib/rubygems/request_set.rb
+++ b/lib/rubygems/request_set.rb
@@ -443,14 +443,14 @@ class Gem::RequestSet
def tsort_each_child(node) # :nodoc:
node.spec.dependencies.each do |dep|
- next if dep.type == :development and not @development
+ next if dep.type == :development && !@development
match = @requests.find do |r|
- dep.match? r.spec.name, r.spec.version, @prerelease
+ dep.match? r.spec.name, r.spec.version, r.spec.is_a?(Gem::Resolver::InstalledSpecification) || @prerelease
end
unless match
- next if dep.type == :development and @development_shallow
+ next if dep.type == :development && @development_shallow
next if @soft_missing
raise Gem::DependencyError,
"Unresolved dependency found during sorting - #{dep} (requested by #{node.spec.full_name})"
diff --git a/lib/rubygems/request_set/gem_dependency_api.rb b/lib/rubygems/request_set/gem_dependency_api.rb
index 568d9f952f..fe75ac5208 100644
--- a/lib/rubygems/request_set/gem_dependency_api.rb
+++ b/lib/rubygems/request_set/gem_dependency_api.rb
@@ -371,7 +371,7 @@ class Gem::RequestSet::GemDependencyAPI
duplicate = @dependencies.include? name
@dependencies[name] =
- if requirements.empty? and not source_set
+ if requirements.empty? && !source_set
Gem::Requirement.default
elsif source_set
Gem::Requirement.source_set
@@ -789,7 +789,7 @@ Gem dependencies file #{@path} includes git reference for both ref/branch and ta
raise ArgumentError,
"You must specify engine_version along with the Ruby engine" if
- engine and not engine_version
+ engine && !engine_version
return true if @installing
@@ -800,7 +800,7 @@ Gem dependencies file #{@path} includes git reference for both ref/branch and ta
raise Gem::RubyVersionMismatch, message
end
- if engine and engine != Gem.ruby_engine
+ if engine && engine != Gem.ruby_engine
message = "Your Ruby engine is #{Gem.ruby_engine}, " +
"but your #{gem_deps_file} requires #{engine}"
diff --git a/lib/rubygems/request_set/lockfile/parser.rb b/lib/rubygems/request_set/lockfile/parser.rb
index 376d37f9e2..8446f9df8e 100644
--- a/lib/rubygems/request_set/lockfile/parser.rb
+++ b/lib/rubygems/request_set/lockfile/parser.rb
@@ -30,7 +30,7 @@ class Gem::RequestSet::Lockfile::Parser
when "PLATFORMS" then
parse_PLATFORMS
else
- token = get until @tokens.empty? or peek.first == :section
+ token = get until @tokens.empty? || peek.first == :section
end
else
raise "BUG: unhandled token #{token.type} (#{token.value.inspect}) at line #{token.line} column #{token.column}"
@@ -44,7 +44,7 @@ class Gem::RequestSet::Lockfile::Parser
def get(expected_types = nil, expected_value = nil) # :nodoc:
token = @tokens.shift
- if expected_types and not Array(expected_types).include? token.type
+ if expected_types && !Array(expected_types).include?(token.type)
unget token
message = "unexpected token [#{token.type.inspect}, #{token.value.inspect}], " +
@@ -53,7 +53,7 @@ class Gem::RequestSet::Lockfile::Parser
raise Gem::RequestSet::Lockfile::ParseError.new message, token.column, token.line, @filename
end
- if expected_value and expected_value != token.value
+ if expected_value && expected_value != token.value
unget token
message = "unexpected token [#{token.type.inspect}, #{token.value.inspect}], " +
@@ -67,7 +67,7 @@ class Gem::RequestSet::Lockfile::Parser
end
def parse_DEPENDENCIES # :nodoc:
- while not @tokens.empty? and :text == peek.type do
+ while !@tokens.empty? && :text == peek.type do
token = get :text
requirements = []
@@ -127,7 +127,7 @@ class Gem::RequestSet::Lockfile::Parser
set = Gem::Resolver::LockSet.new sources
last_specs = nil
- while not @tokens.empty? and :text == peek.type do
+ while !@tokens.empty? && :text == peek.type do
token = get :text
name = token.value
column = token.column
@@ -144,7 +144,7 @@ class Gem::RequestSet::Lockfile::Parser
type = token.type
data = token.value
- if type == :text and column == 4
+ if type == :text && column == 4
version, platform = data.split "-", 2
platform =
@@ -183,7 +183,7 @@ class Gem::RequestSet::Lockfile::Parser
type = peek.type
value = peek.value
- if type == :entry and %w[branch ref tag].include? value
+ if type == :entry && %w[branch ref tag].include?(value)
get
get :text
@@ -199,7 +199,7 @@ class Gem::RequestSet::Lockfile::Parser
last_spec = nil
- while not @tokens.empty? and :text == peek.type do
+ while !@tokens.empty? && :text == peek.type do
token = get :text
name = token.value
column = token.column
@@ -214,7 +214,7 @@ class Gem::RequestSet::Lockfile::Parser
type = token.type
data = token.value
- if type == :text and column == 4
+ if type == :text && column == 4
last_spec = set.add_git_spec name, data, repository, revision, true
else
dependency = parse_dependency name, data
@@ -246,7 +246,7 @@ class Gem::RequestSet::Lockfile::Parser
set = Gem::Resolver::VendorSet.new
last_spec = nil
- while not @tokens.empty? and :text == peek.first do
+ while !@tokens.empty? && :text == peek.first do
token = get :text
name = token.value
column = token.column
@@ -261,7 +261,7 @@ class Gem::RequestSet::Lockfile::Parser
type = token.type
data = token.value
- if type == :text and column == 4
+ if type == :text && column == 4
last_spec = set.add_vendor_gem name, directory
else
dependency = parse_dependency name, data
@@ -281,7 +281,7 @@ class Gem::RequestSet::Lockfile::Parser
end
def parse_PLATFORMS # :nodoc:
- while not @tokens.empty? and :text == peek.first do
+ while !@tokens.empty? && :text == peek.first do
name = get(:text).value
@platforms << name
diff --git a/lib/rubygems/request_set/lockfile/tokenizer.rb b/lib/rubygems/request_set/lockfile/tokenizer.rb
index 79c573a02d..4476a041c4 100644
--- a/lib/rubygems/request_set/lockfile/tokenizer.rb
+++ b/lib/rubygems/request_set/lockfile/tokenizer.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: true
+#) frozen_string_literal: true
require_relative "parser"
class Gem::RequestSet::Lockfile::Tokenizer
@@ -26,7 +26,7 @@ class Gem::RequestSet::Lockfile::Tokenizer
end
def skip(type)
- @tokens.shift while not @tokens.empty? and peek.type == type
+ @tokens.shift while !@tokens.empty? && peek.type == type
end
##
diff --git a/lib/rubygems/requirement.rb b/lib/rubygems/requirement.rb
index 12bf371f4e..4f19b8c5b0 100644
--- a/lib/rubygems/requirement.rb
+++ b/lib/rubygems/requirement.rb
@@ -253,7 +253,7 @@ class Gem::Requirement
def specific?
return true if @requirements.length > 1 # GIGO, > 1, > 2 is silly
- not %w[> >=].include? @requirements.first.first # grab the operator
+ !%w[> >=].include? @requirements.first.first # grab the operator
end
def to_s # :nodoc:
diff --git a/lib/rubygems/resolver.rb b/lib/rubygems/resolver.rb
index 097e8243ee..bf7d6d943b 100644
--- a/lib/rubygems/resolver.rb
+++ b/lib/rubygems/resolver.rb
@@ -153,10 +153,10 @@ class Gem::Resolver
s.fetch_development_dependencies if @development
s.dependencies.reverse_each do |d|
- next if d.type == :development and not @development
- next if d.type == :development and @development_shallow and
+ next if d.type == :development && !@development
+ next if d.type == :development && @development_shallow &&
act.development?
- next if d.type == :development and @development_shallow and
+ next if d.type == :development && @development_shallow &&
act.parent
reqs << Gem::Resolver::DependencyRequest.new(d, act)
@@ -192,7 +192,7 @@ class Gem::Resolver
conflict = e.conflicts.values.first
raise Gem::DependencyResolutionError, Conflict.new(conflict.requirement_trees.first.first, conflict.existing, conflict.requirement)
ensure
- @output.close if defined?(@output) and !debug?
+ @output.close if defined?(@output) && !debug?
end
##
diff --git a/lib/rubygems/resolver/api_specification.rb b/lib/rubygems/resolver/api_specification.rb
index 7af4d9cff3..1e65d5e5a9 100644
--- a/lib/rubygems/resolver/api_specification.rb
+++ b/lib/rubygems/resolver/api_specification.rb
@@ -40,10 +40,10 @@ class Gem::Resolver::APISpecification < Gem::Resolver::Specification
end
def ==(other) # :nodoc:
- self.class === other and
- @set == other.set and
- @name == other.name and
- @version == other.version and
+ self.class === other &&
+ @set == other.set &&
+ @name == other.name &&
+ @version == other.version &&
@platform == other.platform
end
diff --git a/lib/rubygems/resolver/best_set.rb b/lib/rubygems/resolver/best_set.rb
index ab91ebca08..075ee1ef5c 100644
--- a/lib/rubygems/resolver/best_set.rb
+++ b/lib/rubygems/resolver/best_set.rb
@@ -25,7 +25,7 @@ class Gem::Resolver::BestSet < Gem::Resolver::ComposedSet
end
def find_all(req) # :nodoc:
- pick_sets if @remote and @sets.empty?
+ pick_sets if @remote && @sets.empty?
super
rescue Gem::RemoteFetcher::FetchError => e
@@ -35,7 +35,7 @@ class Gem::Resolver::BestSet < Gem::Resolver::ComposedSet
end
def prefetch(reqs) # :nodoc:
- pick_sets if @remote and @sets.empty?
+ pick_sets if @remote && @sets.empty?
super
end
@@ -63,7 +63,7 @@ class Gem::Resolver::BestSet < Gem::Resolver::ComposedSet
uri = uri + "."
raise error unless api_set = @sets.find do |set|
- Gem::Resolver::APISet === set and set.dep_uri == uri
+ Gem::Resolver::APISet === set && set.dep_uri == uri
end
index_set = Gem::Resolver::IndexSet.new api_set.source
diff --git a/lib/rubygems/resolver/conflict.rb b/lib/rubygems/resolver/conflict.rb
index 54a7ca4641..aba6d73ea7 100644
--- a/lib/rubygems/resolver/conflict.rb
+++ b/lib/rubygems/resolver/conflict.rb
@@ -27,9 +27,9 @@ class Gem::Resolver::Conflict
end
def ==(other) # :nodoc:
- self.class === other and
- @dependency == other.dependency and
- @activated == other.activated and
+ self.class === other &&
+ @dependency == other.dependency &&
+ @activated == other.activated &&
@failed_dep == other.failed_dep
end
diff --git a/lib/rubygems/resolver/git_specification.rb b/lib/rubygems/resolver/git_specification.rb
index d1e04737da..6a178ea82e 100644
--- a/lib/rubygems/resolver/git_specification.rb
+++ b/lib/rubygems/resolver/git_specification.rb
@@ -6,9 +6,9 @@
class Gem::Resolver::GitSpecification < Gem::Resolver::SpecSpecification
def ==(other) # :nodoc:
- self.class === other and
- @set == other.set and
- @spec == other.spec and
+ self.class === other &&
+ @set == other.set &&
+ @spec == other.spec &&
@source == other.source
end
diff --git a/lib/rubygems/resolver/index_specification.rb b/lib/rubygems/resolver/index_specification.rb
index e8c3b35f7e..0fc758dfd3 100644
--- a/lib/rubygems/resolver/index_specification.rb
+++ b/lib/rubygems/resolver/index_specification.rb
@@ -21,7 +21,8 @@ class Gem::Resolver::IndexSpecification < Gem::Resolver::Specification
@name = name
@version = version
@source = source
- @platform = platform.to_s
+ @platform = Gem::Platform.new(platform.to_s)
+ @original_platform = platform.to_s
@spec = nil
end
@@ -91,7 +92,7 @@ class Gem::Resolver::IndexSpecification < Gem::Resolver::Specification
def spec # :nodoc:
@spec ||=
begin
- tuple = Gem::NameTuple.new @name, @version, @platform
+ tuple = Gem::NameTuple.new @name, @version, @original_platform
@source.fetch_spec tuple
end
diff --git a/lib/rubygems/resolver/installed_specification.rb b/lib/rubygems/resolver/installed_specification.rb
index 7c7ad8d85b..8932e068be 100644
--- a/lib/rubygems/resolver/installed_specification.rb
+++ b/lib/rubygems/resolver/installed_specification.rb
@@ -5,8 +5,8 @@
class Gem::Resolver::InstalledSpecification < Gem::Resolver::SpecSpecification
def ==(other) # :nodoc:
- self.class === other and
- @set == other.set and
+ self.class === other &&
+ @set == other.set &&
@spec == other.spec
end
diff --git a/lib/rubygems/resolver/installer_set.rb b/lib/rubygems/resolver/installer_set.rb
index 15580d7095..f663ce4ad5 100644
--- a/lib/rubygems/resolver/installer_set.rb
+++ b/lib/rubygems/resolver/installer_set.rb
@@ -61,13 +61,12 @@ class Gem::Resolver::InstallerSet < Gem::Resolver::Set
found = find_all request
found.delete_if do |s|
- s.version.prerelease? and not s.local?
+ s.version.prerelease? && !s.local?
end unless dependency.prerelease?
found = found.select do |s|
- Gem::Source::SpecificFile === s.source or
- Gem::Platform::RUBY == s.platform or
- Gem::Platform.local === s.platform
+ Gem::Source::SpecificFile === s.source ||
+ Gem::Platform.match(s.platform)
end
found = found.sort_by do |s|
@@ -111,14 +110,14 @@ class Gem::Resolver::InstallerSet < Gem::Resolver::Set
# Should local gems should be considered?
def consider_local? # :nodoc:
- @domain == :both or @domain == :local
+ @domain == :both || @domain == :local
end
##
# Should remote gems should be considered?
def consider_remote? # :nodoc:
- @domain == :both or @domain == :remote
+ @domain == :both || @domain == :remote
end
##
@@ -137,8 +136,8 @@ class Gem::Resolver::InstallerSet < Gem::Resolver::Set
dep = req.dependency
- return res if @ignore_dependencies and
- @always_install.none? {|spec| dep.match? spec }
+ return res if @ignore_dependencies &&
+ @always_install.none? {|spec| dep.match? spec }
name = dep.name
@@ -168,10 +167,6 @@ class Gem::Resolver::InstallerSet < Gem::Resolver::Set
end
end
- res.delete_if do |spec|
- spec.version.prerelease? and not dep.prerelease?
- end
-
res.concat @remote_set.find_all req if consider_remote?
res
diff --git a/lib/rubygems/resolver/lock_set.rb b/lib/rubygems/resolver/lock_set.rb
index ff6c6c912f..b1a5433cb5 100644
--- a/lib/rubygems/resolver/lock_set.rb
+++ b/lib/rubygems/resolver/lock_set.rb
@@ -54,7 +54,7 @@ class Gem::Resolver::LockSet < Gem::Resolver::Set
dep = Gem::Dependency.new name, version
found = @specs.find do |spec|
- dep.matches_spec? spec and spec.platform == platform
+ dep.matches_spec?(spec) && spec.platform == platform
end
tuple = Gem::NameTuple.new found.name, found.version, found.platform
diff --git a/lib/rubygems/resolver/lock_specification.rb b/lib/rubygems/resolver/lock_specification.rb
index 4a30dcf849..7de2a14658 100644
--- a/lib/rubygems/resolver/lock_specification.rb
+++ b/lib/rubygems/resolver/lock_specification.rb
@@ -71,7 +71,7 @@ class Gem::Resolver::LockSpecification < Gem::Resolver::Specification
def spec
@spec ||= Gem::Specification.find do |spec|
- spec.name == @name and spec.version == @version
+ spec.name == @name && spec.version == @version
end
@spec ||= Gem::Specification.new do |s|
diff --git a/lib/rubygems/resolver/vendor_specification.rb b/lib/rubygems/resolver/vendor_specification.rb
index 8dfe5940f2..600a98a2bf 100644
--- a/lib/rubygems/resolver/vendor_specification.rb
+++ b/lib/rubygems/resolver/vendor_specification.rb
@@ -6,9 +6,9 @@
class Gem::Resolver::VendorSpecification < Gem::Resolver::SpecSpecification
def ==(other) # :nodoc:
- self.class === other and
- @set == other.set and
- @spec == other.spec and
+ self.class === other &&
+ @set == other.set &&
+ @spec == other.spec &&
@source == other.source
end
diff --git a/lib/rubygems/security.rb b/lib/rubygems/security.rb
index 4eb4023055..dd16283a98 100644
--- a/lib/rubygems/security.rb
+++ b/lib/rubygems/security.rb
@@ -618,7 +618,7 @@ module Gem::Security
path = File.expand_path path
File.open path, "wb", permissions do |io|
- if passphrase and cipher
+ if passphrase && cipher
io.write pemmable.to_pem cipher, passphrase
else
io.write pemmable.to_pem
diff --git a/lib/rubygems/security/policy.rb b/lib/rubygems/security/policy.rb
index 43588fd7f1..959880ddc1 100644
--- a/lib/rubygems/security/policy.rb
+++ b/lib/rubygems/security/policy.rb
@@ -88,16 +88,16 @@ class Gem::Security::Policy
message = "certificate #{signer.subject}"
- if not_before = signer.not_before and not_before > time
+ if (not_before = signer.not_before) && not_before > time
raise Gem::Security::Exception,
"#{message} not valid before #{not_before}"
end
- if not_after = signer.not_after and not_after < time
+ if (not_after = signer.not_after) && not_after < time
raise Gem::Security::Exception, "#{message} not valid after #{not_after}"
end
- if issuer and not signer.verify issuer.public_key
+ if issuer && !signer.verify(issuer.public_key)
raise Gem::Security::Exception,
"#{message} was not issued by #{issuer.subject}"
end
@@ -109,7 +109,7 @@ class Gem::Security::Policy
# Ensures the public key of +key+ matches the public key in +signer+
def check_key(signer, key)
- unless signer and key
+ unless signer && key
return true unless @only_signed
raise Gem::Security::Exception, "missing key or signature"
@@ -231,7 +231,7 @@ class Gem::Security::Policy
if @verify_data
raise Gem::Security::Exception, "no digests provided (probable bug)" if
- signer_digests.nil? or signer_digests.empty?
+ signer_digests.nil? || signer_digests.empty?
else
signer_digests = {}
end
@@ -248,7 +248,7 @@ class Gem::Security::Policy
if @only_trusted
check_trust chain, digester, trust_dir
- elsif signatures.empty? and digests.empty?
+ elsif signatures.empty? && digests.empty?
# trust is irrelevant if there's no signatures to verify
else
alert_warning "#{subject signer} is not trusted for #{full_name}"
diff --git a/lib/rubygems/security/signer.rb b/lib/rubygems/security/signer.rb
index b1308c4e42..cca82f1cf8 100644
--- a/lib/rubygems/security/signer.rb
+++ b/lib/rubygems/security/signer.rb
@@ -141,7 +141,7 @@ class Gem::Security::Signer
raise Gem::Security::Exception, "no certs provided" if @cert_chain.empty?
- if @cert_chain.length == 1 and @cert_chain.last.not_after < Time.now
+ if @cert_chain.length == 1 && @cert_chain.last.not_after < Time.now
alert("Your certificate has expired, trying to re-sign it...")
re_sign_key(
diff --git a/lib/rubygems/source.rb b/lib/rubygems/source.rb
index 7c3b678645..fc72a1038a 100644
--- a/lib/rubygems/source.rb
+++ b/lib/rubygems/source.rb
@@ -62,7 +62,7 @@ class Gem::Source
end
def ==(other) # :nodoc:
- self.class === other and @uri == other.uri
+ self.class === other && @uri == other.uri
end
alias_method :eql?, :== # :nodoc:
diff --git a/lib/rubygems/source/git.rb b/lib/rubygems/source/git.rb
index 22355adcfa..2609a309e8 100644
--- a/lib/rubygems/source/git.rb
+++ b/lib/rubygems/source/git.rb
@@ -76,10 +76,10 @@ class Gem::Source::Git < Gem::Source
end
def ==(other) # :nodoc:
- super and
- @name == other.name and
- @repository == other.repository and
- @reference == other.reference and
+ super &&
+ @name == other.name &&
+ @repository == other.repository &&
+ @reference == other.reference &&
@need_submodules == other.need_submodules
end
diff --git a/lib/rubygems/spec_fetcher.rb b/lib/rubygems/spec_fetcher.rb
index 43e7e05b63..0d06d1f144 100644
--- a/lib/rubygems/spec_fetcher.rb
+++ b/lib/rubygems/spec_fetcher.rb
@@ -98,7 +98,7 @@ class Gem::SpecFetcher
found[source] = specs.select do |tup|
if dependency.match?(tup)
- if matching_platform and !Gem::Platform.match_gem?(tup.platform, tup.name)
+ if matching_platform && !Gem::Platform.match_gem?(tup.platform, tup.name)
pm = (
rejected_specs[dependency] ||= \
Gem::PlatformMismatch.new(tup.name, tup.version))
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb
index 00d139d854..82000bb75d 100644
--- a/lib/rubygems/specification.rb
+++ b/lib/rubygems/specification.rb
@@ -473,7 +473,7 @@ class Gem::Specification < Gem::BasicSpecification
# spec.platform = Gem::Platform.local
def platform=(platform)
- if @original_platform.nil? or
+ if @original_platform.nil? ||
@original_platform == Gem::Platform::RUBY
@original_platform = platform
end
@@ -1046,7 +1046,7 @@ class Gem::Specification < Gem::BasicSpecification
def self.find_active_stub_by_path(path)
stub = @@active_stub_with_requirable_file[path] ||= (stubs.find do |s|
- s.activated? and s.contains_requirable_file? path
+ s.activated? && s.contains_requirable_file?(path)
end || NOT_FOUND)
stub.this
end
@@ -1234,7 +1234,7 @@ class Gem::Specification < Gem::BasicSpecification
latest_remote = remotes.sort.last
yield [local_spec, latest_remote] if
- latest_remote and local_spec.version < latest_remote
+ latest_remote && local_spec.version < latest_remote
end
nil
@@ -1557,7 +1557,7 @@ class Gem::Specification < Gem::BasicSpecification
# Singular reader for #authors. Returns the first author in the list
def author
- val = authors and val.first
+ (val = authors) && val.first
end
##
@@ -1669,7 +1669,7 @@ class Gem::Specification < Gem::BasicSpecification
conflicts = {}
self.runtime_dependencies.each do |dep|
spec = Gem.loaded_specs[dep.name]
- if spec and not spec.satisfies_requirement? dep
+ if spec && !spec.satisfies_requirement?(dep)
(conflicts[spec] ||= []) << dep
end
end
@@ -1696,7 +1696,7 @@ class Gem::Specification < Gem::BasicSpecification
self.dependencies.any? do |dep|
if dep.runtime?
spec = Gem.loaded_specs[dep.name]
- spec and not spec.satisfies_requirement? dep
+ spec && !spec.satisfies_requirement?(dep)
else
false
end
@@ -1717,7 +1717,7 @@ class Gem::Specification < Gem::BasicSpecification
DateLike = Object.new # :nodoc:
def DateLike.===(obj) # :nodoc:
- defined?(::Date) and Date === obj
+ defined?(::Date) && Date === obj
end
DateTimeFormat = # :nodoc:
@@ -1757,9 +1757,9 @@ class Gem::Specification < Gem::BasicSpecification
# executable now. See Gem.bin_path.
def default_executable # :nodoc:
- if defined?(@default_executable) and @default_executable
+ if defined?(@default_executable) && @default_executable
result = @default_executable
- elsif @executables and @executables.size == 1
+ elsif @executables && @executables.size == 1
result = Array(@executables).first
else
result = nil
@@ -1876,7 +1876,7 @@ class Gem::Specification < Gem::BasicSpecification
# Singular accessor for #executables
def executable
- val = executables and val.first
+ (val = executables) && val.first
end
##
@@ -1988,7 +1988,7 @@ class Gem::Specification < Gem::BasicSpecification
# True if this gem has files in test_files
def has_unit_tests? # :nodoc:
- not test_files.empty?
+ !test_files.empty?
end
# :stopdoc:
@@ -2041,7 +2041,7 @@ class Gem::Specification < Gem::BasicSpecification
self.name = name if name
self.version = version if version
- if platform = Gem.platforms.last and platform != Gem::Platform::RUBY and platform != Gem::Platform.local
+ if (platform = Gem.platforms.last) && platform != Gem::Platform::RUBY && platform != Gem::Platform.local
self.platform = platform
end
@@ -2156,8 +2156,8 @@ class Gem::Specification < Gem::BasicSpecification
return
end
- if @specification_version > CURRENT_SPECIFICATION_VERSION and
- sym.to_s.end_with?("=")
+ if @specification_version > CURRENT_SPECIFICATION_VERSION &&
+ sym.to_s.end_with?("=")
warn "ignoring #{sym} loading #{full_name}" if $DEBUG
else
super
@@ -2183,7 +2183,7 @@ class Gem::Specification < Gem::BasicSpecification
# file list.
def normalize
- if defined?(@extra_rdoc_files) and @extra_rdoc_files
+ if defined?(@extra_rdoc_files) && @extra_rdoc_files
@extra_rdoc_files.uniq!
@files ||= []
@files.concat(@extra_rdoc_files)
@@ -2208,7 +2208,7 @@ class Gem::Specification < Gem::BasicSpecification
# platform. For use with legacy gems.
def original_name # :nodoc:
- if platform == Gem::Platform::RUBY or platform.nil?
+ if platform == Gem::Platform::RUBY || platform.nil?
"#{@name}-#{@version}"
else
"#{@name}-#{@version}-#{@original_platform}"
@@ -2241,8 +2241,8 @@ class Gem::Specification < Gem::BasicSpecification
attributes.each do |attr_name|
current_value = self.send attr_name
current_value = current_value.sort if %i[files test_files].include? attr_name
- if current_value != default_value(attr_name) or
- self.class.required_attribute? attr_name
+ if current_value != default_value(attr_name) ||
+ self.class.required_attribute?(attr_name)
q.text "s.#{attr_name} = "
@@ -2300,7 +2300,7 @@ class Gem::Specification < Gem::BasicSpecification
# Singular accessor for #require_paths
def require_path
- val = require_paths and val.first
+ (val = require_paths) && val.first
end
##
@@ -2375,7 +2375,7 @@ class Gem::Specification < Gem::BasicSpecification
def satisfies_requirement?(dependency)
return @name == dependency.name &&
- dependency.requirement.satisfied_by?(@version)
+ dependency.requirement.satisfied_by?(@version)
end
##
@@ -2429,7 +2429,7 @@ class Gem::Specification < Gem::BasicSpecification
# Singular accessor for #test_files
def test_file # :nodoc:
- val = test_files and val.first
+ (val = test_files) && val.first
end
##
@@ -2451,7 +2451,7 @@ class Gem::Specification < Gem::BasicSpecification
@test_files = [@test_suite_file].flatten
@test_suite_file = nil
end
- if defined?(@test_files) and @test_files
+ if defined?(@test_files) && @test_files
@test_files
else
@test_files = []
@@ -2475,13 +2475,13 @@ class Gem::Specification < Gem::BasicSpecification
result << " s.name = #{ruby_code name}"
result << " s.version = #{ruby_code version}"
- unless platform.nil? or platform == Gem::Platform::RUBY
+ unless platform.nil? || platform == Gem::Platform::RUBY
result << " s.platform = #{ruby_code original_platform}"
end
result << ""
result << " s.required_rubygems_version = #{ruby_code required_rubygems_version} if s.respond_to? :required_rubygems_version="
- if metadata and !metadata.empty?
+ if metadata && !metadata.empty?
result << " s.metadata = #{ruby_code metadata} if s.respond_to? :metadata="
end
result << " s.require_paths = #{ruby_code raw_require_paths}"
@@ -2665,6 +2665,8 @@ class Gem::Specification < Gem::BasicSpecification
def version=(version)
@version = Gem::Version.create(version)
+ return if @version.nil?
+
# skip to set required_ruby_version when pre-released rubygems.
# It caused to raise CircularDependencyError
if @version.prerelease? && (@name.nil? || @name.strip != "rubygems")
diff --git a/lib/rubygems/specification_policy.rb b/lib/rubygems/specification_policy.rb
index 332189ae9f..44b31211e5 100644
--- a/lib/rubygems/specification_policy.rb
+++ b/lib/rubygems/specification_policy.rb
@@ -188,7 +188,7 @@ duplicate dependency on #{dep}, (#{prev.requirement}) use:
prerelease_dep && !@specification.version.prerelease?
open_ended = dep.requirement.requirements.all? do |op, version|
- not version.prerelease? and (op == ">" or op == ">=")
+ !version.prerelease? && (op == ">" || op == ">=")
end
if open_ended
@@ -203,7 +203,7 @@ duplicate dependency on #{dep}, (#{prev.requirement}) use:
else
bugfix = if op == ">"
", '> #{dep_version}'"
- elsif op == ">=" and base != segments
+ elsif op == ">=" && base != segments
", '>= #{dep_version}'"
end
@@ -338,7 +338,7 @@ duplicate dependency on #{dep}, (#{prev.requirement}) use:
String
end
- unless Array === val and val.all? {|x| x.kind_of?(klass) }
+ unless Array === val && val.all? {|x| x.kind_of?(klass) }
error "#{field} must be an Array of #{klass}"
end
end
@@ -404,7 +404,7 @@ http://spdx.org/licenses or '#{Gem::Licenses::NONSTANDARD}' for a nonstandard li
homepage = @specification.homepage
# Make sure a homepage is valid HTTP/HTTPS URI
- if homepage and not homepage.empty?
+ if homepage && !homepage.empty?
require "uri"
begin
homepage_uri = URI.parse(homepage)
diff --git a/lib/rubygems/uninstaller.rb b/lib/rubygems/uninstaller.rb
index 1ae301a44d..5883ed1c41 100644
--- a/lib/rubygems/uninstaller.rb
+++ b/lib/rubygems/uninstaller.rb
@@ -105,8 +105,8 @@ class Gem::Uninstaller
@default_specs_matching_uninstall_params = default_specs
list, other_repo_specs = list.partition do |spec|
- @gem_home == spec.base_dir or
- (@user_install and spec.base_dir == Gem.user_dir)
+ @gem_home == spec.base_dir ||
+ (@user_install && spec.base_dir == Gem.user_dir)
end
list.sort!
@@ -239,8 +239,8 @@ class Gem::Uninstaller
# spec:: the spec of the gem to be uninstalled
def remove(spec)
- unless path_ok?(@gem_home, spec) or
- (@user_install and path_ok?(Gem.user_dir, spec))
+ unless path_ok?(@gem_home, spec) ||
+ (@user_install && path_ok?(Gem.user_dir, spec))
e = Gem::GemNotInHomeException.new \
"Gem '#{spec.full_name}' is not installed in directory #{@gem_home}"
e.spec = spec
diff --git a/lib/rubygems/user_interaction.rb b/lib/rubygems/user_interaction.rb
index 4b0a7c60bb..2fa505423b 100644
--- a/lib/rubygems/user_interaction.rb
+++ b/lib/rubygems/user_interaction.rb
@@ -284,7 +284,7 @@ class Gem::StreamUI
# Ask a question. Returns an answer if connected to a tty, nil otherwise.
def ask(question)
- return nil if not tty?
+ return nil if !tty?
@outs.print(question + " ")
@outs.flush
@@ -298,7 +298,7 @@ class Gem::StreamUI
# Ask for a password. Does not echo response to terminal.
def ask_for_password(question)
- return nil if not tty?
+ return nil if !tty?
@outs.print(question, " ")
@outs.flush
diff --git a/lib/rubygems/version.rb b/lib/rubygems/version.rb
index 03ae5ca17e..f67889ef1a 100644
--- a/lib/rubygems/version.rb
+++ b/lib/rubygems/version.rb
@@ -171,9 +171,7 @@ class Gem::Version
# True if the +version+ string matches RubyGems' requirements.
def self.correct?(version)
- unless Gem::Deprecate.skip
- warn "nil versions are discouraged and will be deprecated in Rubygems 4" if version.nil?
- end
+ nil_versions_are_discouraged! if version.nil?
!!(version.to_s =~ ANCHORED_VERSION_PATTERN)
end
@@ -190,6 +188,8 @@ class Gem::Version
if self === input # check yourself before you wreck yourself
input
elsif input.nil?
+ nil_versions_are_discouraged!
+
nil
else
new input
@@ -206,6 +206,14 @@ class Gem::Version
@@all[version] ||= super
end
+ def self.nil_versions_are_discouraged!
+ unless Gem::Deprecate.skip
+ warn "nil versions are discouraged and will be deprecated in Rubygems 4"
+ end
+ end
+
+ private_class_method :nil_versions_are_discouraged!
+
##
# Constructs a Version from the +version+ string. A version string is a
# series of digits or ASCII letters separated by dots.
@@ -244,7 +252,7 @@ class Gem::Version
# same precision. Version "1.0" is not the same as version "1".
def eql?(other)
- self.class === other and @version == other._version
+ self.class === other && @version == other._version
end
def hash # :nodoc:
diff --git a/spec/bundler/bundler/ruby_version_spec.rb b/spec/bundler/bundler/ruby_version_spec.rb
index 3e3850031c..f1df12294d 100644
--- a/spec/bundler/bundler/ruby_version_spec.rb
+++ b/spec/bundler/bundler/ruby_version_spec.rb
@@ -427,9 +427,8 @@ RSpec.describe "Bundler::RubyVersion and its subclasses" do
end
describe "#version" do
- it "should return a copy of the value of RUBY_VERSION" do
- expect(subject.versions).to eq([RUBY_VERSION])
- expect(subject.versions.first).to_not be(RUBY_VERSION)
+ it "should return the value of Gem.ruby_version as a string" do
+ expect(subject.versions).to eq([Gem.ruby_version.to_s])
end
end
@@ -446,13 +445,12 @@ RSpec.describe "Bundler::RubyVersion and its subclasses" do
describe "#engine_version" do
context "engine is ruby" do
before do
- stub_const("RUBY_ENGINE_VERSION", "2.2.4")
+ allow(Gem).to receive(:ruby_version).and_return(Gem::Version.new("2.2.4"))
stub_const("RUBY_ENGINE", "ruby")
end
- it "should return a copy of the value of RUBY_ENGINE_VERSION" do
+ it "should return the value of Gem.ruby_version as a string" do
expect(bundler_system_ruby_version.engine_versions).to eq(["2.2.4"])
- expect(bundler_system_ruby_version.engine_versions.first).to_not be(RUBY_ENGINE_VERSION)
end
end
diff --git a/spec/bundler/commands/install_spec.rb b/spec/bundler/commands/install_spec.rb
index 49bd560703..7bf36ee020 100644
--- a/spec/bundler/commands/install_spec.rb
+++ b/spec/bundler/commands/install_spec.rb
@@ -522,14 +522,14 @@ RSpec.describe "bundle install with gem sources" do
ruby '~> 1.2'
source "#{file_uri_for(gem_repo1)}"
G
- expect(err).to include("Your Ruby version is #{RUBY_VERSION}, but your Gemfile specified ~> 1.2")
+ expect(err).to include("Your Ruby version is #{Gem.ruby_version}, but your Gemfile specified ~> 1.2")
end
end
context "and using a supported Ruby version" do
before do
install_gemfile <<-G
- ruby '~> #{RUBY_VERSION}'
+ ruby '~> #{Gem.ruby_version}'
source "#{file_uri_for(gem_repo1)}"
G
end
@@ -555,7 +555,7 @@ RSpec.describe "bundle install with gem sources" do
it "updates Gemfile.lock with updated yet still compatible ruby version" do
install_gemfile <<-G
- ruby '~> #{RUBY_VERSION[0..2]}'
+ ruby '~> #{current_ruby_minor}'
source "#{file_uri_for(gem_repo1)}"
G
@@ -913,7 +913,7 @@ RSpec.describe "bundle install with gem sources" do
gemfile <<-G
source "https://gem.repo4"
- ruby "#{RUBY_VERSION}"
+ ruby "#{Gem.ruby_version}"
gem "loofah", "~> 2.12.0"
G
@@ -1020,6 +1020,30 @@ RSpec.describe "bundle install with gem sources" do
end
end
+ context "with --prefer-local flag" do
+ before do
+ build_repo4 do
+ build_gem "foo", "1.0.1"
+ build_gem "foo", "1.0.0"
+ build_gem "bar", "1.0.0"
+ end
+
+ system_gems "foo-1.0.0", :path => default_bundle_path, :gem_repo => gem_repo4
+ end
+
+ it "fetches remote sources only when not available locally" do
+ install_gemfile <<-G, :"prefer-local" => true, :verbose => true
+ source "#{file_uri_for(gem_repo4)}"
+
+ gem "foo"
+ gem "bar"
+ G
+
+ expect(out).to include("Using foo 1.0.0").and include("Fetching bar 1.0.0").and include("Installing bar 1.0.0")
+ expect(last_command).to be_success
+ end
+ end
+
context "with a symlinked configured as bundle path and a gem with symlinks" do
before do
symlinked_bundled_app = tmp("bundled_app-symlink")
diff --git a/spec/bundler/commands/lock_spec.rb b/spec/bundler/commands/lock_spec.rb
index b20a6ded43..b314169a98 100644
--- a/spec/bundler/commands/lock_spec.rb
+++ b/spec/bundler/commands/lock_spec.rb
@@ -541,11 +541,9 @@ RSpec.describe "bundle lock" do
end
it "respects lower bound ruby requirements" do
- skip "this spec does not work with prereleases because their version is actually lower than their reported `RUBY_VERSION`" if RUBY_PATCHLEVEL == -1
-
build_repo4 do
build_gem "our_private_gem", "0.1.0" do |s|
- s.required_ruby_version = ">= #{RUBY_VERSION}"
+ s.required_ruby_version = ">= #{Gem.ruby_version}"
end
end
diff --git a/spec/bundler/commands/outdated_spec.rb b/spec/bundler/commands/outdated_spec.rb
index d0209022a2..e084af85d7 100644
--- a/spec/bundler/commands/outdated_spec.rb
+++ b/spec/bundler/commands/outdated_spec.rb
@@ -604,6 +604,22 @@ RSpec.describe "bundle outdated" do
expect(out).to end_with(expected_output)
end
+ it "only reports gems that have a newer version that matches the specified dependency version requirements, using --strict alias" do
+ update_repo2 do
+ build_gem "activesupport", "3.0"
+ build_gem "weakling", "0.0.5"
+ end
+
+ bundle :outdated, :strict => true, :raise_on_error => false
+
+ expected_output = <<~TABLE.strip
+ Gem Current Latest Requested Groups
+ weakling 0.0.3 0.0.5 ~> 0.0.1 default
+ TABLE
+
+ expect(out).to end_with(expected_output)
+ end
+
it "doesn't crash when some deps unused on the current platform" do
install_gemfile <<-G
source "#{file_uri_for(gem_repo2)}"
@@ -1098,116 +1114,125 @@ RSpec.describe "bundle outdated" do
end
context "conservative updates" do
- context "without --strict" do
- before do
- build_repo4 do
- build_gem "patch", %w[1.0.0 1.0.1]
- build_gem "minor", %w[1.0.0 1.0.1 1.1.0]
- build_gem "major", %w[1.0.0 1.0.1 1.1.0 2.0.0]
- end
+ before do
+ build_repo4 do
+ build_gem "patch", %w[1.0.0 1.0.1]
+ build_gem "minor", %w[1.0.0 1.0.1 1.1.0]
+ build_gem "major", %w[1.0.0 1.0.1 1.1.0 2.0.0]
+ end
- # establish a lockfile set to 1.0.0
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo4)}"
- gem 'patch', '1.0.0'
- gem 'minor', '1.0.0'
- gem 'major', '1.0.0'
- G
+ # establish a lockfile set to 1.0.0
+ install_gemfile <<-G
+ source "#{file_uri_for(gem_repo4)}"
+ gem 'patch', '1.0.0'
+ gem 'minor', '1.0.0'
+ gem 'major', '1.0.0'
+ G
- # remove 1.4.3 requirement and bar altogether
- # to setup update specs below
- gemfile <<-G
- source "#{file_uri_for(gem_repo4)}"
- gem 'patch'
- gem 'minor'
- gem 'major'
- G
- end
+ # remove all version requirements
+ gemfile <<-G
+ source "#{file_uri_for(gem_repo4)}"
+ gem 'patch'
+ gem 'minor'
+ gem 'major'
+ G
+ end
- it "shows nothing when patching and filtering to minor" do
- bundle "outdated --patch --filter-minor"
+ it "shows nothing when patching and filtering to minor" do
+ bundle "outdated --patch --filter-minor"
- expect(out).to end_with("No minor updates to display.")
- end
+ expect(out).to end_with("No minor updates to display.")
+ end
- it "shows all gems when patching and filtering to patch" do
- bundle "outdated --patch --filter-patch", :raise_on_error => false
+ it "shows all gems when patching and filtering to patch" do
+ bundle "outdated --patch --filter-patch", :raise_on_error => false
- expected_output = <<~TABLE.strip
- Gem Current Latest Requested Groups
- major 1.0.0 1.0.1 >= 0 default
- minor 1.0.0 1.0.1 >= 0 default
- patch 1.0.0 1.0.1 >= 0 default
- TABLE
+ expected_output = <<~TABLE.strip
+ Gem Current Latest Requested Groups
+ major 1.0.0 1.0.1 >= 0 default
+ minor 1.0.0 1.0.1 >= 0 default
+ patch 1.0.0 1.0.1 >= 0 default
+ TABLE
- expect(out).to end_with(expected_output)
- end
+ expect(out).to end_with(expected_output)
+ end
- it "shows minor and major when updating to minor and filtering to patch and minor" do
- bundle "outdated --minor --filter-minor", :raise_on_error => false
+ it "shows minor and major when updating to minor and filtering to patch and minor" do
+ bundle "outdated --minor --filter-minor", :raise_on_error => false
- expected_output = <<~TABLE.strip
- Gem Current Latest Requested Groups
- major 1.0.0 1.1.0 >= 0 default
- minor 1.0.0 1.1.0 >= 0 default
- TABLE
+ expected_output = <<~TABLE.strip
+ Gem Current Latest Requested Groups
+ major 1.0.0 1.1.0 >= 0 default
+ minor 1.0.0 1.1.0 >= 0 default
+ TABLE
- expect(out).to end_with(expected_output)
- end
+ expect(out).to end_with(expected_output)
+ end
- it "shows minor when updating to major and filtering to minor with parseable" do
- bundle "outdated --major --filter-minor --parseable", :raise_on_error => false
+ it "shows minor when updating to major and filtering to minor with parseable" do
+ bundle "outdated --major --filter-minor --parseable", :raise_on_error => false
- expect(out).not_to include("patch (newest")
- expect(out).to include("minor (newest")
- expect(out).not_to include("major (newest")
- end
+ expect(out).not_to include("patch (newest")
+ expect(out).to include("minor (newest")
+ expect(out).not_to include("major (newest")
end
+ end
- context "with --strict" do
- before do
- build_repo4 do
- build_gem "foo", %w[1.4.3 1.4.4] do |s|
- s.add_dependency "bar", "~> 2.0"
- end
- build_gem "foo", %w[1.4.5 1.5.0] do |s|
- s.add_dependency "bar", "~> 2.1"
- end
- build_gem "foo", %w[1.5.1] do |s|
- s.add_dependency "bar", "~> 3.0"
- end
- build_gem "bar", %w[2.0.3 2.0.4 2.0.5 2.1.0 2.1.1 3.0.0]
- build_gem "qux", %w[1.0.0 1.1.0 2.0.0]
+ context "tricky conservative updates" do
+ before do
+ build_repo4 do
+ build_gem "foo", %w[1.4.3 1.4.4] do |s|
+ s.add_dependency "bar", "~> 2.0"
+ end
+ build_gem "foo", %w[1.4.5 1.5.0] do |s|
+ s.add_dependency "bar", "~> 2.1"
end
+ build_gem "foo", %w[1.5.1] do |s|
+ s.add_dependency "bar", "~> 3.0"
+ end
+ build_gem "bar", %w[2.0.3 2.0.4 2.0.5 2.1.0 2.1.1 3.0.0]
+ build_gem "qux", %w[1.0.0 1.1.0 2.0.0]
+ end
- # establish a lockfile set to 1.4.3
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo4)}"
- gem 'foo', '1.4.3'
- gem 'bar', '2.0.3'
- gem 'qux', '1.0.0'
- G
+ # establish a lockfile set to 1.4.3
+ install_gemfile <<-G
+ source "#{file_uri_for(gem_repo4)}"
+ gem 'foo', '1.4.3'
+ gem 'bar', '2.0.3'
+ gem 'qux', '1.0.0'
+ G
- # remove 1.4.3 requirement and bar altogether
- # to setup update specs below
- gemfile <<-G
- source "#{file_uri_for(gem_repo4)}"
- gem 'foo'
- gem 'qux'
- G
- end
+ # remove 1.4.3 requirement and bar altogether
+ # to setup update specs below
+ gemfile <<-G
+ source "#{file_uri_for(gem_repo4)}"
+ gem 'foo'
+ gem 'qux'
+ G
+ end
- it "shows gems with --strict updating to patch and filtering to patch" do
- bundle "outdated --patch --strict --filter-patch", :raise_on_error => false
+ it "shows gems updating to patch and filtering to patch" do
+ bundle "outdated --patch --filter-patch", :raise_on_error => false, :env => { "DEBUG_RESOLVER" => "1" }
- expected_output = <<~TABLE.strip
- Gem Current Latest Requested Groups
- bar 2.0.3 2.0.5
- foo 1.4.3 1.4.4 >= 0 default
- TABLE
+ expected_output = <<~TABLE.strip
+ Gem Current Latest Requested Groups
+ bar 2.0.3 2.0.5
+ foo 1.4.3 1.4.4 >= 0 default
+ TABLE
- expect(out).to end_with(expected_output)
- end
+ expect(out).to end_with(expected_output)
+ end
+
+ it "shows gems updating to patch and filtering to patch, in debug mode" do
+ bundle "outdated --patch --filter-patch", :raise_on_error => false, :env => { "DEBUG" => "1" }
+
+ expected_output = <<~TABLE.strip
+ Gem Current Latest Requested Groups Path
+ bar 2.0.3 2.0.5
+ foo 1.4.3 1.4.4 >= 0 default
+ TABLE
+
+ expect(out).to end_with(expected_output)
end
end
diff --git a/spec/bundler/other/platform_spec.rb b/spec/bundler/commands/platform_spec.rb
index c157345cab..0b964eac8c 100644
--- a/spec/bundler/other/platform_spec.rb
+++ b/spec/bundler/commands/platform_spec.rb
@@ -19,7 +19,7 @@ Your app has gems that work on these platforms:
* #{specific_local_platform}
Your Gemfile specifies a Ruby version requirement:
-* ruby #{RUBY_VERSION}
+* ruby #{Gem.ruby_version}
Your current platform satisfies the Ruby version requirement.
G
@@ -42,7 +42,7 @@ Your app has gems that work on these platforms:
* #{specific_local_platform}
Your Gemfile specifies a Ruby version requirement:
-* ruby #{RUBY_VERSION}p#{RUBY_PATCHLEVEL}
+* #{Bundler::RubyVersion.system.single_version_string}
Your current platform satisfies the Ruby version requirement.
G
@@ -85,7 +85,7 @@ Your app has gems that work on these platforms:
Your Gemfile specifies a Ruby version requirement:
* ruby #{not_local_ruby_version}
-Your Ruby version is #{RUBY_VERSION}, but your Gemfile specified #{not_local_ruby_version}
+Your Ruby version is #{Gem.ruby_version}, but your Gemfile specified #{not_local_ruby_version}
G
end
end
@@ -231,7 +231,7 @@ G
L
bundle "platform --ruby"
- expect(out).to eq("ruby 1.0.0p127")
+ expect(out).to eq("ruby 1.0.0")
end
it "handles when there is a requirement in the gemfile" do
@@ -255,18 +255,18 @@ G
end
end
- let(:ruby_version_correct) { "ruby \"#{RUBY_VERSION}\", :engine => \"#{local_ruby_engine}\", :engine_version => \"#{local_engine_version}\"" }
- let(:ruby_version_correct_engineless) { "ruby \"#{RUBY_VERSION}\"" }
+ let(:ruby_version_correct) { "ruby \"#{Gem.ruby_version}\", :engine => \"#{local_ruby_engine}\", :engine_version => \"#{local_engine_version}\"" }
+ let(:ruby_version_correct_engineless) { "ruby \"#{Gem.ruby_version}\"" }
let(:ruby_version_correct_patchlevel) { "#{ruby_version_correct}, :patchlevel => '#{RUBY_PATCHLEVEL}'" }
let(:ruby_version_incorrect) { "ruby \"#{not_local_ruby_version}\", :engine => \"#{local_ruby_engine}\", :engine_version => \"#{not_local_ruby_version}\"" }
- let(:engine_incorrect) { "ruby \"#{RUBY_VERSION}\", :engine => \"#{not_local_tag}\", :engine_version => \"#{RUBY_VERSION}\"" }
- let(:engine_version_incorrect) { "ruby \"#{RUBY_VERSION}\", :engine => \"#{local_ruby_engine}\", :engine_version => \"#{not_local_engine_version}\"" }
+ let(:engine_incorrect) { "ruby \"#{Gem.ruby_version}\", :engine => \"#{not_local_tag}\", :engine_version => \"#{Gem.ruby_version}\"" }
+ let(:engine_version_incorrect) { "ruby \"#{Gem.ruby_version}\", :engine => \"#{local_ruby_engine}\", :engine_version => \"#{not_local_engine_version}\"" }
let(:patchlevel_incorrect) { "#{ruby_version_correct}, :patchlevel => '#{not_local_patchlevel}'" }
let(:patchlevel_fixnum) { "#{ruby_version_correct}, :patchlevel => #{RUBY_PATCHLEVEL}1" }
def should_be_ruby_version_incorrect
expect(exitstatus).to eq(18)
- expect(err).to be_include("Your Ruby version is #{RUBY_VERSION}, but your Gemfile specified #{not_local_ruby_version}")
+ expect(err).to be_include("Your Ruby version is #{Gem.ruby_version}, but your Gemfile specified #{not_local_ruby_version}")
end
def should_be_engine_incorrect
diff --git a/spec/bundler/commands/update_spec.rb b/spec/bundler/commands/update_spec.rb
index d45a565475..8ca537ac10 100644
--- a/spec/bundler/commands/update_spec.rb
+++ b/spec/bundler/commands/update_spec.rb
@@ -983,7 +983,7 @@ RSpec.describe "bundle update --ruby" do
context "when the Gemfile removes the ruby" do
before do
install_gemfile <<-G
- ruby '~> #{RUBY_VERSION}'
+ ruby '~> #{Gem.ruby_version}'
source "#{file_uri_for(gem_repo1)}"
G
@@ -1013,12 +1013,12 @@ RSpec.describe "bundle update --ruby" do
context "when the Gemfile specified an updated Ruby version" do
before do
install_gemfile <<-G
- ruby '~> #{RUBY_VERSION}'
+ ruby '~> #{Gem.ruby_version}'
source "#{file_uri_for(gem_repo1)}"
G
gemfile <<-G
- ruby '~> #{RUBY_VERSION[0..2]}'
+ ruby '~> #{current_ruby_minor}'
source "#{file_uri_for(gem_repo1)}"
G
end
@@ -1047,7 +1047,7 @@ RSpec.describe "bundle update --ruby" do
context "when a different Ruby is being used than has been versioned" do
before do
install_gemfile <<-G
- ruby '~> #{RUBY_VERSION}'
+ ruby '~> #{Gem.ruby_version}'
source "#{file_uri_for(gem_repo1)}"
G
@@ -1083,7 +1083,7 @@ RSpec.describe "bundle update --ruby" do
L
gemfile <<-G
- ruby '~> #{RUBY_VERSION}'
+ ruby '~> #{Gem.ruby_version}'
source "#{file_uri_for(gem_repo1)}"
G
end
diff --git a/spec/bundler/install/gemfile/ruby_spec.rb b/spec/bundler/install/gemfile/ruby_spec.rb
index ba250acfdd..39f09031b7 100644
--- a/spec/bundler/install/gemfile/ruby_spec.rb
+++ b/spec/bundler/install/gemfile/ruby_spec.rb
@@ -11,13 +11,13 @@ RSpec.describe "ruby requirement" do
it "allows adding gems" do
install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
- ruby "#{RUBY_VERSION}"
+ ruby "#{Gem.ruby_version}"
gem "rack"
G
install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
- ruby "#{RUBY_VERSION}"
+ ruby "#{Gem.ruby_version}"
gem "rack"
gem "rack-obama"
G
@@ -28,7 +28,7 @@ RSpec.describe "ruby requirement" do
it "allows removing the ruby version requirement" do
install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
- ruby "~> #{RUBY_VERSION}"
+ ruby "~> #{Gem.ruby_version}"
gem "rack"
G
@@ -46,7 +46,7 @@ RSpec.describe "ruby requirement" do
it "allows changing the ruby version requirement to something compatible" do
install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
- ruby ">= #{RUBY_VERSION[0..2]}.0"
+ ruby ">= #{current_ruby_minor}"
gem "rack"
G
@@ -55,7 +55,7 @@ RSpec.describe "ruby requirement" do
install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
- ruby ">= #{RUBY_VERSION}"
+ ruby ">= #{Gem.ruby_version}"
gem "rack"
G
@@ -93,7 +93,7 @@ RSpec.describe "ruby requirement" do
install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
- ruby ">= #{RUBY_VERSION[0..2]}.0"
+ ruby ">= #{current_ruby_minor}"
gem "rack"
G
@@ -104,7 +104,7 @@ RSpec.describe "ruby requirement" do
it "allows requirements with trailing whitespace" do
install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
- ruby "#{RUBY_VERSION}\\n \t\\n"
+ ruby "#{Gem.ruby_version}\\n \t\\n"
gem "rack"
G
diff --git a/spec/bundler/install/gemfile/specific_platform_spec.rb b/spec/bundler/install/gemfile/specific_platform_spec.rb
index 6994cb2af1..fe1c3b71fe 100644
--- a/spec/bundler/install/gemfile/specific_platform_spec.rb
+++ b/spec/bundler/install/gemfile/specific_platform_spec.rb
@@ -374,6 +374,112 @@ RSpec.describe "bundle install with specific platforms" do
ERROR
end
+ it "automatically fixes the lockfile if RUBY platform is locked and some gem has no RUBY variant available" do
+ build_repo4 do
+ build_gem("sorbet-static-and-runtime", "0.5.10160") do |s|
+ s.add_runtime_dependency "sorbet", "= 0.5.10160"
+ s.add_runtime_dependency "sorbet-runtime", "= 0.5.10160"
+ end
+
+ build_gem("sorbet", "0.5.10160") do |s|
+ s.add_runtime_dependency "sorbet-static", "= 0.5.10160"
+ end
+
+ build_gem("sorbet-runtime", "0.5.10160")
+
+ build_gem("sorbet-static", "0.5.10160") do |s|
+ s.platform = Gem::Platform.local
+ end
+ end
+
+ gemfile <<~G
+ source "#{file_uri_for(gem_repo4)}"
+
+ gem "sorbet-static-and-runtime"
+ G
+
+ lockfile <<~L
+ GEM
+ remote: #{file_uri_for(gem_repo4)}/
+ specs:
+ sorbet (0.5.10160)
+ sorbet-static (= 0.5.10160)
+ sorbet-runtime (0.5.10160)
+ sorbet-static (0.5.10160-#{Gem::Platform.local})
+ sorbet-static-and-runtime (0.5.10160)
+ sorbet (= 0.5.10160)
+ sorbet-runtime (= 0.5.10160)
+
+ PLATFORMS
+ #{lockfile_platforms_for([specific_local_platform, "ruby"])}
+
+ DEPENDENCIES
+ sorbet-static-and-runtime
+
+ BUNDLED WITH
+ #{Bundler::VERSION}
+ L
+
+ bundle "update"
+
+ expect(lockfile).to eq <<~L
+ GEM
+ remote: #{file_uri_for(gem_repo4)}/
+ specs:
+ sorbet (0.5.10160)
+ sorbet-static (= 0.5.10160)
+ sorbet-runtime (0.5.10160)
+ sorbet-static (0.5.10160-#{Gem::Platform.local})
+ sorbet-static-and-runtime (0.5.10160)
+ sorbet (= 0.5.10160)
+ sorbet-runtime (= 0.5.10160)
+
+ PLATFORMS
+ #{lockfile_platforms}
+
+ DEPENDENCIES
+ sorbet-static-and-runtime
+
+ BUNDLED WITH
+ #{Bundler::VERSION}
+ L
+ end
+
+ it "can fallback to a source gem when platform gems are incompatible with current ruby version" do
+ setup_multiplatform_gem_with_source_gem
+
+ source = file_uri_for(gem_repo2)
+
+ gemfile <<~G
+ source "#{source}"
+
+ gem "my-precompiled-gem"
+ G
+
+ # simulate lockfile which includes both a precompiled gem with:
+ # - Gem the current platform (with imcompatible ruby version)
+ # - A source gem with compatible ruby version
+ lockfile <<-L
+ GEM
+ remote: #{source}/
+ specs:
+ my-precompiled-gem (3.0.0)
+ my-precompiled-gem (3.0.0-#{Bundler.local_platform})
+
+ PLATFORMS
+ ruby
+ #{Bundler.local_platform}
+
+ DEPENDENCIES
+ my-precompiled-gem
+
+ BUNDLED WITH
+ #{Bundler::VERSION}
+ L
+
+ bundle :install
+ end
+
private
def setup_multiplatform_gem
@@ -404,4 +510,16 @@ RSpec.describe "bundle install with specific platforms" do
build_gem("CFPropertyList")
end
end
+
+ def setup_multiplatform_gem_with_source_gem
+ build_repo2 do
+ build_gem("my-precompiled-gem", "3.0.0")
+ build_gem("my-precompiled-gem", "3.0.0") do |s|
+ s.platform = Bundler.local_platform
+
+ # purposely unresolvable
+ s.required_ruby_version = ">= 1000.0.0"
+ end
+ end
+ end
end
diff --git a/spec/bundler/install/gems/resolving_spec.rb b/spec/bundler/install/gems/resolving_spec.rb
index b136dea8bd..9c0d6bfe56 100644
--- a/spec/bundler/install/gems/resolving_spec.rb
+++ b/spec/bundler/install/gems/resolving_spec.rb
@@ -211,12 +211,12 @@ RSpec.describe "bundle install with install-time dependencies" do
end
install_gemfile <<-G, :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo2.to_s }
- ruby "#{RUBY_VERSION}"
+ ruby "#{Gem.ruby_version}"
source "http://localgemserver.test/"
gem 'rack'
G
- expect(out).to_not include("rack-9001.0.0 requires ruby version > 9000")
+ expect(err).to_not include("rack-9001.0.0 requires ruby version > 9000")
expect(the_bundle).to include_gems("rack 1.2")
end
@@ -232,50 +232,77 @@ RSpec.describe "bundle install with install-time dependencies" do
end
install_gemfile <<-G, :artifice => "endpoint", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo2.to_s }
- ruby "#{RUBY_VERSION}"
+ ruby "#{Gem.ruby_version}"
source "http://localgemserver.test/"
gem 'rack'
G
- expect(out).to_not include("rack-9001.0.0 requires ruby version > 9000")
+ expect(err).to_not include("rack-9001.0.0 requires ruby version > 9000")
expect(the_bundle).to include_gems("rack 1.2")
end
- it "gives a meaningful error if there's a lockfile using the newer incompatible version" do
- build_repo2 do
- build_gem "parallel_tests", "3.7.0" do |s|
- s.required_ruby_version = ">= #{current_ruby_minor}"
- end
+ context "when there is a lockfile using the newer incompatible version" do
+ before do
+ build_repo2 do
+ build_gem "parallel_tests", "3.7.0" do |s|
+ s.required_ruby_version = ">= #{current_ruby_minor}"
+ end
- build_gem "parallel_tests", "3.8.0" do |s|
- s.required_ruby_version = ">= #{next_ruby_minor}"
+ build_gem "parallel_tests", "3.8.0" do |s|
+ s.required_ruby_version = ">= #{next_ruby_minor}"
+ end
end
+
+ gemfile <<-G
+ source "http://localgemserver.test/"
+ gem 'parallel_tests'
+ G
+
+ lockfile <<~L
+ GEM
+ remote: http://localgemserver.test/
+ specs:
+ parallel_tests (3.8.0)
+
+ PLATFORMS
+ #{lockfile_platforms}
+
+ DEPENDENCIES
+ parallel_tests
+
+ BUNDLED WITH
+ #{Bundler::VERSION}
+ L
end
- gemfile <<-G
- source "http://localgemserver.test/"
- gem 'parallel_tests'
- G
+ it "automatically updates lockfile to use the older version" do
+ bundle "install --verbose", :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo2.to_s }
+
+ expect(lockfile).to eq <<~L
+ GEM
+ remote: http://localgemserver.test/
+ specs:
+ parallel_tests (3.7.0)
- lockfile <<~L
- GEM
- remote: http://localgemserver.test/
- specs:
- parallel_tests (3.8.0)
+ PLATFORMS
+ #{lockfile_platforms}
- PLATFORMS
- #{lockfile_platforms}
+ DEPENDENCIES
+ parallel_tests
- DEPENDENCIES
- parallel_tests
+ BUNDLED WITH
+ #{Bundler::VERSION}
+ L
+ end
- BUNDLED WITH
- #{Bundler::VERSION}
- L
+ it "gives a meaningful error if we're in frozen mode" do
+ expect do
+ bundle "install --verbose", :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo2.to_s, "BUNDLE_FROZEN" => "true" }, :raise_on_error => false
+ end.not_to change { lockfile }
- bundle "install --verbose", :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo2.to_s }, :raise_on_error => false
- expect(err).to include("parallel_tests-3.8.0 requires ruby version >= #{next_ruby_minor}")
- expect(err).not_to include("That means the author of parallel_tests (3.8.0) has removed it.")
+ expect(err).to include("parallel_tests-3.8.0 requires ruby version >= #{next_ruby_minor}")
+ expect(err).not_to include("That means the author of parallel_tests (3.8.0) has removed it.")
+ end
end
it "gives a meaningful error on ruby version mismatches between dependencies" do
@@ -309,13 +336,13 @@ RSpec.describe "bundle install with install-time dependencies" do
end
install_gemfile <<-G, :artifice => "compact_index_rate_limited", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s }
- ruby "#{RUBY_VERSION}"
+ ruby "#{Gem.ruby_version}"
source "http://localgemserver.test/"
gem 'rack'
gem 'foo1'
G
- expect(out).to_not include("rack-9001.0.0 requires ruby version > 9000")
+ expect(err).to_not include("rack-9001.0.0 requires ruby version > 9000")
expect(the_bundle).to include_gems("rack 1.2")
end
@@ -333,14 +360,14 @@ RSpec.describe "bundle install with install-time dependencies" do
simulate_platform mingw do
install_gemfile <<-G, :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s }
- ruby "#{RUBY_VERSION}"
+ ruby "#{Gem.ruby_version}"
source "http://localgemserver.test/"
gem 'rack'
G
end
- expect(out).to_not include("rack-9001.0.0 requires ruby version > 9000")
- expect(out).to_not include("rack-1.2-#{Bundler.local_platform} requires ruby version > 9000")
+ expect(err).to_not include("rack-9001.0.0 requires ruby version > 9000")
+ expect(err).to_not include("rack-1.2-#{Bundler.local_platform} requires ruby version > 9000")
expect(the_bundle).to include_gems("rack 1.2")
end
end
@@ -354,8 +381,8 @@ RSpec.describe "bundle install with install-time dependencies" do
end
end
- let(:ruby_requirement) { %("#{RUBY_VERSION}") }
- let(:error_message_requirement) { "= #{RUBY_VERSION}" }
+ let(:ruby_requirement) { %("#{Gem.ruby_version}") }
+ let(:error_message_requirement) { "= #{Gem.ruby_version}" }
it "raises a proper error that mentions the current Ruby version during resolution" do
install_gemfile <<-G, :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo2.to_s }, :raise_on_error => false
diff --git a/spec/bundler/install/gems/standalone_spec.rb b/spec/bundler/install/gems/standalone_spec.rb
index a5302877c1..238006c02b 100644
--- a/spec/bundler/install/gems/standalone_spec.rb
+++ b/spec/bundler/install/gems/standalone_spec.rb
@@ -461,3 +461,31 @@ RSpec.describe "bundle install --standalone run in a subdirectory" do
include_examples("bundle install --standalone")
end
+
+RSpec.describe "bundle install --standalone --local" do
+ before do
+ gemfile <<-G
+ source "#{file_uri_for(gem_repo1)}"
+ gem "rack"
+ G
+
+ system_gems "rack-1.0.0", :path => default_bundle_path
+ end
+
+ it "generates script pointing to system gems" do
+ bundle "install --standalone --local --verbose"
+
+ expect(out).to include("Using rack 1.0.0")
+
+ load_error_ruby <<-RUBY, "spec"
+ require "./bundler/setup"
+
+ require "rack"
+ puts RACK
+ require "spec"
+ RUBY
+
+ expect(out).to eq("1.0.0")
+ expect(err).to eq("ZOMG LOAD ERROR")
+ end
+end
diff --git a/spec/bundler/install/gemspecs_spec.rb b/spec/bundler/install/gemspecs_spec.rb
index 3684d8749d..7b58ea9839 100644
--- a/spec/bundler/install/gemspecs_spec.rb
+++ b/spec/bundler/install/gemspecs_spec.rb
@@ -94,7 +94,8 @@ RSpec.describe "bundle install" do
end
context "when ruby version is specified in gemspec and gemfile" do
- it "installs when patch level is not specified and the version matches" do
+ it "installs when patch level is not specified and the version matches",
+ :if => RUBY_PATCHLEVEL >= 0 do
build_lib("foo", :path => bundled_app) do |s|
s.required_ruby_version = "~> #{RUBY_VERSION}.0"
end
diff --git a/spec/bundler/install/yanked_spec.rb b/spec/bundler/install/yanked_spec.rb
index 44fbb0bda3..09a5ba0be1 100644
--- a/spec/bundler/install/yanked_spec.rb
+++ b/spec/bundler/install/yanked_spec.rb
@@ -43,6 +43,63 @@ RSpec.context "when installing a bundle that includes yanked gems" do
end
end
+RSpec.context "when resolving a bundle that includes yanked gems, but unlocking an unrelated gem" do
+ before(:each) do
+ build_repo4 do
+ build_gem "foo", "10.0.0"
+
+ build_gem "bar", "1.0.0"
+ build_gem "bar", "2.0.0"
+ end
+
+ lockfile <<-L
+ GEM
+ remote: #{file_uri_for(gem_repo4)}
+ specs:
+ foo (9.0.0)
+ bar (1.0.0)
+
+ PLATFORMS
+ #{lockfile_platforms}
+
+ DEPENDENCIES
+ foo
+ bar
+
+ BUNDLED WITH
+ #{Bundler::VERSION}
+ L
+
+ gemfile <<-G
+ source "#{file_uri_for(gem_repo4)}"
+ gem "foo"
+ gem "bar"
+ G
+ end
+
+ it "does not update the yanked gem" do
+ bundle "lock --update bar"
+
+ expect(lockfile).to eq <<~L
+ GEM
+ remote: #{file_uri_for(gem_repo4)}/
+ specs:
+ bar (2.0.0)
+ foo (9.0.0)
+
+ PLATFORMS
+ #{lockfile_platforms}
+
+ DEPENDENCIES
+ bar
+ foo
+
+ BUNDLED WITH
+ #{Bundler::VERSION}
+ L
+ end
+end
+
RSpec.context "when using gem before installing" do
it "does not suggest the author has yanked the gem" do
gemfile <<-G
diff --git a/spec/bundler/lock/lockfile_spec.rb b/spec/bundler/lock/lockfile_spec.rb
index b21765ec4d..29f8863591 100644
--- a/spec/bundler/lock/lockfile_spec.rb
+++ b/spec/bundler/lock/lockfile_spec.rb
@@ -1174,7 +1174,7 @@ RSpec.describe "the lockfile format" do
it "captures the Ruby version in the lockfile" do
install_gemfile <<-G
source "#{file_uri_for(gem_repo2)}/"
- ruby '#{RUBY_VERSION}'
+ ruby '#{Gem.ruby_version}'
gem "rack", "> 0.9", "< 1.0"
G
@@ -1191,7 +1191,7 @@ RSpec.describe "the lockfile format" do
rack (> 0.9, < 1.0)
RUBY VERSION
- ruby #{RUBY_VERSION}p#{RUBY_PATCHLEVEL}
+ #{Bundler::RubyVersion.system}
BUNDLED WITH
#{Bundler::VERSION}
diff --git a/spec/bundler/resolver/basic_spec.rb b/spec/bundler/resolver/basic_spec.rb
index 7182d1e29c..ee62dc3577 100644
--- a/spec/bundler/resolver/basic_spec.rb
+++ b/spec/bundler/resolver/basic_spec.rb
@@ -233,7 +233,7 @@ Bundler could not find compatible versions for gem "a":
it "resolves foo only to latest patch - changing dependency declared case" do
# bar is locked AND a declared dependency in the Gemfile, so it will not move, and therefore
# foo can only move up to 1.4.4.
- @base << Bundler::LazySpecification.new("bar", "2.0.3", nil)
+ @base << build_spec("bar", "2.0.3").first
should_conservative_resolve_and_include :patch, ["foo"], %w[foo-1.4.4 bar-2.0.3]
end
diff --git a/spec/bundler/support/helpers.rb b/spec/bundler/support/helpers.rb
index 03c0df3b50..af6e338853 100644
--- a/spec/bundler/support/helpers.rb
+++ b/spec/bundler/support/helpers.rb
@@ -476,7 +476,7 @@ module Spec
end
def current_ruby_minor
- Gem.ruby_version.segments[0..1].join(".")
+ Gem.ruby_version.segments.tap {|s| s.delete_at(2) }.join(".")
end
def next_ruby_minor
diff --git a/spec/bundler/support/platforms.rb b/spec/bundler/support/platforms.rb
index 48479723e4..1ad7778403 100644
--- a/spec/bundler/support/platforms.rb
+++ b/spec/bundler/support/platforms.rb
@@ -71,7 +71,7 @@ module Spec
end
def local_engine_version
- RUBY_ENGINE_VERSION
+ RUBY_ENGINE == "ruby" ? Gem.ruby_version : RUBY_ENGINE_VERSION
end
def not_local_engine_version
diff --git a/test/rubygems/helper.rb b/test/rubygems/helper.rb
index dab3cd4d4c..df85a056c9 100644
--- a/test/rubygems/helper.rb
+++ b/test/rubygems/helper.rb
@@ -599,7 +599,7 @@ class Gem::TestCase < Test::Unit::TestCase
end
def in_path?(executable) # :nodoc:
- return true if %r{\A([A-Z]:|/)} =~ executable and File.exist? executable
+ return true if %r{\A([A-Z]:|/)} =~ executable && File.exist?(executable)
ENV["PATH"].split(File::PATH_SEPARATOR).any? do |directory|
File.exist? File.join directory, executable
@@ -849,7 +849,7 @@ class Gem::TestCase < Test::Unit::TestCase
# or a +block+ can be given for full customization of the specification.
def util_spec(name, version = 2, deps = nil, *files) # :yields: specification
- raise "deps or block, not both" if deps and block_given?
+ raise "deps or block, not both" if deps && block_given?
spec = Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
@@ -1279,10 +1279,10 @@ Also, a list:
rubyexe = "#{ruby}.exe"
3.times do
- if File.exist? ruby and File.executable? ruby and !File.directory? ruby
+ if File.exist?(ruby) && File.executable?(ruby) && !File.directory?(ruby)
return File.expand_path(ruby)
end
- if File.exist? rubyexe and File.executable? rubyexe
+ if File.exist?(rubyexe) && File.executable?(rubyexe)
return File.expand_path(rubyexe)
end
ruby = File.join("..", ruby)
@@ -1592,7 +1592,7 @@ class Object
metaclass = class << self; self; end
- if respond_to? name and not methods.map(&:to_s).include? name.to_s
+ if respond_to?(name) && !methods.map(&:to_s).include?(name.to_s)
metaclass.send :define_method, name do |*args|
super(*args)
end
diff --git a/test/rubygems/test_gem_config_file.rb b/test/rubygems/test_gem_config_file.rb
index fbc7c85757..e23773a133 100644
--- a/test/rubygems/test_gem_config_file.rb
+++ b/test/rubygems/test_gem_config_file.rb
@@ -35,7 +35,7 @@ class TestGemConfigFile < Gem::TestCase
def test_initialize
assert_equal @temp_conf, @cfg.config_file_name
- assert_equal false, @cfg.backtrace
+ assert_equal true, @cfg.backtrace
assert_equal true, @cfg.update_sources
assert_equal Gem::ConfigFile::DEFAULT_BULK_THRESHOLD, @cfg.bulk_threshold
assert_equal true, @cfg.verbose
@@ -239,6 +239,12 @@ if you believe they were disclosed to a third party.
end
def test_handle_arguments_backtrace
+ File.open @temp_conf, "w" do |fp|
+ fp.puts ":backtrace: false"
+ end
+
+ util_config_file %W[--config-file=#{@temp_conf}]
+
assert_equal false, @cfg.backtrace
args = %w[--backtrace]
@@ -275,6 +281,12 @@ if you believe they were disclosed to a third party.
end
def test_handle_arguments_traceback
+ File.open @temp_conf, "w" do |fp|
+ fp.puts ":backtrace: false"
+ end
+
+ util_config_file %W[--config-file=#{@temp_conf}]
+
assert_equal false, @cfg.backtrace
args = %w[--traceback]
@@ -288,7 +300,7 @@ if you believe they were disclosed to a third party.
assert_equal @temp_conf, @cfg.config_file_name
File.open @temp_conf, "w" do |fp|
- fp.puts ":backtrace: true"
+ fp.puts ":backtrace: false"
fp.puts ":update_sources: false"
fp.puts ":bulk_threshold: 10"
fp.puts ":verbose: false"
@@ -300,7 +312,7 @@ if you believe they were disclosed to a third party.
util_config_file args
- assert_equal false, @cfg.backtrace
+ assert_equal true, @cfg.backtrace
assert_equal true, @cfg.update_sources
assert_equal Gem::ConfigFile::DEFAULT_BULK_THRESHOLD, @cfg.bulk_threshold
assert_equal true, @cfg.verbose
@@ -386,7 +398,7 @@ if you believe they were disclosed to a third party.
end
def test_write
- @cfg.backtrace = true
+ @cfg.backtrace = false
@cfg.update_sources = false
@cfg.bulk_threshold = 10
@cfg.verbose = false
@@ -398,7 +410,7 @@ if you believe they were disclosed to a third party.
util_config_file
# These should not be written out to the config file.
- assert_equal false, @cfg.backtrace, "backtrace"
+ assert_equal true, @cfg.backtrace, "backtrace"
assert_equal Gem::ConfigFile::DEFAULT_BULK_THRESHOLD, @cfg.bulk_threshold,
"bulk_threshold"
assert_equal true, @cfg.update_sources, "update_sources"
diff --git a/test/rubygems/test_gem_dependency_installer.rb b/test/rubygems/test_gem_dependency_installer.rb
index 9db904ba53..2b0b874b2d 100644
--- a/test/rubygems/test_gem_dependency_installer.rb
+++ b/test/rubygems/test_gem_dependency_installer.rb
@@ -1051,8 +1051,8 @@ class TestGemDependencyInstaller < Gem::TestCase
releases = set.all_specs
- assert releases.any? {|s| s.name == "a" and s.version.to_s == "1" }
- refute releases.any? {|s| s.name == "a" and s.version.to_s == "1.a" }
+ assert releases.any? {|s| s.name == "a" && s.version.to_s == "1" }
+ refute releases.any? {|s| s.name == "a" && s.version.to_s == "1.a" }
dependency.prerelease = true
diff --git a/test/rubygems/test_gem_ext_cargo_builder/custom_name/Cargo.lock b/test/rubygems/test_gem_ext_cargo_builder/custom_name/Cargo.lock
index 498ee26c7e..da09e717f0 100644
--- a/test/rubygems/test_gem_ext_cargo_builder/custom_name/Cargo.lock
+++ b/test/rubygems/test_gem_ext_cargo_builder/custom_name/Cargo.lock
@@ -160,9 +160,9 @@ dependencies = [
[[package]]
name = "rb-sys"
-version = "0.9.26"
+version = "0.9.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "723f7560e878bec9d1d49538a17fb6a4e3a04688c1dc6f14eef17918634a54e4"
+checksum = "0317cb843cdeef14c5622917c55c0a170cee31348eb600c4a1683fb8c9e87e7a"
dependencies = [
"bindgen",
"linkify",
@@ -171,9 +171,9 @@ dependencies = [
[[package]]
name = "rb-sys-build"
-version = "0.9.26"
+version = "0.9.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2ccd93f0d9767385cd7a23076c47e3dca4c86144e510ea4c61d04dbce0cbac7e"
+checksum = "c4b8274327aecb7edcff86e290d9cbe7b572b7889c1cfc7476358f4831f78ce5"
dependencies = [
"regex",
"shell-words",
diff --git a/test/rubygems/test_gem_ext_cargo_builder/custom_name/Cargo.toml b/test/rubygems/test_gem_ext_cargo_builder/custom_name/Cargo.toml
index b144f930e5..2a215a55dd 100644
--- a/test/rubygems/test_gem_ext_cargo_builder/custom_name/Cargo.toml
+++ b/test/rubygems/test_gem_ext_cargo_builder/custom_name/Cargo.toml
@@ -7,4 +7,4 @@ edition = "2021"
crate-type = ["cdylib"]
[dependencies]
-rb-sys = { version = "0.9.26", features = ["gem"] }
+rb-sys = { version = "0.9.29", features = ["gem"] }
diff --git a/test/rubygems/test_gem_ext_cargo_builder/custom_name/build.rb b/test/rubygems/test_gem_ext_cargo_builder/custom_name/build.rb
index 21c4fd1c8d..0e04f0de5e 100644
--- a/test/rubygems/test_gem_ext_cargo_builder/custom_name/build.rb
+++ b/test/rubygems/test_gem_ext_cargo_builder/custom_name/build.rb
@@ -1,4 +1,4 @@
-if ENV["RUBYOPT"] or defined? Gem
+if ENV["RUBYOPT"] || defined? Gem
ENV.delete "RUBYOPT"
require "rbconfig"
diff --git a/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.lock b/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.lock
index 376d11cf3e..e351819848 100644
--- a/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.lock
+++ b/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.lock
@@ -153,9 +153,9 @@ dependencies = [
[[package]]
name = "rb-sys"
-version = "0.9.26"
+version = "0.9.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "723f7560e878bec9d1d49538a17fb6a4e3a04688c1dc6f14eef17918634a54e4"
+checksum = "0317cb843cdeef14c5622917c55c0a170cee31348eb600c4a1683fb8c9e87e7a"
dependencies = [
"bindgen",
"linkify",
@@ -164,9 +164,9 @@ dependencies = [
[[package]]
name = "rb-sys-build"
-version = "0.9.26"
+version = "0.9.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2ccd93f0d9767385cd7a23076c47e3dca4c86144e510ea4c61d04dbce0cbac7e"
+checksum = "c4b8274327aecb7edcff86e290d9cbe7b572b7889c1cfc7476358f4831f78ce5"
dependencies = [
"regex",
"shell-words",
diff --git a/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.toml b/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.toml
index 7d3cd133a8..1867db8e66 100644
--- a/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.toml
+++ b/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.toml
@@ -7,4 +7,4 @@ edition = "2021"
crate-type = ["cdylib"]
[dependencies]
-rb-sys = { version = "0.9.26", features = ["gem"] }
+rb-sys = { version = "0.9.29", features = ["gem"] }
diff --git a/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/build.rb b/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/build.rb
index 81b12f99ec..f404aa3468 100644
--- a/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/build.rb
+++ b/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/build.rb
@@ -1,4 +1,4 @@
-if ENV["RUBYOPT"] or defined? Gem
+if ENV["RUBYOPT"] || defined? Gem
ENV.delete "RUBYOPT"
require "rbconfig"
diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb
index 4600317578..3d02de13d5 100644
--- a/test/rubygems/test_gem_installer.rb
+++ b/test/rubygems/test_gem_installer.rb
@@ -473,7 +473,7 @@ gem 'other', version
end
end
ensure
- FileUtils.chmod 0755, util_inst_bindir unless ($DEBUG or win_platform?)
+ FileUtils.chmod 0755, util_inst_bindir unless ($DEBUG || win_platform?)
end
def test_generate_bin_script_no_shebang
@@ -577,7 +577,7 @@ gem 'other', version
end
end
ensure
- FileUtils.chmod 0755, util_inst_bindir unless ($DEBUG or win_platform?)
+ FileUtils.chmod 0755, util_inst_bindir unless ($DEBUG || win_platform?)
end
def test_generate_bin_symlink_update_newer
@@ -756,7 +756,10 @@ gem 'other', version
end
end
- assert_match %r{bin/ascii_binder` is dangling symlink pointing to `bin/asciibinder`}, @ui.error
+ errors = @ui.error.split("\n")
+ assert_equal "WARNING: ascii_binder-0.1.10.1 ships with a dangling symlink named bin/ascii_binder pointing to missing bin/asciibinder file. Ignoring", errors.shift
+ assert_empty errors
+
assert_empty @ui.output
end
diff --git a/test/rubygems/test_gem_package.rb b/test/rubygems/test_gem_package.rb
index 9e18dacba1..9295f42dba 100644
--- a/test/rubygems/test_gem_package.rb
+++ b/test/rubygems/test_gem_package.rb
@@ -529,6 +529,7 @@ class TestGemPackage < Gem::Package::TarTestCase
def test_extract_tar_gz_symlink_relative_path
package = Gem::Package.new @gem
+ package.verify
tgz_io = util_tar_gz do |tar|
tar.add_file "relative.rb", 0644 do |io|
@@ -557,6 +558,27 @@ class TestGemPackage < Gem::Package::TarTestCase
File.read(extracted)
end
+ def test_extract_tar_gz_symlink_broken_relative_path
+ package = Gem::Package.new @gem
+ package.verify
+
+ tgz_io = util_tar_gz do |tar|
+ tar.mkdir "lib", 0755
+ tar.add_symlink "lib/foo.rb", "../broken.rb", 0644
+ end
+
+ ui = Gem::MockGemUi.new
+
+ use_ui ui do
+ package.extract_tar_gz tgz_io, @destination
+ end
+
+ assert_equal "WARNING: a-2 ships with a dangling symlink named lib/foo.rb pointing to missing ../broken.rb file. Ignoring\n", ui.error
+
+ extracted = File.join @destination, "lib/foo.rb"
+ assert_path_not_exist extracted
+ end
+
def test_extract_symlink_parent
package = Gem::Package.new @gem
diff --git a/test/rubygems/test_gem_package_tar_reader.rb b/test/rubygems/test_gem_package_tar_reader.rb
index 86ffff4fe5..19860eb7e8 100644
--- a/test/rubygems/test_gem_package_tar_reader.rb
+++ b/test/rubygems/test_gem_package_tar_reader.rb
@@ -29,7 +29,7 @@ class TestGemPackageTarReader < Gem::Package::TarTestCase
str =
tar_file_header("lib/foo", "", 010644, content.size, Time.now) +
- content + "\0" * (512 - content.size)
+ content + "\0" * (512 - content.size)
str << "\0" * 1024
io = TempIO.new(str)
diff --git a/test/rubygems/test_gem_requirement.rb b/test/rubygems/test_gem_requirement.rb
index 37137dbdad..5ecdbeddae 100644
--- a/test/rubygems/test_gem_requirement.rb
+++ b/test/rubygems/test_gem_requirement.rb
@@ -129,7 +129,9 @@ class TestGemRequirement < Gem::TestCase
assert_satisfied_by "1.3", r
assert_raise ArgumentError do
- assert_satisfied_by nil, r
+ Gem::Deprecate.skip_during do
+ assert_satisfied_by nil, r
+ end
end
end
@@ -141,7 +143,9 @@ class TestGemRequirement < Gem::TestCase
refute_satisfied_by "1.3", r
assert_raise ArgumentError do
- assert_satisfied_by nil, r
+ Gem::Deprecate.skip_during do
+ assert_satisfied_by nil, r
+ end
end
end
@@ -153,7 +157,9 @@ class TestGemRequirement < Gem::TestCase
refute_satisfied_by "1.3", r
assert_raise ArgumentError do
- assert_satisfied_by nil, r
+ Gem::Deprecate.skip_during do
+ assert_satisfied_by nil, r
+ end
end
end
diff --git a/test/rubygems/test_gem_resolver_index_specification.rb b/test/rubygems/test_gem_resolver_index_specification.rb
index 339445cb44..b479757bd5 100644
--- a/test/rubygems/test_gem_resolver_index_specification.rb
+++ b/test/rubygems/test_gem_resolver_index_specification.rb
@@ -26,7 +26,7 @@ class TestGemResolverIndexSpecification < Gem::TestCase
spec = Gem::Resolver::IndexSpecification.new(
set, "rails", version, source, Gem::Platform.local)
- assert_equal Gem::Platform.local.to_s, spec.platform
+ assert_equal Gem::Platform.local, spec.platform
end
def test_install
diff --git a/test/rubygems/test_gem_resolver_installer_set.rb b/test/rubygems/test_gem_resolver_installer_set.rb
index 8d84c28172..7617919e2c 100644
--- a/test/rubygems/test_gem_resolver_installer_set.rb
+++ b/test/rubygems/test_gem_resolver_installer_set.rb
@@ -51,6 +51,38 @@ class TestGemResolverInstallerSet < Gem::TestCase
assert_equal %w[a-1], set.always_install.map {|s| s.full_name }
end
+ def test_add_always_install_platform_if_gem_platforms_modified_by_platform_flag
+ freebsd = Gem::Platform.new "x86-freebsd-9"
+
+ spec_fetcher do |fetcher|
+ fetcher.download "a", 1
+ fetcher.download "a", 1 do |s|
+ s.platform = freebsd
+ end
+ end
+
+ # equivalent to --platform=x86-freebsd-9
+ Gem.platforms << freebsd
+ set = Gem::Resolver::InstallerSet.new :both
+
+ set.add_always_install dep("a")
+
+ assert_equal %w[a-1-x86-freebsd-9], set.always_install.map {|s| s.full_name }
+ end
+
+ def test_add_always_install_index_spec_platform
+ _, a_1_local_gem = util_gem "a", 1 do |s|
+ s.platform = Gem::Platform.local
+ end
+
+ FileUtils.mv a_1_local_gem, @tempdir
+
+ set = Gem::Resolver::InstallerSet.new :both
+ set.add_always_install dep("a")
+
+ assert_equal [Gem::Platform.local], set.always_install.map {|s| s.platform }
+ end
+
def test_add_always_install_prerelease
spec_fetcher do |fetcher|
fetcher.gem "a", 1
@@ -187,6 +219,18 @@ class TestGemResolverInstallerSet < Gem::TestCase
set.find_all(req).map {|spec| spec.full_name }.sort
end
+ def test_find_all_prerelease_dependencies_with_add_local
+ activesupport_7_1_0_alpha = util_spec "activesupport", "7.1.0.alpha"
+
+ install_gem activesupport_7_1_0_alpha
+
+ set = Gem::Resolver::InstallerSet.new :both
+
+ req = Gem::Resolver::DependencyRequest.new dep("activesupport", ">= 4.2.0"), nil
+
+ assert_equal %w[activesupport-7.1.0.alpha], set.find_all(req).map {|spec| spec.full_name }
+ end
+
def test_load_spec
specs = spec_fetcher do |fetcher|
fetcher.spec "a", 2
diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb
index 0c67f600ea..3361b31173 100644
--- a/test/rubygems/test_gem_specification.rb
+++ b/test/rubygems/test_gem_specification.rb
@@ -796,7 +796,7 @@ dependencies: []
assert_equal File.join(@tempdir, "a-2.gemspec"), spec.loaded_from
end
- if RUBY_ENGINE == "ruby" and RUBY_VERSION < "2.7"
+ if RUBY_ENGINE == "ruby" && RUBY_VERSION < "2.7"
def test_self_load_tainted
full_path = @a2.spec_file
write_file full_path do |io|
@@ -1220,6 +1220,15 @@ dependencies: []
assert_equal "1.0.0.dev", spec.version.to_s
end
+ def test_initialize_nil_version
+ expected = "nil versions are discouraged and will be deprecated in Rubygems 4\n"
+ actual_stdout, actual_stderr = capture_output do
+ Gem::Specification.new.version = nil
+ end
+ assert_empty actual_stdout
+ assert_equal(expected, actual_stderr)
+ end
+
def test__dump
@a2.platform = Gem::Platform.local
@a2.instance_variable_set :@original_platform, "old_platform"
@@ -1441,7 +1450,7 @@ dependencies: []
@ext.build_extensions
assert_path_not_exist @ext.extension_dir
ensure
- unless ($DEBUG or win_platform? or Process.uid.zero? or Gem.java_platform?)
+ unless ($DEBUG || win_platform? || Process.uid.zero? || Gem.java_platform?)
FileUtils.chmod 0755, File.join(@ext.base_dir, "extensions")
FileUtils.chmod 0755, @ext.base_dir
end
diff --git a/test/rubygems/test_gem_version.rb b/test/rubygems/test_gem_version.rb
index e907eabb34..9237608d4a 100644
--- a/test/rubygems/test_gem_version.rb
+++ b/test/rubygems/test_gem_version.rb
@@ -32,8 +32,15 @@ class TestGemVersion < Gem::TestCase
def test_class_create
real = Gem::Version.new(1.0)
- assert_same real, Gem::Version.create(real)
- assert_nil Gem::Version.create(nil)
+ assert_same real, Gem::Version.create(real)
+
+ expected = "nil versions are discouraged and will be deprecated in Rubygems 4\n"
+ actual_stdout, actual_stderr = capture_output do
+ assert_nil Gem::Version.create(nil)
+ end
+ assert_empty actual_stdout
+ assert_equal(expected, actual_stderr)
+
assert_equal v("5.1"), Gem::Version.create("5.1")
ver = "1.1".freeze
diff --git a/test/rubygems/test_require.rb b/test/rubygems/test_require.rb
index f933bbb5d5..6135acea92 100644
--- a/test/rubygems/test_require.rb
+++ b/test/rubygems/test_require.rb
@@ -269,7 +269,7 @@ class TestGemRequire < Gem::TestCase
assert_includes $LOAD_PATH, rubylibdir
message = proc {
"this test relies on the b-2 gem lib/ to be before stdlib to make sense\n" +
- $LOAD_PATH.pretty_inspect
+ $LOAD_PATH.pretty_inspect
}
assert_operator $LOAD_PATH.index(b2.load_paths[0]), :<, $LOAD_PATH.index(rubylibdir), message
diff --git a/test/rubygems/utilities.rb b/test/rubygems/utilities.rb
index 5f8f763cb5..c01f7acd48 100644
--- a/test/rubygems/utilities.rb
+++ b/test/rubygems/utilities.rb
@@ -39,9 +39,9 @@ class Gem::FakeFetcher
end
def find_data(path)
- return Gem.read_binary path.path if URI === path and "file" == path.scheme
+ return Gem.read_binary path.path if URI === path && "file" == path.scheme
- if URI === path and "URI::#{path.scheme.upcase}" != path.class.name
+ if URI === path && "URI::#{path.scheme.upcase}" != path.class.name
raise ArgumentError,
"mismatch for scheme #{path.scheme} and class #{path.class}"
end
@@ -67,7 +67,7 @@ class Gem::FakeFetcher
if data.respond_to?(:call)
data.call
else
- if path.to_s.end_with?(".gz") and not data.nil? and not data.empty?
+ if path.to_s.end_with?(".gz") && !data.nil? && !data.empty?
data = Gem::Util.gunzip data
end
data
@@ -76,7 +76,7 @@ class Gem::FakeFetcher
def cache_update_path(uri, path = nil, update = true)
if data = fetch_path(uri)
- File.open(path, "wb") {|io| io.write data } if path and update
+ File.open(path, "wb") {|io| io.write data } if path && update
data
else
Gem.read_binary(path) if path
diff --git a/tool/bundler/dev_gems.rb.lock b/tool/bundler/dev_gems.rb.lock
index 3ff9af9b17..75d8faf683 100644
--- a/tool/bundler/dev_gems.rb.lock
+++ b/tool/bundler/dev_gems.rb.lock
@@ -53,4 +53,4 @@ DEPENDENCIES
webrick (~> 1.6)
BUNDLED WITH
- 2.3.19
+ 2.3.20
diff --git a/tool/bundler/rubocop_gems.rb.lock b/tool/bundler/rubocop_gems.rb.lock
index 4a36ab1f2a..02fdb0b24d 100644
--- a/tool/bundler/rubocop_gems.rb.lock
+++ b/tool/bundler/rubocop_gems.rb.lock
@@ -62,4 +62,4 @@ DEPENDENCIES
test-unit
BUNDLED WITH
- 2.3.19
+ 2.3.20
diff --git a/tool/bundler/standard_gems.rb.lock b/tool/bundler/standard_gems.rb.lock
index d39bbd1c5f..570bd99b4c 100644
--- a/tool/bundler/standard_gems.rb.lock
+++ b/tool/bundler/standard_gems.rb.lock
@@ -68,4 +68,4 @@ DEPENDENCIES
test-unit
BUNDLED WITH
- 2.3.19
+ 2.3.20
diff --git a/tool/bundler/test_gems.rb.lock b/tool/bundler/test_gems.rb.lock
index 2f25751c45..25602cabb2 100644
--- a/tool/bundler/test_gems.rb.lock
+++ b/tool/bundler/test_gems.rb.lock
@@ -43,4 +43,4 @@ DEPENDENCIES
webrick (= 1.7.0)
BUNDLED WITH
- 2.3.19
+ 2.3.20