Sha256: 01c5d466b66d9e25f5d1e1ab15e87c48af7ee6b71bc418fa4b564115b8c1025f
Contents?: true
Size: 900 Bytes
Versions: 3
Compression:
Stored size: 900 Bytes
Contents
class Riddle::ExecuteCommand WINDOWS = (RUBY_PLATFORM =~ /mswin|mingw/) def self.call(command, verbose = true) new(command, verbose).call end def initialize(command, verbose) @command, @verbose = command, verbose return unless WINDOWS @command = "start /B #{@command} 1> NUL 2>&1" @verbose = true end 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 attr_reader :command, :verbose def result_from_backticks output = `#{command}` Riddle::CommandResult.new command, $?.exitstatus, output end def result_from_system system command Riddle::CommandResult.new command, $?.exitstatus end def verbose? verbose end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
riddle-2.2.0 | lib/riddle/execute_command.rb |
riddle-2.1.0 | lib/riddle/execute_command.rb |
riddle-2.0.0 | lib/riddle/execute_command.rb |