Class: Rubsh::RunningPipeline

Inherits:
Object
  • Object
show all
Defined in:
lib/rubsh/running_pipeline.rb

Constant Summary collapse

SPECIAL_KWARGS =
%i[
  _in_data
  _in
  _out
  _err
  _err_to_out
  _capture
  _bg
  _env
  _timeout
  _cwd
  _ok_code
  _out_bufsize
  _err_bufsize
  _no_out
  _no_err
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sh) ⇒ RunningPipeline

Returns a new instance of RunningPipeline.



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/rubsh/running_pipeline.rb', line 41

def initialize(sh)
  @sh = sh
  @rcmds = []

  # Runtime
  @prog_with_args = nil
  @exit_code = nil
  @started_at = nil
  @finished_at = nil
  @stdout_data = "".force_encoding(::Encoding.default_external)
  @stderr_data = "".force_encoding(::Encoding.default_external)
  @in_rd = nil
  @in_wr = nil
  @out_rd = nil
  @out_wr = nil
  @err_rd = nil
  @err_wr = nil
  @out_rd_reader = nil
  @err_rd_reader = nil
  @waiters = []

  # Special Kwargs - Controlling Input/Output
  @_in_data = nil
  @_in = nil
  @_out = nil
  @_err = nil
  @_err_to_out = false
  @_capture = nil

  # Special Kwargs - Execution
  @_bg = false
  @_env = nil
  @_timeout = nil
  @_cwd = nil
  @_ok_code = [0]

  # Special Kwargs - Performance & Optimization
  @_out_bufsize = 0
  @_err_bufsize = 0
  @_no_out = false
  @_no_err = false
end

Instance Attribute Details

#exit_codeNumber (readonly)

Returns:

  • (Number)


23
24
25
# File 'lib/rubsh/running_pipeline.rb', line 23

def exit_code
  @exit_code
end

#finished_atTime (readonly)

Returns:

  • (Time)


31
32
33
# File 'lib/rubsh/running_pipeline.rb', line 31

def finished_at
  @finished_at
end

#started_atTime (readonly)

Returns:

  • (Time)


27
28
29
# File 'lib/rubsh/running_pipeline.rb', line 27

def started_at
  @started_at
end

#stderr_dataString (readonly)

Returns:

  • (String)


39
40
41
# File 'lib/rubsh/running_pipeline.rb', line 39

def stderr_data
  @stderr_data
end

#stdout_dataString (readonly)

Returns:

  • (String)


35
36
37
# File 'lib/rubsh/running_pipeline.rb', line 35

def stdout_data
  @stdout_data
end

Instance Method Details

#ok?Boolean

Returns:

  • (Boolean)


91
92
93
# File 'lib/rubsh/running_pipeline.rb', line 91

def ok?
  @_ok_code.include?(@exit_code)
end

#to_sString

Returns:

  • (String)


102
103
104
# File 'lib/rubsh/running_pipeline.rb', line 102

def to_s
  @prog_with_args
end

#wait(timeout: nil) ⇒ void

This method returns an undefined value.



96
97
98
99
# File 'lib/rubsh/running_pipeline.rb', line 96

def wait(timeout: nil)
  wait2(timeout: timeout)
  handle_return_code
end

#wall_timeNumeric? Also known as: execution_time

Returns:

  • (Numeric, nil)


85
86
87
# File 'lib/rubsh/running_pipeline.rb', line 85

def wall_time
  @finished_at.nil? ? nil : @finished_at - @started_at
end