Class: Lxc::CommandResult
- Inherits:
-
Object
- Object
- Lxc::CommandResult
- Defined in:
- lib/elecksee/helpers.rb
Overview
Result of command
Instance Attribute Summary collapse
-
#original ⇒ Object
readonly
Original result.
-
#stderr ⇒ IO
readonly
Stderr of command.
-
#stdout ⇒ IO
readonly
Stdout of command.
Instance Method Summary collapse
-
#extract_childprocess ⇒ Object
Extract information from childprocess result.
-
#extract_rye ⇒ Object
Extract information from rye result.
-
#extract_shellout ⇒ Object
Extract information from mixlib shellout result.
-
#initialize(result) ⇒ CommandResult
constructor
Create new instance.
Constructor Details
#initialize(result) ⇒ CommandResult
Create new instance
201 202 203 204 205 206 207 208 209 210 211 212 |
# File 'lib/elecksee/helpers.rb', line 201 def initialize(result) @original = result if(result.class.ancestors.map(&:to_s).include?('ChildProcess::AbstractProcess')) extract_childprocess elsif(result.class.to_s == 'Mixlib::ShellOut') extract_shellout elsif(result.class.to_s == 'Rye::Err' || result.class.to_s == 'Rye::Rap') extract_rye else raise TypeError.new("Unknown process result type received: #{result.class}") end end |
Instance Attribute Details
#original ⇒ Object (readonly)
Returns original result.
192 193 194 |
# File 'lib/elecksee/helpers.rb', line 192 def original @original end |
#stderr ⇒ IO (readonly)
Returns stderr of command.
196 197 198 |
# File 'lib/elecksee/helpers.rb', line 196 def stderr @stderr end |
#stdout ⇒ IO (readonly)
Returns stdout of command.
194 195 196 |
# File 'lib/elecksee/helpers.rb', line 194 def stdout @stdout end |
Instance Method Details
#extract_childprocess ⇒ Object
Extract information from childprocess result
215 216 217 218 219 220 221 222 |
# File 'lib/elecksee/helpers.rb', line 215 def extract_childprocess original.io.stdout.rewind original.io.stderr.rewind @stdout = original.io.stdout.read @stderr = original.io.stderr.read original.io.stdout.delete original.io.stderr.delete end |
#extract_rye ⇒ Object
Extract information from rye result
231 232 233 234 |
# File 'lib/elecksee/helpers.rb', line 231 def extract_rye @stdout = original.stdout.map(&:to_s).join("\n") @stderr = original.stderr.map(&:to_s).join("\n") end |
#extract_shellout ⇒ Object
Extract information from mixlib shellout result
225 226 227 228 |
# File 'lib/elecksee/helpers.rb', line 225 def extract_shellout @stdout = original.stdout @stderr = original.stderr end |