class FlightPlanCli::Commands::List

Public Instance Methods

process() click to toggle source
# File lib/flight_plan_cli/commands/list.rb, line 14
def process
  swimlanes = tickets_by_swimlane
  FlightPlanCli.settings.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 Instance Methods

git_current_branch() click to toggle source
# File lib/flight_plan_cli/commands/list.rb, line 67
def git_current_branch
  @git_current_branch ||= git.current_branch
end
print_swimlane(swimlane) click to toggle source
print_ticket(ticket) click to toggle source
tickets_by_swimlane() click to toggle source
# File lib/flight_plan_cli/commands/list.rb, line 30
def tickets_by_swimlane
  response = flight_plan.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 FlightPlanCli.settings.default_swimlane_ids.include? swimlane['id']

    swimlanes[swimlane['id']] ||= swimlane
    swimlanes[swimlane['id']]['tickets'] ||= []
    swimlanes[swimlane['id']]['tickets'] << board_ticket['ticket']
  end
  swimlanes
end