class Riddle::ExecuteCommand
Constants
- WINDOWS
Attributes
command[R]
verbose[R]
Public Class Methods
call(command, verbose = true)
click to toggle source
# File lib/riddle/execute_command.rb, line 6 def self.call(command, verbose = true) new(command, verbose).call end
new(command, verbose)
click to toggle source
# 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
Public Instance Methods
call()
click to toggle source
# 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
Private Instance Methods
result_from_backticks()
click to toggle source
# File lib/riddle/execute_command.rb, line 32 def result_from_backticks begin output = `#{command}` rescue SystemCallError => error output = error.message end Riddle::CommandResult.new command, $?.exitstatus, output end
result_from_system()
click to toggle source
# File lib/riddle/execute_command.rb, line 42 def result_from_system system command Riddle::CommandResult.new command, $?.exitstatus end
verbose?()
click to toggle source
# File lib/riddle/execute_command.rb, line 48 def verbose? verbose end