Module: Librarian::Puppet::Simple::Iterator
Instance Method Summary collapse
- #clear_modules ⇒ Object
-
#each_module(&block) ⇒ Object
iterate through all modules.
-
#each_module_of_type(type, &block) ⇒ Object
loop over each module of a certain type.
-
#mod(name, options = {}) ⇒ Object
evaluate a module and add it our @modules instance variable.
- #modules ⇒ Object
Instance Method Details
#clear_modules ⇒ Object
32 33 34 |
# File 'lib/librarian/puppet/simple/iterator.rb', line 32 def clear_modules @modules = nil end |
#each_module(&block) ⇒ Object
iterate through all modules
37 38 39 40 41 42 43 |
# File 'lib/librarian/puppet/simple/iterator.rb', line 37 def each_module(&block) (@modules || {}).each do |type, repos| (repos || {}).values.each do |repo| yield repo end end end |
#each_module_of_type(type, &block) ⇒ Object
loop over each module of a certain type
46 47 48 49 50 51 |
# File 'lib/librarian/puppet/simple/iterator.rb', line 46 def each_module_of_type(type, &block) abort("undefined type #{type}") unless [:git, :tarball].include?(type) ((@modules || {})[type] || {}).values.each do |repo| yield repo end end |
#mod(name, options = {}) ⇒ Object
evaluate a module and add it our @modules instance variable
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/librarian/puppet/simple/iterator.rb', line 9 def mod(name, = {}) @modules ||= {} full_name = name module_name = name.split('/', 2).last case when [:git] @modules[:git] ||= {} @modules[:git][module_name] = .merge(:name => module_name, :full_name => full_name) when [:tarball] @modules[:tarball] ||= {} @modules[:tarball][module_name] = .merge(:name => module_name, :full_name => full_name) else @modules[:forge] ||= {} @modules[:forge][module_name] = .merge(:name => module_name, :full_name => full_name) #abort('only the :git and :tarball providers are currently supported') end end |
#modules ⇒ Object
28 29 30 |
# File 'lib/librarian/puppet/simple/iterator.rb', line 28 def modules @modules end |