Class: Metaverse::Iterator
- Inherits:
-
Object
- Object
- Metaverse::Iterator
- Defined in:
- lib/metaverse/iterator.rb
Instance Method Summary collapse
- #build ⇒ Object
- #each(&block) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(rootPath, ignore, repos = []) ⇒ Iterator
constructor
A new instance of Iterator.
- #map(&block) ⇒ Object
Constructor Details
#initialize(rootPath, ignore, repos = []) ⇒ Iterator
Returns a new instance of Iterator.
9 10 11 12 13 14 |
# File 'lib/metaverse/iterator.rb', line 9 def initialize rootPath, ignore, repos = [] @logger = Logger.new STDOUT @ignore = ['.', 'bower_components', 'node_modules'] + ignore @rootPath = rootPath @repos = repos end |
Instance Method Details
#build ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/metaverse/iterator.rb', line 16 def build Find.find(@rootPath) do |path| if File.directory? path if @ignore.any? { |word| File.basename(path).include? word } Find.prune end end if File.directory? path + '/.git' @repos << path end end puts "#{@repos.length} repos loaded" @repos end |
#each(&block) ⇒ Object
33 34 35 |
# File 'lib/metaverse/iterator.rb', line 33 def each &block @repos.send(:each, &block) end |
#empty? ⇒ Boolean
41 42 43 |
# File 'lib/metaverse/iterator.rb', line 41 def empty? @repos.count == 0 end |
#map(&block) ⇒ Object
37 38 39 |
# File 'lib/metaverse/iterator.rb', line 37 def map &block @repos.send(:map, &block) end |