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.
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:.
Constructor Details
Instance Attribute Details
#need_submodules ⇒ Object (readonly)
Contains repositories needing submodules
22 23 24 |
# File 'lib/rubygems/resolver/git_set.rb', line 22 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.
28 29 30 |
# File 'lib/rubygems/resolver/git_set.rb', line 28 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.
17 18 19 |
# File 'lib/rubygems/resolver/git_set.rb', line 17 def root_dir @root_dir end |
#specs ⇒ Object (readonly)
A hash of gem names to Gem::Resolver::GitSpecifications
33 34 35 |
# File 'lib/rubygems/resolver/git_set.rb', line 33 def specs @specs end |
Instance Method Details
#add_git_gem(name, repository, reference, submodules) ⇒ Object
:nodoc:
43 44 45 46 |
# File 'lib/rubygems/resolver/git_set.rb', line 43 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.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/rubygems/resolver/git_set.rb', line 56 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
77 78 79 80 81 82 83 |
# File 'lib/rubygems/resolver/git_set.rb', line 77 def find_all req prefetch nil specs.values.select do |spec| req.matches_spec? spec end end |
#prefetch(reqs) ⇒ Object
Prefetches specifications from the git repositories in this set.
88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/rubygems/resolver/git_set.rb', line 88 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.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:
103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/rubygems/resolver/git_set.rb', line 103 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 |