Sha256: b4ae7f55054cfadcf13b4e180dc916d8935cc7fe573b55849807603996737352
Contents?: true
Size: 982 Bytes
Versions: 2
Compression:
Stored size: 982 Bytes
Contents
require 'time' module Circle module CLI class Model TIME_FORMAT = '%-b %-e, %-l:%M %p' STATUS_COLORS = { green: %w(fixed success), yellow: %w(running retried not_run queued scheduled not_running no_tests), red: %w(canceled infrastructure_fail timedout failed) } attr_reader :attributes def initialize(attributes = {}) @attributes = attributes end def [](key) @attributes[key.to_s] end private def format_time(value) Time.parse(value).strftime(TIME_FORMAT) if value rescue ArgumentError end def color_for(value) case value when *STATUS_COLORS[:green] then :green when *STATUS_COLORS[:yellow] then :yellow when *STATUS_COLORS[:red] then :red else :blue end end def truncate(str, len = 50) str && str.length > len ? "#{str[0..(len - 4)]}..." : str end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
circle-cli-0.1.3 | lib/circle/cli/model.rb |
circle-cli-0.1.2 | lib/circle/cli/model.rb |