Class: Scriptster::ShellCmd
- Inherits:
-
Object
- Object
- Scriptster::ShellCmd
- Includes:
- Logger
- Defined in:
- lib/scriptster/shellcmd.rb
Overview
Represent an executed shell command.
The command will be executed in the constructor. It runs in the foreground, so your application will block until it’s finished executing. The logs, however, will be printed real-time as the command prints its output.
Instance Attribute Summary collapse
-
#err ⇒ String
The content of the STDERR of the command.
-
#out ⇒ String
The content of the STDOUT of the command.
-
#status ⇒ Process::status
The exit status of the command.
Instance Method Summary collapse
-
#initialize(cmd, opts = {}) ⇒ ShellCmd
constructor
Initialise the object and run the command.
Methods included from Logger
log, #log, set_file, set_format, set_name, set_verbosity
Constructor Details
#initialize(cmd, opts = {}) ⇒ ShellCmd
Initialise the object and run the command
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/scriptster/shellcmd.rb', line 56 def initialize(cmd, opts={}) @out = "" @err = "" @show_out = false @out_level = :info @show_err = true @raise = true @tag = cmd.split[0] @expect = 0 opts.each do |k, v| self.instance_variable_set("@#{k.to_s}", v) end @cmd = cmd @status = nil run end |
Instance Attribute Details
#err ⇒ String
The content of the STDERR of the command.
39 40 41 |
# File 'lib/scriptster/shellcmd.rb', line 39 def err @err end |
#out ⇒ String
The content of the STDOUT of the command.
39 40 41 |
# File 'lib/scriptster/shellcmd.rb', line 39 def out @out end |
#status ⇒ Process::status
The exit status of the command.
39 40 41 |
# File 'lib/scriptster/shellcmd.rb', line 39 def status @status end |