Class: TPS::CliReporter
- Inherits:
-
Object
- Object
- TPS::CliReporter
- Defined in:
- lib/tps/cli_reporter.rb
Instance Attribute Summary collapse
-
#task ⇒ Object
readonly
Returns the value of attribute task.
Instance Method Summary collapse
- #color ⇒ Object
-
#initialize(task) ⇒ CliReporter
constructor
A new instance of CliReporter.
- #points ⇒ Object
- #print ⇒ Object
- #progress ⇒ Object
- #report ⇒ Object
- #report_task ⇒ Object
- #status ⇒ Object
Constructor Details
#initialize(task) ⇒ CliReporter
Returns a new instance of CliReporter.
5 6 7 |
# File 'lib/tps/cli_reporter.rb', line 5 def initialize(task) @task = task end |
Instance Attribute Details
#task ⇒ Object (readonly)
Returns the value of attribute task.
3 4 5 |
# File 'lib/tps/cli_reporter.rb', line 3 def task @task end |
Instance Method Details
#color ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/tps/cli_reporter.rb', line 47 def color if task.done? 32 elsif task.in_progress? 34 else 30 end end |
#points ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/tps/cli_reporter.rb', line 39 def points [ "%3i" % [ task.points_done ], c("/", 30), c("%-2i" % [ task.points ], 32) ].join '' end |
#print ⇒ Object
9 10 11 |
# File 'lib/tps/cli_reporter.rb', line 9 def print puts report end |
#progress ⇒ Object
69 70 71 72 73 74 75 76 77 |
# File 'lib/tps/cli_reporter.rb', line 69 def progress max = 12 len = (task.percent * max).to_i prog = ("%-#{max}s" % ["="*len]) prog = c("❚"*len, color) + c("❘"*(max-len), 30) prog end |
#report ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/tps/cli_reporter.rb', line 13 def report re = "" task.walk do |t, recurse| re += CliReporter.new(t).report_task recurse.call if recurse end re end |
#report_task ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/tps/cli_reporter.rb', line 22 def report_task indent = ' ' * (4 * task.level) # Columns c1 = "%s %s %s" % [ indent, status, task.name ] c2 = if task.feature? || task.milestone? "%6s %s" % [ points, progress ] else ' '*19 end pref = c("━"*80, 30)+"\n" if task.feature? # Put together "#{pref}" + "%-88s%s\n" % [ c1, c2 ] end |
#status ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/tps/cli_reporter.rb', line 57 def status l = c("", 30) r = c(" ", 30) if task.done? l + c('✓', color) + r elsif task.in_progress? l + c('•', color) + r else l + c(' ', color) + r end end |