diff options
-rw-r--r-- | lib/rubygems/request_set/gem_dependency_api.rb | 319 |
1 files changed, 295 insertions, 24 deletions
@@ -1,5 +1,33 @@ ## -# A semi-compatible DSL for the Bundler Gemfile and Isolate formats. class Gem::RequestSet::GemDependencyAPI @@ -21,6 +49,8 @@ class Gem::RequestSet::GemDependencyAPI :ruby_21 => %w[ruby rbx maglev], } x86_mingw = Gem::Platform.new 'x86-mingw32' x64_mingw = Gem::Platform.new 'x64-mingw32' @@ -39,7 +69,15 @@ class Gem::RequestSet::GemDependencyAPI :mri_19 => Gem::Platform::RUBY, :mri_20 => Gem::Platform::RUBY, :mri_21 => Gem::Platform::RUBY, - :mswin => Gem::Platform::RUBY, :rbx => Gem::Platform::RUBY, :ruby => Gem::Platform::RUBY, :ruby_18 => Gem::Platform::RUBY, @@ -73,6 +111,14 @@ class Gem::RequestSet::GemDependencyAPI :mri_20 => tilde_gt_2_0_0, :mri_21 => tilde_gt_2_1_0, :mswin => gt_eq_0, :rbx => gt_eq_0, :ruby => gt_eq_0, :ruby_18 => tilde_gt_1_8_0, @@ -96,6 +142,14 @@ class Gem::RequestSet::GemDependencyAPI :mri_20 => :never, :mri_21 => :never, :mswin => :only, :rbx => :never, :ruby => :never, :ruby_18 => :never, @@ -108,6 +162,11 @@ class Gem::RequestSet::GemDependencyAPI } ## # A set of gems that are loaded via the +:git+ option to #gem attr_reader :git_set # :nodoc: @@ -136,14 +195,31 @@ class Gem::RequestSet::GemDependencyAPI @path = path @current_groups = nil - @current_platform = nil @current_repository = nil @default_sources = true @git_set = @set.git_set @requires = Hash.new { |h, name| h[name] = [] } @vendor_set = @set.vendor_set @gem_sources = {} @without_groups = [] end ## @@ -187,14 +263,26 @@ class Gem::RequestSet::GemDependencyAPI end ## - # Loads the gem dependency file def load instance_eval File.read(@path).untaint, @path, 1 end ## # :category: Gem Dependencies DSL # :call-seq: # gem(name) # gem(name, *requirements) @@ -202,6 +290,66 @@ class Gem::RequestSet::GemDependencyAPI # # 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) @@ -211,9 +359,20 @@ class Gem::RequestSet::GemDependencyAPI source_set = false - source_set ||= gem_path name, options - source_set ||= gem_git name, options - source_set ||= gem_ name, options return unless gem_platforms options @@ -225,6 +384,12 @@ class Gem::RequestSet::GemDependencyAPI gem_requires name, options @set.gem name, *requirements end @@ -258,21 +423,27 @@ class Gem::RequestSet::GemDependencyAPI private :gem_git ## - # Handles the : option from +options+ for gem +name+. # - # Returns +true+ if the path option was handled. - def gem_ name, options # :nodoc: - return unless path = options.delete(:) - options[:git] = "git://.com/#{path}.git" gem_git name, options true end - private :gem_ ## # Handles the :group and :groups +options+ for the gem with the given @@ -314,8 +485,9 @@ class Gem::RequestSet::GemDependencyAPI # platform matches the current platform. def gem_platforms options # :nodoc: - platform_names = Array(options.delete :platforms) - platform_names << @current_platform if @current_platform return true if platform_names.empty? @@ -343,7 +515,7 @@ class Gem::RequestSet::GemDependencyAPI private :gem_platforms ## - # Handles the require: option from +options+ and adds those files, or the # default file to the require list for +name+. def gem_requires name, options # :nodoc: @@ -362,6 +534,11 @@ class Gem::RequestSet::GemDependencyAPI # :category: Gem Dependencies DSL # # Block form for specifying gems from a git +repository+. def git repository @current_repository = repository @@ -373,6 +550,15 @@ class Gem::RequestSet::GemDependencyAPI end ## # Returns the basename of the file the dependencies were loaded from def gem_deps_file # :nodoc: @@ -383,6 +569,23 @@ class Gem::RequestSet::GemDependencyAPI # :category: Gem Dependencies DSL # # Loads dependencies from a gemspec file. def gemspec options = {} name = options.delete(:name) || '{,*}' @@ -404,7 +607,20 @@ class Gem::RequestSet::GemDependencyAPI ## # :category: Gem Dependencies DSL # Block form for placing a dependency in the given +groups+. def group *groups @current_groups = groups @@ -440,28 +656,72 @@ class Gem::RequestSet::GemDependencyAPI ## # :category: Gem Dependencies DSL # - # Block form for restricting gems to a particular platform. - def platform what - @current_platform = what yield ensure - @current_platform = nil end ## # :category: Gem Dependencies DSL # - # Block form for restricting gems to a particular platform. 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 = {} engine = options[:engine] @@ -471,6 +731,8 @@ class Gem::RequestSet::GemDependencyAPI 'you must specify engine_version along with the ruby engine' if engine and not engine_version unless RUBY_VERSION == version then message = "Your Ruby version is #{RUBY_VERSION}, " + "but your #{gem_deps_file} requires #{version}" @@ -503,7 +765,16 @@ class Gem::RequestSet::GemDependencyAPI ## # :category: Gem Dependencies DSL # - # Sets +url+ as a source for gems for this dependency API. def source url Gem.sources.clear if @default_sources |