Skip to content
Browse files

More or less finish the version_requirement -> requirement renaming.

  • Loading branch information...
1 parent c74de93 commit 068afbc8219f4e2796db27c25138e7294575e6cc @jbarnette jbarnette committed Nov 14, 2010
Showing with 56 additions and 38 deletions.
  1. +38 −20 lib/rubygems.rb
  2. +9 −9 lib/rubygems/source_index.rb
  3. +1 −1 test/test_kernel.rb
  4. +8 −8 util/gem_prelude.rb
View
58 lib/rubygems.rb
@@ -111,7 +111,25 @@ class LoadError < ::LoadError
attr_accessor :name
# Version requirement of gem
- attr_accessor :version_requirement
+ attr_accessor :requirement
+
+ def version_requirement
+ warn "#{Gem.location_of_caller.join ':'}:Warning: " \
+ "Gem::LoadError#version_requirement is deprecated " \
+ "and will be removed on or after January 2011. " \
+ "Use #requirement."
+
+ requirement
+ end
+
+ def version_requirement= requirement
+ warn "#{Gem.location_of_caller.join ':'}:Warning: " \
+ "Gem::LoadError#version_requirement= is deprecated " \
+ "and will be removed on or after January 2011. " \
+ "Use #requirement."
+
+ self.requirement = requirement
+ end
end
RbConfigPriorities = %w[
@@ -168,7 +186,7 @@ class LoadError < ::LoadError
##
# Activates an installed gem matching +gem+. The gem must satisfy
- # +version_requirements+.
+ # +requirements+.
#
# Returns true if the gem is activated, false if it is already
# loaded, or an exception otherwise.
@@ -182,22 +200,22 @@ class LoadError < ::LoadError
# More information on version requirements can be found in the
# Gem::Requirement and Gem::Version documentation.
- def self.activate(gem, *version_requirements)
- if version_requirements.last.is_a?(Hash)
- options = version_requirements.pop
+ def self.activate(gem, *requirements)
+ if requirements.last.is_a?(Hash)
+ options = requirements.pop
else
options = {}
end
sources = options[:sources] || []
- if version_requirements.empty? then
- version_requirements = Gem::Requirement.default
+ if requirements.empty? then
+ requirements = Gem::Requirement.default
end
unless gem.respond_to?(:name) and
gem.respond_to?(:requirement) then
- gem = Gem::Dependency.new(gem, version_requirements)
+ gem = Gem::Dependency.new(gem, requirements)
end
matches = Gem.source_index.find_name(gem.name, gem.requirement)
@@ -218,7 +236,7 @@ def self.activate(gem, *version_requirements)
e = Gem::LoadError.new msg
e.name = gem.name
- e.version_requirement = gem.requirement
+ e.requirement = gem.requirement
raise e
end
@@ -302,23 +320,23 @@ def self.available?(gem, *requirements)
##
# Find the full path to the executable for gem +name+. If the +exec_name+
# is not given, the gem's default_executable is chosen, otherwise the
- # specified executable's path is returned. +version_requirements+ allows
+ # specified executable's path is returned. +requirements+ allows
# you to specify specific gem versions.
- def self.bin_path(name, exec_name = nil, *version_requirements)
- version_requirements = Gem::Requirement.default if
- version_requirements.empty?
- specs = Gem.source_index.find_name(name, version_requirements)
+ def self.bin_path(name, exec_name = nil, *requirements)
+ requirements = Gem::Requirement.default if
+ requirements.empty?
+ specs = Gem.source_index.find_name(name, requirements)
raise Gem::GemNotFoundException,
- "can't find gem #{name} (#{version_requirements})" if specs.empty?
+ "can't find gem #{name} (#{requirements})" if specs.empty?
specs = specs.find_all do |spec|
spec.executables.include?(exec_name)
end if exec_name
unless spec = specs.last
- msg = "can't find gem #{name} (#{version_requirements}) with executable #{exec_name}"
+ msg = "can't find gem #{name} (#{requirements}) with executable #{exec_name}"
raise Gem::GemNotFoundException, msg
end
@@ -775,7 +793,7 @@ def self.report_activate_error(gem)
end
error.name = gem.name
- error.version_requirement = gem.requirement
+ error.requirement = gem.requirement
raise error
end
@@ -1084,7 +1102,7 @@ module Kernel
##
# Use Kernel#gem to activate a specific version of +gem_name+.
#
- # +version_requirements+ is a list of version requirements that the
+ # +requirements+ is a list of version requirements that the
# specified gem must match, most commonly "= example.version.number". See
# Gem::Requirement for how to specify a version requirement.
#
@@ -1107,10 +1125,10 @@ module Kernel
#
# GEM_SKIP=libA:libB ruby -I../libA -I../libB ./mycode.rb
- def gem(gem_name, *version_requirements) # :doc:
+ def gem(gem_name, *requirements) # :doc:
skip_list = (ENV['GEM_SKIP'] || "").split(/:/)
raise Gem::LoadError, "skipping #{gem_name}" if skip_list.include? gem_name
- Gem.activate(gem_name, *version_requirements)
+ Gem.activate(gem_name, *requirements)
end
private :gem
View
18 lib/rubygems/source_index.rb
@@ -269,8 +269,8 @@ def size
##
# Find a gem by an exact match on the short name.
- def find_name(gem_name, version_requirement = Gem::Requirement.default)
- dep = Gem::Dependency.new gem_name, version_requirement
+ def find_name(gem_name, requirement = Gem::Requirement.default)
+ dep = Gem::Dependency.new gem_name, requirement
search dep
end
@@ -284,7 +284,7 @@ def find_name(gem_name, version_requirement = Gem::Requirement.default)
# behavior is deprecated and will be removed.
def search(gem_pattern, platform_only = false)
- version_requirement = nil
+ requirement = nil
only_platform = false
# TODO - Remove support and warning for legacy arguments after 2008/11
@@ -294,10 +294,10 @@ def search(gem_pattern, platform_only = false)
case gem_pattern
when Regexp then
- version_requirement = platform_only || Gem::Requirement.default
+ requirement = platform_only || Gem::Requirement.default
when Gem::Dependency then
only_platform = platform_only
- version_requirement = gem_pattern.requirement
+ requirement = gem_pattern.requirement
gem_pattern = if Regexp === gem_pattern.name then
gem_pattern.name
elsif gem_pattern.name.empty? then
@@ -306,17 +306,17 @@ def search(gem_pattern, platform_only = false)
/^#{Regexp.escape gem_pattern.name}$/
end
else
- version_requirement = platform_only || Gem::Requirement.default
+ requirement = platform_only || Gem::Requirement.default
gem_pattern = /#{gem_pattern}/i
end
- unless Gem::Requirement === version_requirement then
- version_requirement = Gem::Requirement.create version_requirement
+ unless Gem::Requirement === requirement then
+ requirement = Gem::Requirement.create requirement
end
specs = all_gems.values.select do |spec|
spec.name =~ gem_pattern and
- version_requirement.satisfied_by? spec.version
+ requirement.satisfied_by? spec.version
end
if only_platform then
View
2 test/test_kernel.rb
@@ -47,7 +47,7 @@ def test_gem_conflicting
assert_match(/activate a \(= 2, runtime\)/, ex.message)
assert_match(/activated a-1/, ex.message)
assert_equal 'a', ex.name
- assert_equal Gem::Requirement.new('= 2'), ex.version_requirement
+ assert_equal Gem::Requirement.new('= 2'), ex.requirement
assert $:.any? { |p| %r{a-1/lib} =~ p }
assert $:.any? { |p| %r{a-1/bin} =~ p }
View
16 util/gem_prelude.rb
@@ -12,8 +12,8 @@
module Kernel
- def gem(gem_name, *version_requirements)
- Gem.push_gem_version_on_load_path(gem_name, *version_requirements)
+ def gem(gem_name, *requirements)
+ Gem.push_gem_version_on_load_path(gem_name, *requirements)
end
private :gem
end
@@ -184,21 +184,21 @@ def self.path_to_full_rubygems_library
GemPaths = {}
GemVersions = {}
- def push_gem_version_on_load_path(gem_name, *version_requirements)
- if version_requirements.empty?
+ def push_gem_version_on_load_path(gem_name, *requirements)
+ if requirements.empty?
unless GemPaths.has_key?(gem_name) then
raise Gem::LoadError, "Could not find RubyGem #{gem_name} (>= 0)\n"
end
# highest version gems already active
return false
else
- if version_requirements.length > 1 then
+ if requirements.length > 1 then
QuickLoader.load_full_rubygems_library
- return gem(gem_name, *version_requirements)
+ return gem(gem_name, *requirements)
end
- requirement, version = version_requirements[0].split
+ requirement, version = requirements[0].split
requirement.strip!
if loaded_version = GemVersions[gem_name] then
@@ -214,7 +214,7 @@ def push_gem_version_on_load_path(gem_name, *version_requirements)
end
QuickLoader.load_full_rubygems_library
- gem gem_name, *version_requirements
+ gem gem_name, *requirements
end
end

0 comments on commit 068afbc

Please sign in to comment.
Something went wrong with that request. Please try again.