summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBundlerbot <bot@bundler.io>2019-04-28 09:34:17 +0000
committerBundlerbot <bot@bundler.io>2019-04-28 09:34:17 +0000
commit662fe29107bf0dafd55be661a4471f4b7afd73f6 (patch)
treeca2383e0059cb289edbbde7d6f74357a3314ae45
parent0d56002c0673da24140bffbfd5f22df619b8a7b8 (diff)
parentab029eff517ddc40f79bd0bb2ec994899c1f724c (diff)
downloadbundler-662fe29107bf0dafd55be661a4471f4b7afd73f6.tar.gz
Merge #7145
7145: More compatibility cleanup r=hsbt a=deivid-rodriguez ### What was the end-user problem that led to this PR? The problem was we still have unnecessary code for compatiblity with rubygems versions we no longer support. ### What was your diagnosis of the problem? My diagnosis was that we can remove this code. ### What is your fix for the problem, implemented in this PR? My fix is to remove it. Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net>
-rw-r--r--bundler.gemspec9
-rw-r--r--lib/bundler/rubygems_ext.rb36
-rw-r--r--lib/bundler/rubygems_integration.rb43
-rw-r--r--lib/bundler/shared_helpers.rb4
-rw-r--r--lib/bundler/stub_specification.rb2
5 files changed, 8 insertions, 86 deletions
diff --git a/bundler.gemspec b/bundler.gemspec
index 7ebecb6f6f..bcc1027a40 100644
--- a/bundler.gemspec
+++ b/bundler.gemspec
@@ -31,13 +31,8 @@ Gem::Specification.new do |s|
}
end
- if s.version >= Gem::Version.new("2.a".dup)
- s.required_ruby_version = ">= 2.3.0"
- s.required_rubygems_version = ">= 2.5.0"
- else
- s.required_ruby_version = ">= 1.8.7"
- s.required_rubygems_version = ">= 1.3.6"
- end
+ s.required_ruby_version = ">= 2.3.0"
+ s.required_rubygems_version = ">= 2.5.0"
s.add_development_dependency "automatiek", "~> 0.1.0"
s.add_development_dependency "rake", "~> 12.0"
diff --git a/lib/bundler/rubygems_ext.rb b/lib/bundler/rubygems_ext.rb
index df8646a2bb..96b93836c7 100644
--- a/lib/bundler/rubygems_ext.rb
+++ b/lib/bundler/rubygems_ext.rb
@@ -44,15 +44,7 @@ module Gem
end
def load_paths
- return full_require_paths if respond_to?(:full_require_paths)
-
- require_paths.map do |require_path|
- if require_path.include?(full_gem_path)
- require_path
- else
- File.join(full_gem_path, require_path)
- end
- end
+ full_require_paths
end
if method_defined?(:extension_dir)
@@ -136,32 +128,6 @@ module Gem
end
out
end
-
- # Backport of performance enhancement added to RubyGems 1.4
- def matches_spec?(spec)
- # name can be a Regexp, so use ===
- return false unless name === spec.name
- return true if requirement.none?
-
- requirement.satisfied_by?(spec.version)
- end unless allocate.respond_to?(:matches_spec?)
- end
-
- class Requirement
- # Backport of performance enhancement added to RubyGems 1.4
- def none?
- # note that it might be tempting to replace with with RubyGems 2.0's
- # improved implementation. Don't. It requires `DefaultRequirement` to be
- # defined, and more importantantly, these overrides are not used when the
- # running RubyGems defines these methods
- to_s == ">= 0"
- end unless allocate.respond_to?(:none?)
-
- # Backport of performance enhancement added to RubyGems 2.2
- def exact?
- return false unless @requirements.size == 1
- @requirements[0][0] == "="
- end unless allocate.respond_to?(:exact?)
end
class Platform
diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb
index 81bac3540e..ae1c1943e5 100644
--- a/lib/bundler/rubygems_integration.rb
+++ b/lib/bundler/rubygems_integration.rb
@@ -213,16 +213,8 @@ module Bundler
end
def loaded_gem_paths
- # RubyGems 2.2+ can put binary extension into dedicated folders,
- # therefore use RubyGems facilities to obtain their load paths.
- if Gem::Specification.method_defined? :full_require_paths
- loaded_gem_paths = Gem.loaded_specs.map {|_, s| s.full_require_paths }
- loaded_gem_paths.flatten
- else
- $LOAD_PATH.select do |p|
- Bundler.rubygems.gem_path.any? {|gp| p =~ /^#{Regexp.escape(gp)}/ }
- end
- end
+ loaded_gem_paths = Gem.loaded_specs.map {|_, s| s.full_require_paths }
+ loaded_gem_paths.flatten
end
def load_plugins
@@ -463,25 +455,6 @@ module Bundler
Gem.clear_paths
end
- # This backports the correct segment generation code from RubyGems 1.4+
- # by monkeypatching it into the method in RubyGems 1.3.6 and 1.3.7.
- def backport_segment_generation
- redefine_method(Gem::Version, :segments) do
- @segments ||= @version.scan(/[0-9]+|[a-z]+/i).map do |s|
- /^\d+$/ =~ s ? s.to_i : s
- end
- end
- end
-
- # This backport fixes the marshaling of @segments.
- def backport_yaml_initialize
- redefine_method(Gem::Version, :yaml_initialize) do |_, map|
- @version = map["version"]
- @segments = nil
- @hash = nil
- end
- end
-
# This backports base_dir which replaces installation path
# RubyGems 1.8+
def backport_base_dir
@@ -652,16 +625,8 @@ module Bundler
end
end
- if Gem::Specification.respond_to?(:stubs_for)
- def find_name(name)
- Gem::Specification.stubs_for(name).map(&:to_spec)
- end
- else
- def find_name(name)
- Gem::Specification.stubs.find_all do |spec|
- spec.name == name
- end.map(&:to_spec)
- end
+ def find_name(name)
+ Gem::Specification.stubs_for(name).map(&:to_spec)
end
if Gem::Specification.respond_to?(:default_stubs)
diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb
index 73c6dc3097..a0982f561f 100644
--- a/lib/bundler/shared_helpers.rb
+++ b/lib/bundler/shared_helpers.rb
@@ -103,9 +103,7 @@ module Bundler
#
# @see {Bundler::PermissionError}
def filesystem_access(path, action = :write, &block)
- # Use block.call instead of yield because of a bug in Ruby 2.2.2
- # See https://github.com/bundler/bundler/issues/5341 for details
- block.call(path.dup.untaint)
+ yield(path.dup.untaint)
rescue Errno::EACCES
raise PermissionError.new(path, action)
rescue Errno::EAGAIN
diff --git a/lib/bundler/stub_specification.rb b/lib/bundler/stub_specification.rb
index 64b6d1b724..bad69c9a14 100644
--- a/lib/bundler/stub_specification.rb
+++ b/lib/bundler/stub_specification.rb
@@ -55,8 +55,6 @@ module Bundler
stub.full_require_paths
end
- # This is what we do in bundler/rubygems_ext
- # full_require_paths is always implemented
def load_paths
full_require_paths
end