Class: Jira::Auto::Tool::Performer::QuarterlySprintRenamer::NextNameGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/jira/auto/tool/performer/quarterly_sprint_renamer/next_name_generator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(original_name_of_first_renamed_sprint, name_of_first_renamed_sprint) ⇒ NextNameGenerator

Returns a new instance of NextNameGenerator.



13
14
15
16
# File 'lib/jira/auto/tool/performer/quarterly_sprint_renamer/next_name_generator.rb', line 13

def initialize(original_name_of_first_renamed_sprint, name_of_first_renamed_sprint)
  @original_name_of_first_renamed_sprint = Sprint::Name.parse(original_name_of_first_renamed_sprint)
  @name_of_first_renamed_sprint = Sprint::Name.parse(name_of_first_renamed_sprint)
end

Instance Attribute Details

#name_of_first_renamed_sprintObject (readonly)

Returns the value of attribute name_of_first_renamed_sprint.



11
12
13
# File 'lib/jira/auto/tool/performer/quarterly_sprint_renamer/next_name_generator.rb', line 11

def name_of_first_renamed_sprint
  @name_of_first_renamed_sprint
end

#original_name_of_first_renamed_sprintObject (readonly)

Returns the value of attribute original_name_of_first_renamed_sprint.



11
12
13
# File 'lib/jira/auto/tool/performer/quarterly_sprint_renamer/next_name_generator.rb', line 11

def original_name_of_first_renamed_sprint
  @original_name_of_first_renamed_sprint
end

Instance Method Details

#name_for(sprint_name) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/jira/auto/tool/performer/quarterly_sprint_renamer/next_name_generator.rb', line 18

def name_for(sprint_name)
  if outside_planning_interval_of_sprint_next_to_first_renamed_sprint?(sprint_name)
    sprint_name
  else
    next_name_in_planning_interval
  end
end

#new_name_of_sprint_next_to_first_renamed_sprintObject



26
27
28
29
30
31
32
33
# File 'lib/jira/auto/tool/performer/quarterly_sprint_renamer/next_name_generator.rb', line 26

def new_name_of_sprint_next_to_first_renamed_sprint
  @new_name_of_sprint_next_to_first_renamed_sprint ||=
    if pulling_sprint_into_previous_planning_interval?
      original_name_of_first_renamed_sprint
    else
      name_of_first_renamed_sprint.next_in_planning_interval
    end
end

#next_name_in_planning_intervalObject



35
36
37
38
39
40
41
42
43
# File 'lib/jira/auto/tool/performer/quarterly_sprint_renamer/next_name_generator.rb', line 35

def next_name_in_planning_interval
  @next_name_in_planning_interval ||= new_name_of_sprint_next_to_first_renamed_sprint

  next_name = @next_name_in_planning_interval.to_s

  @next_name_in_planning_interval = @next_name_in_planning_interval.next_in_planning_interval

  next_name
end

#outside_planning_interval_of_sprint_next_to_first_renamed_sprint?(sprint_name) ⇒ Boolean

Returns:

  • (Boolean)


51
52
53
54
# File 'lib/jira/auto/tool/performer/quarterly_sprint_renamer/next_name_generator.rb', line 51

def outside_planning_interval_of_sprint_next_to_first_renamed_sprint?(sprint_name)
  new_name_of_sprint_next_to_first_renamed_sprint.planning_interval !=
    Sprint::Name.parse(sprint_name).planning_interval
end

#pulling_sprint_into_previous_planning_interval?Boolean

Returns:

  • (Boolean)


45
46
47
48
49
# File 'lib/jira/auto/tool/performer/quarterly_sprint_renamer/next_name_generator.rb', line 45

def pulling_sprint_into_previous_planning_interval?
  (name_of_first_renamed_sprint.planning_interval <=>
    original_name_of_first_renamed_sprint.planning_interval)
    .negative?
end