Class: Beaker::Host::PuppetConfigReader
- Inherits:
-
Object
- Object
- Beaker::Host::PuppetConfigReader
- Defined in:
- lib/beaker/host.rb
Overview
This class provides array syntax for using puppet –configprint on a host
Instance Method Summary collapse
- #[](k) ⇒ Object
- #has_key?(k) ⇒ Boolean
-
#initialize(host, command) ⇒ PuppetConfigReader
constructor
A new instance of PuppetConfigReader.
Constructor Details
#initialize(host, command) ⇒ PuppetConfigReader
Returns a new instance of PuppetConfigReader.
24 25 26 27 |
# File 'lib/beaker/host.rb', line 24 def initialize(host, command) @host = host @command = command end |
Instance Method Details
#[](k) ⇒ Object
37 38 39 40 |
# File 'lib/beaker/host.rb', line 37 def [](k) cmd = PuppetCommand.new(@command, "--configprint #{k.to_s}") @host.exec(cmd).stdout.strip end |
#has_key?(k) ⇒ Boolean
29 30 31 32 33 34 35 |
# File 'lib/beaker/host.rb', line 29 def has_key?(k) cmd = PuppetCommand.new(@command, '--configprint all') keys = @host.exec(cmd).stdout.split("\n").collect do |x| x[/^[^\s]+/] end keys.include?(k) end |