Class: Unixoid::Runner
- Inherits:
-
Object
- Object
- Unixoid::Runner
- Defined in:
- lib/unixoid/runner.rb
Constant Summary collapse
- LOG_FILE =
'logfile.log'
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Runner
constructor
A new instance of Runner.
- #log(level, message) ⇒ Object
- #run(command, params: {}, outcodes: [0]) ⇒ Object
Constructor Details
#initialize ⇒ Runner
Returns a new instance of Runner.
10 11 12 |
# File 'lib/unixoid/runner.rb', line 10 def initialize @logger = Logger.new(LOG_FILE) end |
Class Method Details
.run(command, params: {}, outcodes: {}) ⇒ Object
14 15 16 |
# File 'lib/unixoid/runner.rb', line 14 def self.run(command, params: {}, outcodes: {}) new.run(command, params: params, outcodes: outcodes) end |
Instance Method Details
#log(level, message) ⇒ Object
27 28 29 30 |
# File 'lib/unixoid/runner.rb', line 27 def log(level, ) @logger.send(level, ) end |
#run(command, params: {}, outcodes: [0]) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/unixoid/runner.rb', line 18 def run(command, params: {}, outcodes: [0]) line = Cocaine::CommandLine.new('', command, expected_outcodes: outcodes, swallow_stderr: true) begin log(:info, line.run(params)) rescue Cocaine::ExitStatusError => error log(:error, error.) end end |