Class: CommandExec::Process
- Inherits:
-
Object
- Object
- CommandExec::Process
- Includes:
- FieldHelper
- Defined in:
- lib/command_exec/process.rb
Overview
The class used to save the data about the executed command
Instance Attribute Summary collapse
-
#end_time ⇒ Object
Returns the value of attribute end_time.
-
#executable ⇒ Object
Set/Get the executable of the command.
-
#log_file ⇒ Object
Returns the value of attribute log_file.
-
#pid ⇒ Object
Get the pid of the command.
-
#reason_for_failure ⇒ Object
Get the reason why
command_execthinks a command failed. -
#return_code ⇒ Object
Get the exit code of the command.
-
#start_time ⇒ Object
Return the time when the execution of the command started.
-
#status ⇒ Object
Get the status of the command.
-
#stderr ⇒ Object
Get stderr of the command.
-
#stdout ⇒ Object
Get stdout of the command.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Process
constructor
Create a process object.
- #run_time ⇒ Object
-
#to_a(fields = default_fields, formatter = Formatter::Array.new) ⇒ Object
Output process data as array.
-
#to_h(fields = default_fields, formatter = Formatter::Hash.new) ⇒ Object
Output process data as hash.
-
#to_json(fields = default_fields, formatter = Formatter::JSON.new) ⇒ Object
Output process data as json.
-
#to_s(fields = default_fields, formatter = Formatter::String.new) ⇒ Object
Output process data as string.
-
#to_xml(fields = default_fields, formatter = Formatter::XML.new) ⇒ Object
Output process data as xml.
-
#to_yaml(fields = default_fields, formatter = Formatter::YAML.new) ⇒ Object
Output process data as yaml.
Constructor Details
#initialize(options = {}) ⇒ Process
Create a process object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/command_exec/process.rb', line 70 def initialize(={}) @options = { lib_logger: Logger.new($stderr), stderr: [], stdout: [], log_file: [], pid: nil, return_code: nil, reason_for_failure: [], status: :success, executable: nil, }.merge @logger = @options[:lib_logger] @stderr = @options[:stderr] @stdout = @options[:stdout] @status = @options[:status] @log_file = @options[:log_file] @pid = @options[:pid] @reason_for_failure = @options[:reason_for_failure] @return_code = @options[:return_code] @executable = @options[:executable] @start_time = nil @end_time = nil end |
Instance Attribute Details
#end_time ⇒ Object
Returns the value of attribute end_time.
38 |
# File 'lib/command_exec/process.rb', line 38 attr_reader :status, :log_file, :stdout, :stderr, :reason_for_failure, :return_code, :pid, :start_time, :end_time |
#executable ⇒ Object
Set/Get the executable of the command
13 14 15 |
# File 'lib/command_exec/process.rb', line 13 def executable @executable end |
#log_file ⇒ Object
Returns the value of attribute log_file.
38 39 40 |
# File 'lib/command_exec/process.rb', line 38 def log_file @log_file end |
#pid ⇒ Object
Get the pid of the command
38 |
# File 'lib/command_exec/process.rb', line 38 attr_reader :status, :log_file, :stdout, :stderr, :reason_for_failure, :return_code, :pid, :start_time, :end_time |
#reason_for_failure ⇒ Object
Get the reason why command_exec thinks a command failed
38 |
# File 'lib/command_exec/process.rb', line 38 attr_reader :status, :log_file, :stdout, :stderr, :reason_for_failure, :return_code, :pid, :start_time, :end_time |
#return_code ⇒ Object
Get the exit code of the command
38 |
# File 'lib/command_exec/process.rb', line 38 attr_reader :status, :log_file, :stdout, :stderr, :reason_for_failure, :return_code, :pid, :start_time, :end_time |
#start_time ⇒ Object
Return the time when the execution of the command started
38 |
# File 'lib/command_exec/process.rb', line 38 attr_reader :status, :log_file, :stdout, :stderr, :reason_for_failure, :return_code, :pid, :start_time, :end_time |
#status ⇒ Object
Get the status of the command
38 39 40 |
# File 'lib/command_exec/process.rb', line 38 def status @status end |
#stderr ⇒ Object
Get stderr of the command
38 |
# File 'lib/command_exec/process.rb', line 38 attr_reader :status, :log_file, :stdout, :stderr, :reason_for_failure, :return_code, :pid, :start_time, :end_time |
#stdout ⇒ Object
Get stdout of the command
38 |
# File 'lib/command_exec/process.rb', line 38 attr_reader :status, :log_file, :stdout, :stderr, :reason_for_failure, :return_code, :pid, :start_time, :end_time |
Instance Method Details
#run_time ⇒ Object
203 204 205 |
# File 'lib/command_exec/process.rb', line 203 def run_time end_time - start_time end |
#to_a(fields = default_fields, formatter = Formatter::Array.new) ⇒ Object
Output process data as array
234 235 236 |
# File 'lib/command_exec/process.rb', line 234 def to_a(fields=default_fields, formatter=Formatter::Array.new) output(fields, formatter) end |
#to_h(fields = default_fields, formatter = Formatter::Hash.new) ⇒ Object
Output process data as hash
245 246 247 |
# File 'lib/command_exec/process.rb', line 245 def to_h(fields=default_fields, formatter=Formatter::Hash.new) output(fields, formatter) end |
#to_json(fields = default_fields, formatter = Formatter::JSON.new) ⇒ Object
Output process data as json
278 279 280 |
# File 'lib/command_exec/process.rb', line 278 def to_json(fields=default_fields, formatter=Formatter::JSON.new) output(fields, formatter) end |
#to_s(fields = default_fields, formatter = Formatter::String.new) ⇒ Object
Output process data as string
256 257 258 |
# File 'lib/command_exec/process.rb', line 256 def to_s(fields=default_fields, formatter=Formatter::String.new) output(fields, formatter) end |
#to_xml(fields = default_fields, formatter = Formatter::XML.new) ⇒ Object
Output process data as xml
267 268 269 |
# File 'lib/command_exec/process.rb', line 267 def to_xml(fields=default_fields, formatter=Formatter::XML.new) output(fields, formatter) end |
#to_yaml(fields = default_fields, formatter = Formatter::YAML.new) ⇒ Object
Output process data as yaml
289 290 291 |
# File 'lib/command_exec/process.rb', line 289 def to_yaml(fields=default_fields, formatter=Formatter::YAML.new) output(fields, formatter) end |