Module: Story
- Included in:
- StoryAccept, StoryOpen, StoryPullRequest
- Defined in:
- lib/pivotal-github/story.rb
Instance Method Summary collapse
-
#delivered_ids(text) ⇒ Object
Returns the ids of delivered stories found in the given text.
-
#delivered_ids_since_last_pr(text) ⇒ Object
Returns the ids delivered since the last pull request.
- #fast_log_delivered_text ⇒ Object
-
#git_log_delivered_story_ids ⇒ Object
Returns the ids of delivered stories according to the Git log.
-
#pr_ids(text) ⇒ Object
Returns the ids included in previous pull requests.
-
#story_url(story_id) ⇒ Object
Returns the URL for the story at Pivotal Tracker.
Instance Method Details
#delivered_ids(text) ⇒ Object
Returns the ids of delivered stories found in the given text.
9 10 11 12 13 14 15 16 |
# File 'lib/pivotal-github/story.rb', line 9 def delivered_ids(text) delivered = text.scan(/\[Deliver(?:s|ed) (.*?)\]/).flatten # Handle multiple ids, i.e., '[Delivers #<id 1> #<id 2>]' delivered.inject([]) do |ids, element| ids.concat(element.scan(/[0-9]{8,}/).flatten) ids end.uniq end |
#delivered_ids_since_last_pr(text) ⇒ Object
Returns the ids delivered since the last pull request. We omit the ids of stories that have already been delivered by a particular pull request, so that each new PR is only tagged with stories delivered since the last PR.
34 35 36 |
# File 'lib/pivotal-github/story.rb', line 34 def delivered_ids_since_last_pr(text) delivered_ids(text) - pr_ids(text) end |
#fast_log_delivered_text ⇒ Object
26 27 28 |
# File 'lib/pivotal-github/story.rb', line 26 def fast_log_delivered_text @delivered_text ||= `git log -E --grep '\\[Deliver(s|ed) #'` end |
#git_log_delivered_story_ids ⇒ Object
Returns the ids of delivered stories according to the Git log. These ids are of the form [Delivers #<story id>] or [Delivers #<story id> #<another story id>]. The difference is handled by the delivered_ids method.
22 23 24 |
# File 'lib/pivotal-github/story.rb', line 22 def git_log_delivered_story_ids delivered_ids(fast_log_delivered_text).uniq end |
#pr_ids(text) ⇒ Object
Returns the ids included in previous pull requests.
39 40 41 |
# File 'lib/pivotal-github/story.rb', line 39 def pr_ids(text) text.scan(/\[Deliver(?:s|ed) #(.*?)\]\(https:\/\//).flatten.uniq end |
#story_url(story_id) ⇒ Object
Returns the URL for the story at Pivotal Tracker.
4 5 6 |
# File 'lib/pivotal-github/story.rb', line 4 def story_url(story_id) "https://www.pivotaltracker.com/story/show/#{story_id}" end |