Class: FlightPlanCli::Commands::Ls
- Inherits:
-
Object
- Object
- FlightPlanCli::Commands::Ls
- Includes:
- FlightPlanCli::Config
- Defined in:
- lib/flight_plan_cli/commands/ls.rb
Constant Summary
Constants included from FlightPlanCli::Config
FlightPlanCli::Config::YAML_FILE
Instance Attribute Summary
Attributes included from FlightPlanCli::Config
#api_key, #api_secret, #api_url, #board_id, #default_swimlane_ids, #repo_id
Instance Method Summary collapse
-
#initialize ⇒ Ls
constructor
A new instance of Ls.
- #print_swimlane(swimlane) ⇒ Object
- #process ⇒ Object
- #tickets_by_swimlane ⇒ Object
Methods included from FlightPlanCli::Config
#client, #config, #read_config
Constructor Details
#initialize ⇒ Ls
Returns a new instance of Ls.
6 7 8 |
# File 'lib/flight_plan_cli/commands/ls.rb', line 6 def initialize read_config end |
Instance Method Details
#print_swimlane(swimlane) ⇒ Object
42 43 44 45 46 47 |
# File 'lib/flight_plan_cli/commands/ls.rb', line 42 def print_swimlane(swimlane) puts "#{swimlane['name']} (#{swimlane['tickets'].count})".green swimlane['tickets'].each do |ticket| puts "├── #{ticket['remote_number'].rjust(4)} : #{ticket['remote_title']}".yellow end end |
#process ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/flight_plan_cli/commands/ls.rb', line 10 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.}".red end |
#tickets_by_swimlane ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/flight_plan_cli/commands/ls.rb', line 24 def tickets_by_swimlane response = client.board_tickets(board_id: board_id, repo_id: repo_id) puts 'ok2' 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 |