Class: Jira::Auto::Tool::TeamSprintPrefixMapper
- Inherits:
-
Object
- Object
- Jira::Auto::Tool::TeamSprintPrefixMapper
show all
- Defined in:
- lib/jira/auto/tool/team_sprint_prefix_mapper.rb,
lib/jira/auto/tool/team_sprint_prefix_mapper/options.rb
Defined Under Namespace
Classes: NoMatchingSprintPrefixError, NoMatchingTeamError, Options
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of TeamSprintPrefixMapper.
15
16
17
18
|
# File 'lib/jira/auto/tool/team_sprint_prefix_mapper.rb', line 15
def initialize(teams, sprint_prefixes)
@sprint_prefixes = sprint_prefixes
@teams = teams
end
|
Instance Attribute Details
#sprint_prefixes ⇒ Object
Returns the value of attribute sprint_prefixes.
13
14
15
|
# File 'lib/jira/auto/tool/team_sprint_prefix_mapper.rb', line 13
def sprint_prefixes
@sprint_prefixes
end
|
Returns the value of attribute teams.
13
14
15
|
# File 'lib/jira/auto/tool/team_sprint_prefix_mapper.rb', line 13
def teams
@teams
end
|
Instance Method Details
#fetch_for(team_name) ⇒ Object
32
33
34
|
# File 'lib/jira/auto/tool/team_sprint_prefix_mapper.rb', line 32
def fetch_for(team_name)
team_sprint_prefix_mappings[team_name]
end
|
#fetch_for!(team_name) ⇒ Object
36
37
38
39
40
|
# File 'lib/jira/auto/tool/team_sprint_prefix_mapper.rb', line 36
def fetch_for!(team_name)
fetch_for(team_name) or
raise NoMatchingSprintPrefixError,
no_matching_sprint_prefix_for_team_message(team_name)
end
|
#list_mappings ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/jira/auto/tool/team_sprint_prefix_mapper.rb', line 20
def list_mappings
table = Terminal::Table.new(
title: "Team Sprint Mappings",
headings: ["Team", "Sprint Prefix"],
rows: teams.collect do |team|
[team, team_sprint_prefix_mappings.fetch(team, "!!__no matching sprint prefix__!!")]
end
)
puts table
end
|
#map_prefix_name_to_team_name(prefix_name) ⇒ Object
50
51
52
53
54
|
# File 'lib/jira/auto/tool/team_sprint_prefix_mapper.rb', line 50
def map_prefix_name_to_team_name(prefix_name)
sub_team_in_prefix = prefix_name.split(Sprint::Name::SPRINT_PREFIX_SEPARATOR).last
teams.find { |team| team.end_with?(sub_team_in_prefix) }
end
|
#no_matching_sprint_prefix_for_team_message(team_name) ⇒ Object
56
57
58
|
# File 'lib/jira/auto/tool/team_sprint_prefix_mapper.rb', line 56
def no_matching_sprint_prefix_for_team_message(team_name)
"No matching sprint prefix for team '#{team_name}' in #{team_sprint_prefix_mappings.inspect}"
end
|
#team_sprint_prefix_mappings ⇒ Object
42
43
44
45
46
47
48
|
# File 'lib/jira/auto/tool/team_sprint_prefix_mapper.rb', line 42
def team_sprint_prefix_mappings
@team_sprint_prefix_mappings ||=
sprint_prefixes.collect(&:name).each_with_object({}) do |prefix_name, mappings|
found_team = map_prefix_name_to_team_name(prefix_name)
mappings[prefix_name] = found_team if found_team
end.invert
end
|