Class: YleTf::System

Inherits:
Object
  • Object
show all
Defined in:
lib/yle_tf/system.rb

Overview

Helpers to execute system commands with error handling

TODO: Add way to wrap stdout of the commands and direct it to ‘Logger`

Constant Summary collapse

ExecuteError =
Class.new(YleTf::Error)

Class Method Summary collapse

Class Method Details

.cmd(*args, **opts) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/yle_tf/system.rb', line 13

def self.cmd(*args, **opts)
  env = opts[:env]
  YleTf::Logger.debug { "Calling `#{args.shelljoin}`#{" with env '#{env}'" if env}" }

  system(env || {}, *args) ||
    raise(ExecuteError,
          "Failed to execute `#{args.shelljoin}`#{" with env '#{env}'" if env}")
end