class Abt::Providers::Devops::BaseCommand
Attributes
config[R]
path[R]
Public Class Methods
new(ari:, cli:)
click to toggle source
Calls superclass method
Abt::BaseCommand::new
# File lib/abt/providers/devops/base_command.rb, line 13 def initialize(ari:, cli:) super @config = Configuration.new(cli: cli) @path = ari.path ? Path.new(ari.path) : config.path end
Private Instance Methods
api()
click to toggle source
# File lib/abt/providers/devops/base_command.rb, line 84 def api Api.new(organization_name: organization_name, username: config.username_for_organization(organization_name), access_token: config.access_token_for_organization(organization_name), cli: cli) end
board()
click to toggle source
# File lib/abt/providers/devops/base_command.rb, line 51 def board @board ||= begin api.get("#{project_name}/#{team_name}/_apis/work/boards/#{board_name}") rescue HttpError::NotFoundError nil end end
print_board(organization_name, project_name, team_name, board)
click to toggle source
# File lib/abt/providers/devops/base_command.rb, line 68 def print_board(organization_name, project_name, team_name, board) board_name = Api.rfc_3986_encode_path_segment(board["name"]) path = "#{organization_name}/#{project_name}/#{team_name}/#{board_name}" cli.print_ari("devops", path, board["name"]) warn(api.url_for_board(project_name, team_name, board)) if cli.output.isatty end
print_work_item(organization, project, team_name, board, work_item)
click to toggle source
# File lib/abt/providers/devops/base_command.rb, line 76 def print_work_item(organization, project, team_name, board, work_item) board_name = Api.rfc_3986_encode_path_segment(board["name"]) path = "#{organization}/#{project}/#{team_name}/#{board_name}/#{work_item['id']}" cli.print_ari("devops", path, work_item["name"]) warn(work_item["url"]) if work_item.key?("url") && cli.output.isatty end
prompt_board!()
click to toggle source
# File lib/abt/providers/devops/base_command.rb, line 39 def prompt_board! result = Services::BoardPicker.call(cli: cli, config: config) @path = result.path @board = result.board end
prompt_work_item!()
click to toggle source
# File lib/abt/providers/devops/base_command.rb, line 45 def prompt_work_item! result = Services::WorkItemPicker.call(cli: cli, path: path, config: config, board: board) @path = result.path @work_item = result.work_item end
require_board!()
click to toggle source
# File lib/abt/providers/devops/base_command.rb, line 26 def require_board! return if board_name && organization_name && project_name && team_name abort("No current/specified board. Did you forget to `pick`?") end
require_local_config!()
click to toggle source
# File lib/abt/providers/devops/base_command.rb, line 22 def require_local_config! abort("Must be run inside a git repository") unless config.local_available? end
require_work_item!()
click to toggle source
# File lib/abt/providers/devops/base_command.rb, line 32 def require_work_item! require_board! return if work_item_id abort("No current/specified work item. Did you forget to `pick`?") end
work_item()
click to toggle source
# File lib/abt/providers/devops/base_command.rb, line 59 def work_item @work_item ||= begin work_item = api.get_paged("_apis/wit/workitems", ids: work_item_id)[0] api.sanitize_work_item(work_item) rescue HttpError::NotFoundError nil end end