aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rubygems/request_set
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rubygems/request_set')
-rw-r--r--lib/rubygems/request_set/gem_dependency_api.rb61
-rw-r--r--lib/rubygems/request_set/lockfile.rb7
-rw-r--r--lib/rubygems/request_set/lockfile/parser.rb28
-rw-r--r--lib/rubygems/request_set/lockfile/tokenizer.rb2
4 files changed, 76 insertions, 22 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
-
diff --git a/lib/rubygems/request_set/lockfile.rb b/lib/rubygems/request_set/lockfile.rb
index e9a706e83b..7f6eadb939 100644
--- a/lib/rubygems/request_set/lockfile.rb
+++ b/lib/rubygems/request_set/lockfile.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
##
# Parses a gem.deps.rb.lock file and constructs a LockSet containing the
# dependencies found inside. If the lock file is missing no LockSet is
@@ -130,8 +130,8 @@ class Gem::RequestSet::Lockfile
[source.repository, source.rev_parse]
end
- out << "GIT"
by_repository_revision.each do |(repository, revision), requests|
+ out << "GIT"
out << " remote: #{repository}"
out << " revision: #{revision}"
out << " specs:"
@@ -144,9 +144,8 @@ class Gem::RequestSet::Lockfile
out << " #{dep.name}#{dep.requirement.for_lockfile}"
end
end
+ out << nil
end
-
- out << nil
end
def relative_path_from dest, base # :nodoc:
diff --git a/lib/rubygems/request_set/lockfile/parser.rb b/lib/rubygems/request_set/lockfile/parser.rb
index 18aaadf3bb..ebea940188 100644
--- a/lib/rubygems/request_set/lockfile/parser.rb
+++ b/lib/rubygems/request_set/lockfile/parser.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
class Gem::RequestSet::Lockfile::Parser
###
# Parses lockfiles
@@ -325,15 +325,24 @@ class Gem::RequestSet::Lockfile::Parser
@tokens.peek
end
- def pinned_requirement name # :nodoc:
- spec = @set.sets.select { |set|
- Gem::Resolver::GitSet === set or
- Gem::Resolver::VendorSet === set
- }.map { |set|
- set.specs[name]
- }.compact.first
+ if [].respond_to? :flat_map
+ def pinned_requirement name # :nodoc:
+ requirement = Gem::Dependency.new name
+ specification = @set.sets.flat_map { |set|
+ set.find_all(requirement)
+ }.compact.first
- spec.version
+ specification && specification.version
+ end
+ else # FIXME: remove when 1.8 is dropped
+ def pinned_requirement name # :nodoc:
+ requirement = Gem::Dependency.new name
+ specification = @set.sets.map { |set|
+ set.find_all(requirement)
+ }.flatten(1).compact.first
+
+ specification && specification.version
+ end
end
##
@@ -343,4 +352,3 @@ class Gem::RequestSet::Lockfile::Parser
@tokens.unshift token
end
end
-
diff --git a/lib/rubygems/request_set/lockfile/tokenizer.rb b/lib/rubygems/request_set/lockfile/tokenizer.rb
index d68645d235..c9f1fac75b 100644
--- a/lib/rubygems/request_set/lockfile/tokenizer.rb
+++ b/lib/rubygems/request_set/lockfile/tokenizer.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'strscan'
require 'rubygems/request_set/lockfile/parser'