summaryrefslogtreecommitdiff
path: root/lib/rubygems/request_set/gem_dependency_api.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rubygems/request_set/gem_dependency_api.rb')
-rw-r--r--lib/rubygems/request_set/gem_dependency_api.rb61
1 files changed, 54 insertions, 7 deletions
diff --git a/lib/rubygems/request_set/gem_dependency_api.rb b/lib/rubygems/request_set/gem_dependency_api.rb
index 4927e5db6a..4b2699d7d2 100644
--- a/lib/rubygems/request_set/gem_dependency_api.rb
+++ b/lib/rubygems/request_set/gem_dependency_api.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
##
# A semi-compatible DSL for the Bundler Gemfile and Isolate gem dependencies
# files.
@@ -205,6 +205,7 @@ class Gem::RequestSet::GemDependencyAPI
@installing = false
@requires = Hash.new { |h, name| h[name] = [] }
@vendor_set = @set.vendor_set
+ @source_set = @set.source_set
@gem_sources = {}
@without_groups = []
@@ -363,6 +364,7 @@ class Gem::RequestSet::GemDependencyAPI
source_set ||= gem_path name, options
source_set ||= gem_git name, options
source_set ||= gem_git_source name, options
+ source_set ||= gem_source name, options
duplicate = @dependencies.include? name
@@ -408,11 +410,7 @@ Gem dependencies file #{@path} requires #{name} more than once.
pin_gem_source name, :git, repository
- reference = nil
- reference ||= options.delete :ref
- reference ||= options.delete :branch
- reference ||= options.delete :tag
- reference ||= 'master'
+ reference = gem_git_reference options
submodules = options.delete :submodules
@@ -421,6 +419,36 @@ Gem dependencies file #{@path} requires #{name} more than once.
true
end
+ ##
+ # Handles the git options from +options+ for git gem.
+ #
+ # Returns reference for the git gem.
+
+ def gem_git_reference options # :nodoc:
+ ref = options.delete :ref
+ branch = options.delete :branch
+ tag = options.delete :tag
+
+ reference = nil
+ reference ||= ref
+ reference ||= branch
+ reference ||= tag
+ reference ||= 'master'
+
+ if ref && branch
+ warn <<-WARNING
+Gem dependencies file #{@path} includes git reference for both ref and branch but only ref is used.
+ WARNING
+ end
+ if (ref||branch) && tag
+ warn <<-WARNING
+Gem dependencies file #{@path} includes git reference for both ref/branch and tag but only ref/branch is used.
+ WARNING
+ end
+
+ reference
+ end
+
private :gem_git
##
@@ -482,6 +510,23 @@ Gem dependencies file #{@path} requires #{name} more than once.
private :gem_path
##
+ # Handles the source: option from +options+ for gem +name+.
+ #
+ # Returns +true+ if the source option was handled.
+
+ def gem_source name, options # :nodoc:
+ return unless source = options.delete(:source)
+
+ pin_gem_source name, :source, source
+
+ @source_set.add_source_gem name, source
+
+ true
+ end
+
+ private :gem_source
+
+ ##
# Handles the platforms: option from +options+. Returns true if the
# platform matches the current platform.
@@ -527,6 +572,7 @@ Gem dependencies file #{@path} requires #{name} more than once.
else
@requires[name] << name
end
+ raise ArgumentError, "Unhandled gem options #{options.inspect}" unless options.empty?
end
private :gem_requires
@@ -612,6 +658,7 @@ Gem dependencies file #{@path} requires #{name} more than once.
add_dependencies groups, spec.development_dependencies
+ @vendor_set.add_vendor_gem spec.name, path
gem_requires spec.name, options
end
@@ -651,6 +698,7 @@ Gem dependencies file #{@path} requires #{name} more than once.
when :default then '(default)'
when :path then "path: #{source}"
when :git then "git: #{source}"
+ when :source then "source: #{source}"
else '(unknown)'
end
@@ -799,4 +847,3 @@ Gem dependencies file #{@path} requires #{name} more than once.
Gem::RequestSet::GemDepedencyAPI = self # :nodoc:
end
-