Class: Jira::Auto::Tool::Performer::SprintRenamer

Inherits:
PrefixSprintUpdater show all
Defined in:
lib/jira/auto/tool/performer/sprint_renamer.rb,
lib/jira/auto/tool/performer/sprint_renamer/next_name_generator.rb,
lib/jira/auto/tool/performer/sprint_renamer/keep_same_name_generator.rb

Direct Known Subclasses

QuarterlySprintRenamer

Defined Under Namespace

Classes: KeepSameNameGenerator, NextNameGenerator

Instance Attribute Summary collapse

Attributes inherited from PrefixSprintUpdater

#tool

Instance Method Summary collapse

Methods inherited from PrefixSprintUpdater

#first_sprint_to_act_on?, #run, #sprint_prefixes

Constructor Details

#initialize(tool, from_string, to_string) ⇒ SprintRenamer

Returns a new instance of SprintRenamer.



15
16
17
18
19
20
# File 'lib/jira/auto/tool/performer/sprint_renamer.rb', line 15

def initialize(tool, from_string, to_string)
  super(tool)

  @from_string_regex = Regexp.new(Regexp.escape(from_string))
  @to_string = to_string
end

Instance Attribute Details

#from_string_regexObject (readonly)

Returns the value of attribute from_string_regex.



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

def from_string_regex
  @from_string_regex
end

#to_stringObject (readonly)

Returns the value of attribute to_string.



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

def to_string
  @to_string
end

Instance Method Details

#act_on_sprints_for_sprint_prefix(sprint_prefix) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/jira/auto/tool/performer/sprint_renamer.rb', line 22

def act_on_sprints_for_sprint_prefix(sprint_prefix)
  prefix_sprints = sprint_prefix.sprints

  new_sprint_names = calculate_sprint_new_names(prefix_sprints.collect(&:name))

  prefix_sprints.zip(new_sprint_names).each do |sprint, new_sprint_name|
    sprint.rename_to(new_sprint_name)
  end
end

#calculate_sprint_new_names(sprint_names) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/jira/auto/tool/performer/sprint_renamer.rb', line 32

def calculate_sprint_new_names(sprint_names)
  name_generator = Performer::SprintRenamer::KeepSameNameGenerator.new

  sprint_names.collect do |sprint_name|
    if first_sprint_to_act_on?(sprint_name)
      sprint_new_name = sprint_name.sub(from_string_regex, to_string)

      name_generator = next_sprint_name_generator_class.new(sprint_name, sprint_new_name)

      sprint_new_name
    else
      name_generator.name_for(sprint_name)
    end
  end
end

#next_sprint_name_generator_classObject



48
49
50
# File 'lib/jira/auto/tool/performer/sprint_renamer.rb', line 48

def next_sprint_name_generator_class
  NextNameGenerator
end