Module: PoolParty::DependencyResolutions::Puppet

Defined in:
lib/poolparty/dependency_resolver/puppet.rb

Instance Method Summary collapse

Instance Method Details

#pretty_print_resources(pre = " ") ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/poolparty/dependency_resolver/puppet.rb', line 13

def pretty_print_resources(pre=" ")
  returning Array.new do |out|
    resources.each do |name, res|
      out << "#{pre}#{name}"
      out << "#{pre*2}#{res.map {|a| a.name}}"
      res.each do |r|
        out << "#{pre*2}#{r.pretty_print_resources(pre*2)}"
      end
    end
  end.join("\n")
end

#to_string(pre = "") ⇒ Object

Generic to_s Most Resources won’t need to extend this



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/poolparty/dependency_resolver/puppet.rb', line 27

def to_string(pre="")
  return "" if printed?
  opts = options #get_modified_options
  
  returning Array.new do |output|
    unless cancelled?
      output << @prestring || ""

      if resources && !resources.empty? 
        output << resources_string_from_resources(resources, pre)
      end
      
      unless virtual_resource?
        output << "#{pre}#{class_type_name.downcase} { #{pre}\"#{self.key}\":"
        output << opts.flush_out("#{pre*2}").join(",\n")
        output << "#{pre}}"
      end
      
      printed
      output << @poststring || ""
    end
  end.join("\n")
end