Class: Abt::Providers::Devops::Path
- Inherits:
-
String
- Object
- String
- Abt::Providers::Devops::Path
- 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
- TEAM_NAME_REGEX =
%r{(?<team_name>[^/ ]+)}.freeze
- BOARD_NAME_REGEX =
%r{(?<board_name>[^/ ]+)}.freeze
- WORK_ITEM_ID_REGEX =
/(?<work_item_id>\d+)/.freeze
- PATH_REGEX =
%r{^(#{ORGANIZATION_NAME_REGEX}/#{PROJECT_NAME_REGEX}(/#{TEAM_NAME_REGEX}(/#{BOARD_NAME_REGEX}(/#{WORK_ITEM_ID_REGEX})?)?)?)?}.freeze
Class Method Summary collapse
Instance Method Summary collapse
- #board_name ⇒ Object
-
#initialize(path = "") ⇒ Path
constructor
A new instance of Path.
- #organization_name ⇒ Object
- #project_name ⇒ Object
- #team_name ⇒ Object
- #work_item_id ⇒ Object
Constructor Details
#initialize(path = "") ⇒ Path
Returns a new instance of Path.
33 34 35 36 37 |
# File 'lib/abt/providers/devops/path.rb', line 33 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, team_name: nil, board_name: nil, work_item_id: nil) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/abt/providers/devops/path.rb', line 16 def self.from_ids(organization_name: nil, project_name: nil, team_name: nil, board_name: nil, work_item_id: nil) return new unless organization_name && project_name parts = [organization_name, project_name] if team_name parts << team_name if board_name parts << board_name parts << work_item_id if work_item_id end end new(parts.join("/")) end |
Instance Method Details
#board_name ⇒ Object
51 52 53 |
# File 'lib/abt/providers/devops/path.rb', line 51 def board_name match[:board_name] end |
#organization_name ⇒ Object
39 40 41 |
# File 'lib/abt/providers/devops/path.rb', line 39 def organization_name match[:organization_name] end |
#project_name ⇒ Object
43 44 45 |
# File 'lib/abt/providers/devops/path.rb', line 43 def project_name match[:project_name] end |
#team_name ⇒ Object
47 48 49 |
# File 'lib/abt/providers/devops/path.rb', line 47 def team_name match[:team_name] end |
#work_item_id ⇒ Object
55 56 57 |
# File 'lib/abt/providers/devops/path.rb', line 55 def work_item_id match[:work_item_id] end |