Module: RFacter::DSL::Facter::Core::Execution
- Defined in:
- lib/rfacter/dsl.rb
Overview
TODO:
Implement execution options
Shims for Facter::Core::Exection methods
Defined Under Namespace
Classes: ExecutionFailure
Class Method Summary collapse
-
.exec(command) ⇒ String
deprecated
Deprecated.
Use #Execution.execute instead
-
.execute(command, on_fail: :raise, **options) ⇒ String, Object
Execute a command and return the output of that program.
-
.which(bin) ⇒ String?
Determines the full path to a binary.
Class Method Details
.exec(command) ⇒ String
Deprecated.
Use #execute instead
Try to execute a command and return the output.
255 256 257 |
# File 'lib/rfacter/dsl.rb', line 255 def self.exec(command) execute(command, on_fail: nil) end |
.execute(command, on_fail: :raise, **options) ⇒ String, Object
Execute a command and return the output of that program.
275 276 277 278 279 280 281 282 283 284 285 286 287 288 |
# File 'lib/rfacter/dsl.rb', line 275 def self.execute(command, on_fail: :raise, **) begin output = NODE.value.execute(command).stdout.chomp rescue => detail if on_fail == :raise raise ::RFacter::DSL::Facter::Core::Execution::ExecutionFailure.new, "Failed while executing '#{command}': #{detail.}" else return on_fail end end output end |
.which(bin) ⇒ String?
Determines the full path to a binary.
Returns nil if no matching executable can be found otherwise returns the expanded pathname.
299 300 301 |
# File 'lib/rfacter/dsl.rb', line 299 def self.which(bin) NODE.value.which(bin) end |