Class: Riddle::ExecuteCommand
- Inherits:
-
Object
- Object
- Riddle::ExecuteCommand
- Defined in:
- lib/riddle/execute_command.rb
Constant Summary collapse
- WINDOWS =
(RUBY_PLATFORM =~ /mswin|mingw/)
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(command, verbose) ⇒ ExecuteCommand
constructor
A new instance of ExecuteCommand.
Constructor Details
#initialize(command, verbose) ⇒ ExecuteCommand
Returns a new instance of ExecuteCommand.
10 11 12 13 14 15 16 17 |
# File 'lib/riddle/execute_command.rb', line 10 def initialize(command, verbose) @command, @verbose = command, verbose return unless WINDOWS @command = "start /B #{@command} 1> NUL 2>&1" @verbose = true end |
Class Method Details
.call(command, verbose = true) ⇒ Object
6 7 8 |
# File 'lib/riddle/execute_command.rb', line 6 def self.call(command, verbose = true) new(command, verbose).call end |
Instance Method Details
#call ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/riddle/execute_command.rb', line 19 def call result = verbose? ? result_from_system : result_from_backticks return result if result.status == 0 error = Riddle::CommandFailedError.new "Sphinx command failed to execute" error.command_result = result raise error end |