class Startling::WorkPrinter

Public Instance Methods

ago(time) click to toggle source
# File lib/startling/work_printer.rb, line 30
def ago(time)
  business_time_ago(time).yellow
end
count(works) click to toggle source
# File lib/startling/work_printer.rb, line 34
def count(works)
  count = works.count

  if count > Startling.wip_limit
    count.to_s.red
  elsif count == Startling.wip_limit
    count.to_s.yellow
  else
    count.to_s.blue
  end
end
format_pull_request(pull_request) click to toggle source
# File lib/startling/work_printer.rb, line 15
def format_pull_request(pull_request)
  "#{format_pull_request_labels(pull_request)}#{pull_request.title}\n" +
    "  Started #{ago pull_request.created_at}, last updated #{ago pull_request.updated_at}\n" +
    "  #{pull_request.url.cyan.underline}"
end
format_work(work) click to toggle source
# File lib/startling/work_printer.rb, line 21
def format_work(work)
  "#{work.authors.join(", ").green} - #{work.branch.to_s.yellow}\n".yellow +
    indent(work.pull_requests.sort_by(&:created_at).map { |p| format_pull_request(p) }.join("\n"))
end
indent(string) click to toggle source
# File lib/startling/work_printer.rb, line 26
def indent(string)
  string.split("\n").map {|s| "  #{s}"}.join("\n")
end
print(works) click to toggle source

Private Instance Methods

format_pull_request_labels(pull_request) click to toggle source
# File lib/startling/work_printer.rb, line 47
def format_pull_request_labels(pull_request)
  labels = pull_request.labels.map do |label|
    Paint[label[:name], :black, label[:color]]
  end.join(" ")

  labels.empty? ? labels : labels.concat(" ")
end