class TPS::CliReporter
Attributes
task[R]
Public Class Methods
new(task)
click to toggle source
# File lib/tps/cli_reporter.rb, line 5 def initialize(task) @task = task end
Public Instance Methods
color()
click to toggle source
# File lib/tps/cli_reporter.rb, line 47 def color if task.done? 32 elsif task.in_progress? 34 else 30 end end
points()
click to toggle source
# File lib/tps/cli_reporter.rb, line 39 def points [ "%3i" % [ task.points_done ], c("/", 30), c("%-2i" % [ task.points ], 32) ].join '' end
print()
click to toggle source
# File lib/tps/cli_reporter.rb, line 9 def print puts report end
progress()
click to toggle source
# 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()
click to toggle source
# 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()
click to toggle source
# 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()
click to toggle source
# 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
Private Instance Methods
c(str, c=nil)
click to toggle source
# File lib/tps/cli_reporter.rb, line 80 def c(str, c=nil) c ? "\033[#{c}m#{str}\033[0m" : str end