Class: Abt::Providers::Devops::Path

Inherits:
String
  • Object
show all
Defined in:
lib/abt/providers/devops/path.rb

Constant Summary collapse

ORGANIZATION_NAME_REGEX =
%r{(?<organization_name>[^/ ]+)}.freeze
PROJECT_NAME_REGEX =
%r{(?<project_name>[^/ ]+)}.freeze
BOARD_ID_REGEX =
/(?<board_id>[a-z0-9\-]+)/.freeze
WORK_ITEM_ID_REGEX =
/(?<work_item_id>\d+)/.freeze
PATH_REGEX =
%r{^(#{ORGANIZATION_NAME_REGEX}/#{PROJECT_NAME_REGEX}(/#{BOARD_ID_REGEX}(/#{WORK_ITEM_ID_REGEX})?)?)?}.freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path = "") ⇒ Path

Returns a new instance of Path.

Raises:



21
22
23
24
25
# File 'lib/abt/providers/devops/path.rb', line 21

def initialize(path = "")
  raise Abt::Cli::Abort, "Invalid path: #{path}" unless PATH_REGEX.match?(path)

  super
end

Class Method Details

.from_ids(organization_name: nil, project_name: nil, board_id: nil, work_item_id: nil) ⇒ Object



15
16
17
18
19
# File 'lib/abt/providers/devops/path.rb', line 15

def self.from_ids(organization_name: nil, project_name: nil, board_id: nil, work_item_id: nil)
  return new unless organization_name && project_name && board_id

  new([organization_name, project_name, board_id, *work_item_id].join("/"))
end

Instance Method Details

#board_idObject



35
36
37
# File 'lib/abt/providers/devops/path.rb', line 35

def board_id
  match[:board_id]
end

#organization_nameObject



27
28
29
# File 'lib/abt/providers/devops/path.rb', line 27

def organization_name
  match[:organization_name]
end

#project_nameObject



31
32
33
# File 'lib/abt/providers/devops/path.rb', line 31

def project_name
  match[:project_name]
end

#work_item_idObject



39
40
41
# File 'lib/abt/providers/devops/path.rb', line 39

def work_item_id
  match[:work_item_id]
end