aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bundler/rubygems_ext.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bundler/rubygems_ext.rb')
-rw-r--r--lib/bundler/rubygems_ext.rb67
1 files changed, 9 insertions, 58 deletions
diff --git a/lib/bundler/rubygems_ext.rb b/lib/bundler/rubygems_ext.rb
index ccf71c8c00..96b93836c7 100644
--- a/lib/bundler/rubygems_ext.rb
+++ b/lib/bundler/rubygems_ext.rb
@@ -4,40 +4,25 @@ require "pathname"
require "rubygems/specification"
-begin
- # Possible use in Gem::Specification#source below and require
- # shouldn't be deferred.
- require "rubygems/source"
-rescue LoadError
- # Not available before RubyGems 2.0.0, ignore
- nil
-end
+# Possible use in Gem::Specification#source below and require
+# shouldn't be deferred.
+require "rubygems/source"
-require "bundler/match_platform"
+require_relative "match_platform"
module Gem
- @loaded_stacks = Hash.new {|h, k| h[k] = [] }
-
class Specification
attr_accessor :remote, :location, :relative_loaded_from
- if instance_methods(false).include?(:source)
- remove_method :source
- attr_writer :source
- def source
- (defined?(@source) && @source) || Gem::Source::Installed.new
- end
- else
- # rubocop:disable Lint/DuplicateMethods
- attr_accessor :source
- # rubocop:enable Lint/DuplicateMethods
+ remove_method :source
+ attr_writer :source
+ def source
+ (defined?(@source) && @source) || Gem::Source::Installed.new
end
alias_method :rg_full_gem_path, :full_gem_path
alias_method :rg_loaded_from, :loaded_from
- attr_writer :full_gem_path unless instance_methods.include?(:full_gem_path=)
-
def full_gem_path
# this cannot check source.is_a?(Bundler::Plugin::API::Source)
# because that _could_ trip the autoload, and if there are unresolved
@@ -59,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)
@@ -151,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