summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-10-17 02:08:53 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-10-17 02:08:53 +0000
commita35798450864ee9515e1742627fb592a40c0c44a (patch)
tree0692694d9abf1c1d4832a984a8f8a2b708b1874a /lib
parent6944271c0d18336376f63b3dda442a18202a4c1b (diff)
* lib/rubygems: Update to RubyGems master 941c21a. Changes:
Restored method bundler wants to remove for compatibility. Improvements to Gemfile compatibility. * test/rubygems: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43323 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/rubygems/exceptions.rb6
-rw-r--r--lib/rubygems/request_set.rb2
-rw-r--r--lib/rubygems/request_set/gem_dependency_api.rb98
-rw-r--r--lib/rubygems/specification.rb7
4 files changed, 104 insertions, 9 deletions
diff --git a/lib/rubygems/exceptions.rb b/lib/rubygems/exceptions.rb
index 4a988f9edf..9aef89956e 100644
--- a/lib/rubygems/exceptions.rb
+++ b/lib/rubygems/exceptions.rb
@@ -154,6 +154,12 @@ class Gem::RemoteInstallationSkipped < Gem::Exception; end
# Represents an error communicating via HTTP.
class Gem::RemoteSourceException < Gem::Exception; end
+##
+# Raised when a gem dependencies file specifies a ruby version that does not
+# match the current version.
+
+class Gem::RubyVersionMismatch < Gem::Exception; end
+
class Gem::VerificationError < Gem::Exception; end
##
diff --git a/lib/rubygems/request_set.rb b/lib/rubygems/request_set.rb
index 3ff3e83ca6..0d52423f8f 100644
--- a/lib/rubygems/request_set.rb
+++ b/lib/rubygems/request_set.rb
@@ -143,7 +143,7 @@ class Gem::RequestSet
# Load a dependency management file.
def load_gemdeps path
- gf = Gem::RequestSet::GemDepedencyAPI.new self, path
+ gf = Gem::RequestSet::GemDependencyAPI.new self, path
gf.load
end
diff --git a/lib/rubygems/request_set/gem_dependency_api.rb b/lib/rubygems/request_set/gem_dependency_api.rb
index 178ed1b59d..435e157861 100644
--- a/lib/rubygems/request_set/gem_dependency_api.rb
+++ b/lib/rubygems/request_set/gem_dependency_api.rb
@@ -1,39 +1,121 @@
##
-# A semi-compatible DSL for Bundler's Gemfile format
+# A semi-compatible DSL for the Bundler Gemfile and Isolate formats.
-class Gem::RequestSet::GemDepedencyAPI
+class Gem::RequestSet::GemDependencyAPI
+
+ ##
+ # The dependency groups created by #group in the dependency API file.
+
+ attr_reader :dependency_groups
+
+ ##
+ # Creates a new GemDependencyAPI that will add dependencies to the
+ # Gem::RequestSet +set+ based on the dependency API description in +path+.
def initialize set, path
@set = set
@path = path
+
+ @current_groups = nil
+ @dependency_groups = Hash.new { |h, group| h[group] = [] }
end
+ ##
+ # Loads the gem dependency file
+
def load
instance_eval File.read(@path).untaint, @path, 1
end
- # :category: Bundler Gemfile DSL
+ ##
+ # :category: Gem Dependencies DSL
+ # :call-seq:
+ # gem(name)
+ # gem(name, *requirements)
+ # gem(name, *requirements, options)
+ #
+ # Specifies a gem dependency with the given +name+ and +requirements+. You
+ # may also supply +options+ following the +requirements+
+
+ def gem name, *requirements
+ options = requirements.pop if requirements.last.kind_of?(Hash)
+ options ||= {}
+
+ groups =
+ (group = options.delete(:group) and Array(group)) ||
+ options.delete(:groups) ||
+ @current_groups
- def gem name, *reqs
- # Ignore the opts for now.
- reqs.pop if reqs.last.kind_of?(Hash)
+ if groups then
+ groups.each do |group|
+ gem_arguments = [name, *requirements]
+ gem_arguments << options unless options.empty?
+ @dependency_groups[group] << gem_arguments
+ end
- @set.gem name, *reqs
+ return
+ end
+
+ @set.gem name, *requirements
end
- def group *what
+ ##
+ # Returns the basename of the file the dependencies were loaded from
+
+ def gem_deps_file # :nodoc:
+ File.basename @path
end
+ ##
+ # :category: Gem Dependencies DSL
+ # Block form for placing a dependency in the given +groups+.
+
+ def group *groups
+ @current_groups = groups
+
+ yield
+
+ ensure
+ @current_groups = nil
+ end
+
+ ##
+ # :category: Gem Dependencies DSL
+
def platform what
if what == :ruby
yield
end
end
+ ##
+ # :category: Gem Dependencies DSL
+
alias :platforms :platform
+ ##
+ # :category: Gem Dependencies DSL
+ # Restricts this gem dependencies file to the given ruby +version+. The
+ # +:engine+ options from Bundler are currently ignored.
+
+ def ruby version, options = {}
+ return true if version == RUBY_VERSION
+
+ message = "Your Ruby version is #{RUBY_VERSION}, " +
+ "but your #{gem_deps_file} specified #{version}"
+
+ raise Gem::RubyVersionMismatch, message
+ end
+
+ ##
+ # :category: Gem Dependencies DSL
+
def source url
end
+ # TODO: remove this typo name at RubyGems 3.0
+
+ Gem::RequestSet::DepedencyAPI = self # :nodoc:
+
end
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb
index f63f6282d3..21119b901a 100644
--- a/lib/rubygems/specification.rb
+++ b/lib/rubygems/specification.rb
@@ -1721,6 +1721,13 @@ class Gem::Specification < Gem::BasicSpecification
end
##
+ # Work around bundler removing my methods
+
+ def gem_dir # :nodoc:
+ super
+ end
+
+ ##
# Deprecated and ignored, defaults to true.
#
# Formerly used to indicate this gem was RDoc-capable.