Class: Chef::GuardInterpreter::DefaultGuardInterpreter
- Inherits:
-
Object
- Object
- Chef::GuardInterpreter::DefaultGuardInterpreter
- Includes:
- Mixin::ShellOut
- Defined in:
- lib/chef/guard_interpreter/default_guard_interpreter.rb
Instance Attribute Summary collapse
-
#output ⇒ Object
readonly
Returns the value of attribute output.
Instance Method Summary collapse
- #evaluate ⇒ Object
-
#initialize(command, opts) ⇒ DefaultGuardInterpreter
constructor
A new instance of DefaultGuardInterpreter.
Constructor Details
#initialize(command, opts) ⇒ DefaultGuardInterpreter
Returns a new instance of DefaultGuardInterpreter.
28 29 30 31 |
# File 'lib/chef/guard_interpreter/default_guard_interpreter.rb', line 28 def initialize(command, opts) @command = command @command_opts = opts end |
Instance Attribute Details
#output ⇒ Object (readonly)
Returns the value of attribute output.
26 27 28 |
# File 'lib/chef/guard_interpreter/default_guard_interpreter.rb', line 26 def output @output end |
Instance Method Details
#evaluate ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/chef/guard_interpreter/default_guard_interpreter.rb', line 33 def evaluate result = shell_out(@command, default_env: false, **@command_opts) @output = "STDOUT: #{result.stdout}\nSTDERR: #{result.stderr}\n" Chef::Log.debug "Command failed: #{result.stderr}" unless result.status.success? result.status.success? # Timeout fails command rather than chef-client run, see: # https://tickets.opscode.com/browse/CHEF-2690 rescue Chef::Exceptions::CommandTimeout Chef::Log.warn "Command '#{@command}' timed out" false end |