class MakeRelease::Story
Attributes
sha[R]
Public Class Methods
new( story )
click to toggle source
# File lib/make_release/story.rb, line 4 def initialize( story ) unless story =~ /\S+|\S+/ raise ArgumentError, "story must follow 'SHA|description' format" end @sha, @description = story.split('|') raise ArgumentError if @sha.nil? || @description.nil? end
Public Instance Methods
desc()
click to toggle source
# File lib/make_release/story.rb, line 44 def desc (split_story)[1] end
split_story( description = @description )
click to toggle source
# 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
tickets()
click to toggle source
# File lib/make_release/story.rb, line 40 def tickets (split_story)[0] end
to_s()
click to toggle source
# File lib/make_release/story.rb, line 48 def to_s '[%07.07s] %s - %s' % [sha, tickets.join(', '), desc] end