Class: Twigg::RepoSet
- Inherits:
-
Object
- Object
- Twigg::RepoSet
- Defined in:
- lib/twigg/repo_set.rb
Overview
Represents a set of Git repositories existing in a directory.
Instance Method Summary collapse
-
#for_each_repo(&block) ⇒ Object
Execute ‘block` for each repo in the set.
-
#initialize(repositories_directory) ⇒ RepoSet
constructor
A new instance of RepoSet.
- #repos ⇒ Object
Constructor Details
#initialize(repositories_directory) ⇒ RepoSet
Returns a new instance of RepoSet.
6 7 8 |
# File 'lib/twigg/repo_set.rb', line 6 def initialize(repositories_directory) @repositories_directory = Pathname.new(repositories_directory) end |
Instance Method Details
#for_each_repo(&block) ⇒ Object
Execute ‘block` for each repo in the set.
The Twigg::Repo object is passed in to the block.
13 14 15 16 17 |
# File 'lib/twigg/repo_set.rb', line 13 def for_each_repo(&block) repos.each do |repo| block.call(repo) end end |
#repos ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/twigg/repo_set.rb', line 19 def repos @repos ||= begin Dir[File.join(@repositories_directory, '*')].map do |path| begin repo = Repo.new(path) rescue Repo::InvalidRepoError # most likely an empty or non-Git directory end end.compact end end |