Class: Zio::UpLogger
- Inherits:
-
Object
- Object
- Zio::UpLogger
- Includes:
- Celluloid, Celluloid::Notifications
- Defined in:
- lib/zio/up.rb
Instance Attribute Summary collapse
-
#out ⇒ Object
Returns the value of attribute out.
-
#paths ⇒ Object
Returns the value of attribute paths.
Instance Method Summary collapse
-
#initialize ⇒ UpLogger
constructor
A new instance of UpLogger.
- #new_data(_topic, data) ⇒ Object
- #print ⇒ Object
- #set_paths(_topic, data) ⇒ Object
Constructor Details
#initialize ⇒ UpLogger
Returns a new instance of UpLogger.
11 12 13 14 15 16 |
# File 'lib/zio/up.rb', line 11 def initialize subscribe 'up_paths', :set_paths subscribe 'up_capture_complete', :new_data @out = [] @paths = [1] end |
Instance Attribute Details
#out ⇒ Object
Returns the value of attribute out.
9 10 11 |
# File 'lib/zio/up.rb', line 9 def out @out end |
#paths ⇒ Object
Returns the value of attribute paths.
9 10 11 |
# File 'lib/zio/up.rb', line 9 def paths @paths end |
Instance Method Details
#new_data(_topic, data) ⇒ Object
18 19 20 |
# File 'lib/zio/up.rb', line 18 def new_data(_topic, data) @out << data end |
#print ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/zio/up.rb', line 26 def print while paths.size > 0 do if out.empty? sleep 2 next end data = out.shift path, stdout, stderr, status = *data dirname = path.split('/').last puts sprintf("\nProcessing - #{dirname}").color(:green) puts sprintf('---------------------------').color(:green) if status.exitstatus == 0 puts sprintf('[%s] - %s', dirname, stdout).color(:blue) else STDERR.puts stderr.color(:red) end paths.delete(path) paths.delete(1) if paths.size == 1 && paths[0] == 1 end end |
#set_paths(_topic, data) ⇒ Object
22 23 24 |
# File 'lib/zio/up.rb', line 22 def set_paths(_topic, data) @paths.concat(data) end |