summaryrefslogtreecommitdiff
path: root/lib/rubygems/basic_specification.rb
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-12-07 00:53:01 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-12-07 00:53:01 +0000
commit97f80207d0f0d13f28a419d8c92e96bb9064096a (patch)
treede416fff9bbc978434cb4c1185099151df2ac27c /lib/rubygems/basic_specification.rb
parenta0b80a44101708b5d66cdd87f16c98277954a77c (diff)
* lib/rubygems: Update to RubyGems 2.4.5.
* test/rubygems: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48729 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/basic_specification.rb')
-rw-r--r--lib/rubygems/basic_specification.rb74
1 files changed, 52 insertions, 22 deletions
diff --git a/lib/rubygems/basic_specification.rb b/lib/rubygems/basic_specification.rb
index f9eb193fb4..f5fb0f5d97 100644
--- a/lib/rubygems/basic_specification.rb
+++ b/lib/rubygems/basic_specification.rb
@@ -58,23 +58,28 @@ class Gem::BasicSpecification
# Return true if this spec can require +file+.
def contains_requirable_file? file
- if instance_variable_defined?(:@ignored) or
- instance_variable_defined?('@ignored') then
- return false
- elsif missing_extensions? then
- @ignored = true
-
- warn "Ignoring #{full_name} because its extensions are not built. " +
- "Try: gem pristine #{full_name}"
- return false
- end
-
- suffixes = Gem.suffixes
-
- full_require_paths.any? do |dir|
- base = "#{dir}/#{file}"
- suffixes.any? { |suf| File.file? "#{base}#{suf}" }
- end
+ @contains_requirable_file ||= {}
+ @contains_requirable_file[file] ||=
+ begin
+ if instance_variable_defined?(:@ignored) or
+ instance_variable_defined?('@ignored') then
+ return false
+ elsif missing_extensions? then
+ @ignored = true
+
+ warn "Ignoring #{full_name} because its extensions are not built. " +
+ "Try: gem pristine #{name} --version #{version}"
+ return false
+ end
+
+ suffixes = Gem.suffixes
+
+ full_require_paths.any? do |dir|
+ base = "#{dir}/#{file}"
+ suffixes.any? { |suf| File.file? "#{base}#{suf}" }
+ end
+ end ? :yes : :no
+ @contains_requirable_file[file] == :yes
end
def default_gem?
@@ -134,13 +139,38 @@ class Gem::BasicSpecification
# activated.
def full_require_paths
- full_paths = raw_require_paths.map do |path|
- File.join full_gem_path, path
- end
+ @full_require_paths ||=
+ begin
+ full_paths = raw_require_paths.map do |path|
+ File.join full_gem_path, path
+ end
- full_paths.unshift extension_dir unless @extensions.nil? || @extensions.empty?
+ full_paths.unshift extension_dir unless @extensions.nil? || @extensions.empty?
- full_paths
+ full_paths
+ end
+ end
+
+ ##
+ # Full path of the target library file.
+ # If the file is not in this gem, return nil.
+
+ def to_fullpath path
+ if activated? then
+ @paths_map ||= {}
+ @paths_map[path] ||=
+ begin
+ fullpath = nil
+ suffixes = Gem.suffixes
+ full_require_paths.find do |dir|
+ suffixes.find do |suf|
+ File.file?(fullpath = "#{dir}/#{path}#{suf}")
+ end
+ end ? fullpath : nil
+ end
+ else
+ nil
+ end
end
##