Method: MakeRelease::Story#split_story

Defined in:
lib/make_release/story.rb

#split_story(description = @description) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/make_release/story.rb', line 15

def split_story( description = @description )
  raise RuntimeError 'description cannot be blank' unless description

  stories = []
  story_pattern = /\[?(((SRMPRT|OSMCLOUD)\-\d+)|NO-JIRA)\]?[,:\-\s]+\s*(.*)$/
  line = description.match(story_pattern)

  if line.nil? # did not find a JIRA ticket pattern
    stories.push 'NO-JIRA'
    desc = description.strip
  else
    stories.push line.captures[0]
    desc = line.captures[3].strip
  end

  # Perform recursion if there are multiple tickets in the description
  if desc =~ story_pattern
    new_story, new_desc = split_story desc
    stories.push new_story
    desc = new_desc
  end

  [stories.flatten, desc]
end