Class: Puppet_X::Binford2k::Itemize::Runner
- Inherits:
-
Object
- Object
- Puppet_X::Binford2k::Itemize::Runner
- Defined in:
- lib/puppet_x/binford2k/itemize/runner.rb
Instance Attribute Summary collapse
-
#results ⇒ Object
readonly
Returns the value of attribute results.
Instance Method Summary collapse
- #dump! ⇒ Object
- #expand(paths) ⇒ Object
-
#initialize(options = {}) ⇒ Runner
constructor
A new instance of Runner.
- #run! ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Runner
Returns a new instance of Runner.
3 4 5 6 7 |
# File 'lib/puppet_x/binford2k/itemize/runner.rb', line 3 def initialize( = {}) @paths = (Array([:manifests])) = @results = {} end |
Instance Attribute Details
#results ⇒ Object (readonly)
Returns the value of attribute results.
2 3 4 |
# File 'lib/puppet_x/binford2k/itemize/runner.rb', line 2 def results @results end |
Instance Method Details
#dump! ⇒ Object
38 39 40 41 |
# File 'lib/puppet_x/binford2k/itemize/runner.rb', line 38 def dump! require 'json' puts JSON.pretty_generate(@results) end |
#expand(paths) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/puppet_x/binford2k/itemize/runner.rb', line 9 def (paths) paths.map do |path| path = File.(path) if File.file? path path elsif File.directory? path Dir.glob("#{path}/**/*.pp") else raise "Path '#{path}' doesn't appear to be a file or directory" end end.flatten end |
#run! ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/puppet_x/binford2k/itemize/runner.rb', line 23 def run! @paths.each do |path| parser = Puppet_X::Binford2k::Itemize::Parser.new(path, ).parse! parser.results.each do |kind, counts| @results[kind] ||= {} counts.each do |name, count| @results[kind][name] ||= 0 @results[kind][name] += count end end end self end |