class Tempo::Views::Formatters::Screen
Public Instance Methods
active_indicator(project)
click to toggle source
spacer for project titles, active project marked with *
# File lib/tempo/views/formatters/screen.rb, line 36 def active_indicator(project) indicator = project.current ? "* " : " " end
duration_block(record)
click to toggle source
# File lib/tempo/views/formatters/screen.rb, line 27 def duration_block(record) record.format do |d| puts "#{ d.hours.to_s }:#{ d.minutes.to_s.rjust(2, '0') }" end end
id_partial(id)
click to toggle source
# File lib/tempo/views/formatters/screen.rb, line 54 def id_partial(id) @options[:id] ? "[#{id}] ".rjust(6, ' ') : "" end
message_block(record)
click to toggle source
# File lib/tempo/views/formatters/screen.rb, line 15 def message_block(record) record.format do |m| case m.category when :error raise m.message when :info, :warning, :debug puts m.message end m.message end end
project_block(record)
click to toggle source
PARTIALS ^^—————————————————————–^^
# File lib/tempo/views/formatters/screen.rb, line 61 def project_block(record) record.format do |r| @options[:active] = @options.fetch( :active, false ) record = r.title id = id_partial r.id active = @options[:active] ? active_indicator( r ) : "" depth = @options[:depth] ? " " * r.depth : "" title = r.title view = "#{id}#{active}#{depth}#{title}" tags = @options[:tags] ? tag_partial( r.tags, view.length ) : "" view += tags puts view end end
tag_partial(tags, title_length)
click to toggle source
# File lib/tempo/views/formatters/screen.rb, line 40 def tag_partial(tags, title_length) max_length = ViewRecords::Project.max_title_length max_length += ViewRecords::Project.max_depth * 2 if @options[:depth] max_length += 6 if @options[:id] max_length += 2 if @options[:active] spacer = [0, max_length - title_length].max view = " " + ( " " * spacer ) return view + "tags: none" if tags.length < 1 view += "tags: [" tags.each { |t| view += "#{t}, "} view[0..-3] + "]" end
timerecord_block(record)
click to toggle source
# File lib/tempo/views/formatters/screen.rb, line 78 def timerecord_block(record) #require 'pry'; binding.pry record.format do |r| id = id_partial r.id running = r.running ? "*" : " " if @options[:bullet_report] view = " * #{r.description}" else description = r.description.empty? ? "#{r.project}" : "#{r.project}: #{r.description}" view = "#{id}#{r.start_time.strftime('%H:%M')} - #{r.end_time.strftime('%H:%M')}#{running} [#{r.duration.format}] #{description}" end puts view end end