Class: Beaker::Host::PuppetConfigReader

Inherits:
Object
  • Object
show all
Defined in:
lib/beaker/host.rb

Overview

This class provides array syntax for using puppet –configprint on a host

Instance Method Summary collapse

Constructor Details

#initialize(host, command) ⇒ PuppetConfigReader

Returns a new instance of PuppetConfigReader.



26
27
28
29
# File 'lib/beaker/host.rb', line 26

def initialize(host, command)
  @host = host
  @command = command
end

Instance Method Details

#[](k) ⇒ Object



39
40
41
42
# File 'lib/beaker/host.rb', line 39

def [](k)
  cmd = PuppetCommand.new(@command, "--configprint #{k}")
  @host.exec(cmd).stdout.strip
end

#has_key?(k) ⇒ Boolean

Returns:

  • (Boolean)


31
32
33
34
35
36
37
# File 'lib/beaker/host.rb', line 31

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