Class: Gem::Resolver::GitSet
- Defined in:
- lib/rubygems/resolver/git_set.rb
Overview
Instance Attribute Summary collapse
-
#need_submodules ⇒ Object
readonly
Contains repositories needing submodules.
-
#repositories ⇒ Object
readonly
A Hash containing git gem names for keys and a Hash of repository and git commit reference as values.
-
#root_dir ⇒ Object
The root directory for git gems in this set.
-
#specs ⇒ Object
readonly
A hash of gem names to Gem::Resolver::GitSpecifications.
Attributes inherited from Set
Instance Method Summary collapse
-
#add_git_gem(name, repository, reference, submodules) ⇒ Object
:nodoc:.
-
#add_git_spec(name, version, repository, reference, submodules) ⇒ Object
Adds and returns a GitSpecification with the given
name
andversion
which came from arepository
at the givenreference
. -
#find_all(req) ⇒ Object
Finds all git gems matching
req
. -
#initialize ⇒ GitSet
constructor
:nodoc:.
-
#prefetch(reqs) ⇒ Object
Prefetches specifications from the git repositories in this set.
-
#pretty_print(q) ⇒ Object
:nodoc:.
Methods inherited from Set
Constructor Details
Instance Attribute Details
#need_submodules ⇒ Object (readonly)
Contains repositories needing submodules
23 24 25 |
# File 'lib/rubygems/resolver/git_set.rb', line 23 def need_submodules @need_submodules end |
#repositories ⇒ Object (readonly)
A Hash containing git gem names for keys and a Hash of repository and git commit reference as values.
29 30 31 |
# File 'lib/rubygems/resolver/git_set.rb', line 29 def repositories @repositories end |
#root_dir ⇒ Object
The root directory for git gems in this set. This is usually Gem.dir, the installation directory for regular gems.
18 19 20 |
# File 'lib/rubygems/resolver/git_set.rb', line 18 def root_dir @root_dir end |
#specs ⇒ Object (readonly)
A hash of gem names to Gem::Resolver::GitSpecifications
34 35 36 |
# File 'lib/rubygems/resolver/git_set.rb', line 34 def specs @specs end |
Instance Method Details
#add_git_gem(name, repository, reference, submodules) ⇒ Object
:nodoc:
45 46 47 48 |
# File 'lib/rubygems/resolver/git_set.rb', line 45 def add_git_gem(name, repository, reference, submodules) # :nodoc: @repositories[name] = [repository, reference] @need_submodules[repository] = submodules end |
#add_git_spec(name, version, repository, reference, submodules) ⇒ Object
Adds and returns a GitSpecification with the given name
and version
which came from a repository
at the given reference
. If submodules
is true they are checked out along with the repository.
This fills in the prefetch information as enough information about the gem is present in the arguments.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/rubygems/resolver/git_set.rb', line 58 def add_git_spec(name, version, repository, reference, submodules) # :nodoc: add_git_gem name, repository, reference, submodules source = Gem::Source::Git.new name, repository, reference source.root_dir = @root_dir spec = Gem::Specification.new do |s| s.name = name s.version = version end git_spec = Gem::Resolver::GitSpecification.new self, spec, source @specs[spec.name] = git_spec git_spec end |
#find_all(req) ⇒ Object
Finds all git gems matching req
79 80 81 82 83 84 85 |
# File 'lib/rubygems/resolver/git_set.rb', line 79 def find_all(req) prefetch nil specs.values.select do |spec| req.match? spec end end |
#prefetch(reqs) ⇒ Object
Prefetches specifications from the git repositories in this set.
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/rubygems/resolver/git_set.rb', line 90 def prefetch(reqs) return unless @specs.empty? @repositories.each do |name, (repository, reference)| source = Gem::Source::Git.new name, repository, reference source.root_dir = @root_dir source.remote = @remote source.specs.each do |spec| git_spec = Gem::Resolver::GitSpecification.new self, spec, source @specs[spec.name] = git_spec end end end |
#pretty_print(q) ⇒ Object
:nodoc:
106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/rubygems/resolver/git_set.rb', line 106 def pretty_print(q) # :nodoc: q.group 2, "[GitSet", "]" do next if @repositories.empty? q.breakable repos = @repositories.map do |name, (repository, reference)| "#{name}: #{repository}@#{reference}" end q.seplist repos do |repo| q.text repo end end end |