summaryrefslogtreecommitdiff
path: root/lib/rubygems/basic_specification.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rubygems/basic_specification.rb')
-rw-r--r--lib/rubygems/basic_specification.rb72
1 files changed, 53 insertions, 19 deletions
diff --git a/lib/rubygems/basic_specification.rb b/lib/rubygems/basic_specification.rb
index 0380fceece..0ed7fc60bb 100644
--- a/lib/rubygems/basic_specification.rb
+++ b/lib/rubygems/basic_specification.rb
@@ -34,15 +34,6 @@ class Gem::BasicSpecification
internal_init
end
- def self.default_specifications_dir
- Gem.default_specifications_dir
- end
-
- class << self
- extend Gem::Deprecate
- rubygems_deprecate :default_specifications_dir, "Gem.default_specifications_dir"
- end
-
##
# The path to the gem.build_complete file within the extension install
# directory.
@@ -71,11 +62,7 @@ class Gem::BasicSpecification
# Return true if this spec can require +file+.
def contains_requirable_file?(file)
- if @ignored
- return false
- elsif missing_extensions?
- @ignored = true
-
+ if ignored?
if platform == Gem::Platform::RUBY || Gem::Platform.local === platform
warn "Ignoring #{full_name} because its extensions are not built. " \
"Try: gem pristine #{name} --version #{version}"
@@ -93,12 +80,35 @@ class Gem::BasicSpecification
end
end
+ ##
+ # Return true if this spec should be ignored because it's missing extensions.
+
+ def ignored?
+ return @ignored unless @ignored.nil?
+
+ @ignored = missing_extensions?
+ end
+
def default_gem?
- loaded_from &&
+ !loaded_from.nil? &&
File.dirname(loaded_from) == Gem.default_specifications_dir
end
##
+ # Regular gems take precedence over default gems
+
+ def default_gem_priority
+ default_gem? ? 1 : -1
+ end
+
+ ##
+ # Gems higher up in +gem_path+ take precedence
+
+ def base_dir_priority(gem_path)
+ gem_path.index(base_dir) || gem_path.size
+ end
+
+ ##
# Returns full path to the directory where gem's extensions are installed.
def extension_dir
@@ -115,7 +125,6 @@ class Gem::BasicSpecification
end
def find_full_gem_path # :nodoc:
- # TODO: also, shouldn't it default to full_name if it hasn't been written?
File.expand_path File.join(gems_dir, full_name)
end
@@ -123,10 +132,10 @@ class Gem::BasicSpecification
##
# The full path to the gem (install path + full name).
+ #
+ # TODO: This is duplicated with #gem_dir. Eventually either of them should be deprecated.
def full_gem_path
- # TODO: This is a heavily used method by gems, so we'll need
- # to aleast just alias it to #gem_dir rather than remove it.
@full_gem_path ||= find_full_gem_path
end
@@ -144,6 +153,19 @@ class Gem::BasicSpecification
end
##
+ # Returns the full name of this Gem (see `Gem::BasicSpecification#full_name`).
+ # Information about where the gem is installed is also included if not
+ # installed in the default GEM_HOME.
+
+ def full_name_with_location
+ if base_dir != Gem.dir
+ "#{full_name} in #{base_dir}"
+ else
+ full_name
+ end
+ end
+
+ ##
# Full paths in the gem to add to <code>$LOAD_PATH</code> when this gem is
# activated.
@@ -168,6 +190,9 @@ class Gem::BasicSpecification
File.expand_path(File.join(gems_dir, full_name, "data", name))
end
+ extend Gem::Deprecate
+ rubygems_deprecate :datadir, :none, "4.1"
+
##
# Full path of the target library file.
# If the file is not in this gem, return nil.
@@ -189,9 +214,11 @@ class Gem::BasicSpecification
##
# Returns the full path to this spec's gem directory.
# eg: /usr/local/lib/ruby/1.8/gems/mygem-1.0
+ #
+ # TODO: This is duplicated with #full_gem_path. Eventually either of them should be deprecated.
def gem_dir
- @gem_dir ||= File.expand_path File.join(gems_dir, full_name)
+ @gem_dir ||= find_full_gem_path
end
##
@@ -223,6 +250,13 @@ class Gem::BasicSpecification
raise NotImplementedError
end
+ def installable_on_platform?(target_platform) # :nodoc:
+ return true if [Gem::Platform::RUBY, nil, target_platform].include?(platform)
+ return true if Gem::Platform.new(platform) === target_platform
+
+ false
+ end
+
def raw_require_paths # :nodoc:
raise NotImplementedError
end