Class: Gloo::Objs::EachRepo
- Inherits:
-
Object
- Object
- Gloo::Objs::EachRepo
- Defined in:
- lib/gloo/objs/ctrl/each_repo.rb
Constant Summary collapse
- FILE =
'file'.freeze
- REPO =
'repo'.freeze
Class Method Summary collapse
-
.use_for?(iterator_obj) ⇒ Boolean
Use this iterator for each loop?.
Instance Method Summary collapse
-
#find_all_git_projects(path) ⇒ Object
Find all git projects in a path.
-
#initialize(engine, iterator_obj) ⇒ EachRepo
constructor
——————————————————————— Create Iterator ———————————————————————.
-
#run ⇒ Object
Run for repo.
-
#set_repo(path) ⇒ Object
Set the value of the repo.
Constructor Details
#initialize(engine, iterator_obj) ⇒ EachRepo
Create Iterator
19 20 21 22 |
# File 'lib/gloo/objs/ctrl/each_repo.rb', line 19 def initialize( engine, iterator_obj ) @engine = engine @iterator_obj = iterator_obj end |
Class Method Details
Instance Method Details
#find_all_git_projects(path) ⇒ Object
Find all git projects in a path.
46 47 48 49 50 51 52 53 54 |
# File 'lib/gloo/objs/ctrl/each_repo.rb', line 46 def find_all_git_projects( path ) path.children.collect do |f| if f.directory? && ( File.basename( f ) == '.git' ) File.dirname( f ) elsif f.directory? find_all_git_projects( f ) end end.flatten.compact end |
#run ⇒ Object
Run for repo.
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/gloo/objs/ctrl/each_repo.rb', line 59 def run path = @iterator_obj.in_value return unless path path = Pathname.new( path ) repos = find_all_git_projects( path ) repos.each do |o| set_repo o @iterator_obj.run_do end end |
#set_repo(path) ⇒ Object
Set the value of the repo. This is a path to the repo.
75 76 77 78 79 80 |
# File 'lib/gloo/objs/ctrl/each_repo.rb', line 75 def set_repo( path ) o = @iterator_obj.find_child REPO return unless o o.set_value path end |