Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Merge #7145
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
bundlerbot and deivid-rodriguez committed Apr 28, 2019
2 parents 0d56002 + ab029ef commit 662fe29
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 86 deletions.
9 changes: 2 additions & 7 deletions bundler.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
36 changes: 1 addition & 35 deletions lib/bundler/rubygems_ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,7 @@ def loaded_from
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)
Expand Down Expand Up @@ -136,32 +128,6 @@ def to_lock
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
Expand Down
43 changes: 4 additions & 39 deletions lib/bundler/rubygems_integration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -213,16 +213,8 @@ def preserve_paths
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
Expand Down Expand Up @@ -463,25 +455,6 @@ def replace_entrypoints(specs)
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
Expand Down Expand Up @@ -652,16 +625,8 @@ module Ext
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)
Expand Down
4 changes: 1 addition & 3 deletions lib/bundler/shared_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,7 @@ def set_bundle_environment
#
# @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
Expand Down
2 changes: 0 additions & 2 deletions lib/bundler/stub_specification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ def full_require_paths
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
Expand Down

0 comments on commit 662fe29

Please sign in to comment.