Module: ChoreDisplay
- Defined in:
- lib/chore/server.rb
Overview
Provide colorized text output for the CLI interface.
Instance Method Summary collapse
Instance Method Details
#colorize(str, color) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/chore/server.rb', line 30 def colorize str, color color_code = case color when :red then 31 when :green then 32 when :yellow then 33 else raise "BAD COLOR #{str} #{color}" end "\033[#{color_code}m#{str}\033[0m" end |
#receive_data(data) ⇒ Object
53 54 55 56 |
# File 'lib/chore/server.rb', line 53 def receive_data(data) send_data(text_statuses) close_connection_after_writing end |
#text_statuses ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/chore/server.rb', line 40 def text_statuses status_lines = [] Chore::Store.iterate_statuses do |status| status_line = "#{status[:job]} - #{status[:status]} #{Time.at(status[:start_time])}" status_line += " (#{status[:notes].join(', ')})" if !status[:notes].empty? status_lines << colorize(status_line, status[:state]) end status_lines.join("\n") + "\n" end |