Module: WebVideo::Tools
- Defined in:
- lib/web_video/tools.rb
Class Method Summary collapse
- .apply_options(command, options) ⇒ Object
-
.run(cmd, params = "", expected_outcodes = 0) ⇒ Object
Execute command with params and return output if exit status equal expected_outcodes.
- .run_with_option(command_name, params, options = {}) ⇒ Object
Class Method Details
.apply_options(command, options) ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/web_video/tools.rb', line 28 def self.(command, ) str = command.dup .each do |key, value| param = value.is_a?(String) ? value.inspect : value str.gsub!("$#{key}$", param.to_s) end str end |
.run(cmd, params = "", expected_outcodes = 0) ⇒ Object
Execute command with params and return output if exit status equal expected_outcodes
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/web_video/tools.rb', line 11 def self.run(cmd, params = "", expected_outcodes = 0) command = %Q[#{cmd} #{params}].gsub(/\s+/, " ") command = "#{command} 2>&1" WebVideo.logger.info(command) output = `#{command}` WebVideo.logger.info(output) unless [expected_outcodes].flatten.include?($?.exitstatus) raise WebVideo::CommandLineError, "Error while running #{cmd}" end output end |
.run_with_option(command_name, params, options = {}) ⇒ Object
4 5 6 |
# File 'lib/web_video/tools.rb', line 4 def self.run_with_option(command_name, params, = {}) run(command_name, (params, )) end |