Module: Librarian::Puppet::Simple::Iterator

Included in:
CLI, Installer
Defined in:
lib/librarian/puppet/simple/iterator.rb

Instance Method Summary collapse

Instance Method Details

#clear_modulesObject



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, options = {})
  @modules ||= {}
  full_name   = name
  module_name = name.split('/', 2).last

  case
  when options[:git]
    @modules[:git] ||= {}
    @modules[:git][module_name] = options.merge(:name => module_name, :full_name => full_name)
  when options[:tarball]
    @modules[:tarball] ||= {}
    @modules[:tarball][module_name] = options.merge(:name => module_name, :full_name => full_name)
  else
    @modules[:forge] ||= {}
    @modules[:forge][module_name] = options.merge(:name => module_name, :full_name => full_name)
    #abort('only the :git and :tarball providers are currently supported')
  end
end

#modulesObject



28
29
30
# File 'lib/librarian/puppet/simple/iterator.rb', line 28

def modules
  @modules
end