Class: Sprinkle::Utility::LogRecorder

Inherits:
Object
  • Object
show all
Defined in:
lib/sprinkle/utility/log_recorder.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cmd = nil) ⇒ LogRecorder

Returns a new instance of LogRecorder.



7
8
9
# File 'lib/sprinkle/utility/log_recorder.rb', line 7

def initialize(cmd=nil)
  reset(cmd)
end

Instance Attribute Details

#codeObject

Returns the value of attribute code.



5
6
7
# File 'lib/sprinkle/utility/log_recorder.rb', line 5

def code
  @code
end

#commandObject

Returns the value of attribute command.



5
6
7
# File 'lib/sprinkle/utility/log_recorder.rb', line 5

def command
  @command
end

#errObject

Returns the value of attribute err.



5
6
7
# File 'lib/sprinkle/utility/log_recorder.rb', line 5

def err
  @err
end

#outObject

Returns the value of attribute out.



5
6
7
# File 'lib/sprinkle/utility/log_recorder.rb', line 5

def out
  @out
end

Instance Method Details

#hashObject

hash suitable to pass into a pretty failure details hash



19
20
21
# File 'lib/sprinkle/utility/log_recorder.rb', line 19

def hash
  {:error => err, :stdout => out, :command => command, :code => code}
end

#log(stream, data) ⇒ Object



11
12
13
14
15
16
# File 'lib/sprinkle/utility/log_recorder.rb', line 11

def log(stream, data)
  case stream
    when :err then @err << data
    when :out then @out << data
  end
end

#reset(cmd = nil) ⇒ Object



23
24
25
26
27
28
# File 'lib/sprinkle/utility/log_recorder.rb', line 23

def reset(cmd=nil)
  @command=cmd
  @code=nil
  @err=""
  @out=""        
end