Sha256: e2dfc46ab2e45dd1f147c81eabc7ef0b35900ce5e36bdf0f208c544c6996d644
Contents?: true
Size: 1.78 KB
Versions: 1
Compression:
Stored size: 1.78 KB
Contents
module FlightPlanCli module Commands class Ls module Color SWIMLANE = :cyan ISSUE = :yellow ISSUE_NO = :red end include FlightPlanCli::Config def initialize read_config end def process swimlanes = tickets_by_swimlane default_swimlane_ids.each do |swimlane_id| next unless swimlanes.key?(swimlane_id) print_swimlane(swimlanes[swimlane_id]) end rescue ApiUnauthorized puts 'Unauthorize. Please ensure your key and secret as setup correctly'.red rescue Errno::ECONNREFUSED, SocketError => e # TODO: caching - low timeout (5s) then fallback to cache puts "Network error. #{e.message}".red end private def tickets_by_swimlane response = client.board_tickets raise ApiUnauthorized if response.code == 401 raise ApiNotFound if response.code == 404 swimlanes = {} response.each do |board_ticket| swimlane = board_ticket['swimlane'] next unless default_swimlane_ids.include? swimlane['id'] swimlanes[swimlane['id']] ||= swimlane swimlanes[swimlane['id']]['tickets'] ||= [] swimlanes[swimlane['id']]['tickets'] << board_ticket['ticket'] end swimlanes end def print_swimlane(swimlane) puts "#{swimlane['name']} (#{swimlane['tickets'].count})" .colorize(Color::SWIMLANE) swimlane['tickets'].each do |ticket| title = ticket['remote_title'] title = title.underline if git.head.name =~ /##{ticket['remote_number']}[^0-9]/ print " #{ticket['remote_number']} ".colorize(Color::ISSUE_NO) puts title.colorize(Color::ISSUE) end puts end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
flight_plan_cli-0.2.6 | lib/flight_plan_cli/commands/ls.rb |