Class: Plywood::FancyLogger::FancyLog
- Inherits:
-
Object
- Object
- Plywood::FancyLogger::FancyLog
- Defined in:
- lib/plywood/fancy_logger/fancy_log.rb
Instance Attribute Summary collapse
-
#exit_status ⇒ Object
Returns the value of attribute exit_status.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
Instance Method Summary collapse
- #add_line(stream) ⇒ Object
- #icon ⇒ Object
-
#initialize(name) ⇒ FancyLog
constructor
A new instance of FancyLog.
- #running? ⇒ Boolean
- #status ⇒ Object
- #success? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(name) ⇒ FancyLog
Returns a new instance of FancyLog.
8 9 10 11 12 |
# File 'lib/plywood/fancy_logger/fancy_log.rb', line 8 def initialize(name) @name = name @exit_status = nil @output = Concurrent::Array.new end |
Instance Attribute Details
#exit_status ⇒ Object
Returns the value of attribute exit_status.
6 7 8 |
# File 'lib/plywood/fancy_logger/fancy_log.rb', line 6 def exit_status @exit_status end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/plywood/fancy_logger/fancy_log.rb', line 6 def name @name end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
6 7 8 |
# File 'lib/plywood/fancy_logger/fancy_log.rb', line 6 def output @output end |
Instance Method Details
#add_line(stream) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/plywood/fancy_logger/fancy_log.rb', line 14 def add_line(stream) raise "Process exited" unless exit_status.nil? stream.gets.each_line do |line| @output << [(stream.err? ? :stderr : :stdout), line] end self end |
#icon ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/plywood/fancy_logger/fancy_log.rb', line 46 def icon case exit_status when nil then "⏵" when 0 then "✔" else "‼" end end |
#running? ⇒ Boolean
26 27 28 |
# File 'lib/plywood/fancy_logger/fancy_log.rb', line 26 def running? @exit_status.nil? end |
#status ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/plywood/fancy_logger/fancy_log.rb', line 38 def status case exit_status when nil then "running" when 0 then "success" else "failed (#{exit_status})" end end |
#success? ⇒ Boolean
30 31 32 |
# File 'lib/plywood/fancy_logger/fancy_log.rb', line 30 def success? @exit_status&.zero? end |
#to_s ⇒ Object
34 35 36 |
# File 'lib/plywood/fancy_logger/fancy_log.rb', line 34 def to_s "#{icon} #{name} | #{status}" end |