Class: PivotalIntegration::Util::Story
- Inherits:
-
Object
- Object
- PivotalIntegration::Util::Story
- Defined in:
- lib/pivotal-integration/util/story.rb
Overview
Utilities for dealing with PivotalTracker::Storys
Class Method Summary collapse
- .add_comment(story, comment) ⇒ Object
-
.assign(story, username) ⇒ void
Assign story to pivotal tracker member.
- .estimate(story, points) ⇒ Object
-
.mark(story, state) ⇒ void
Marks Pivotal Tracker story with given state.
- .new(project, name, type) ⇒ Object
-
.pretty_print(story) ⇒ void
Print a human readable version of a story.
-
.select_story(project, filter = nil, limit = 5) ⇒ PivotalTracker::Story
Selects a Pivotal Tracker story by doing the following steps:.
Class Method Details
.add_comment(story, comment) ⇒ Object
87 88 89 |
# File 'lib/pivotal-integration/util/story.rb', line 87 def self.add_comment(story, comment) story.notes.create(text: comment) end |
.assign(story, username) ⇒ void
This method returns an undefined value.
Assign story to pivotal tracker member.
70 71 72 |
# File 'lib/pivotal-integration/util/story.rb', line 70 def self.assign(story, username) puts "Story assigned to #{username}" if story.update(owned_by: username) end |
.estimate(story, points) ⇒ Object
83 84 85 |
# File 'lib/pivotal-integration/util/story.rb', line 83 def self.estimate(story, points) story.update(estimate: points) end |
.mark(story, state) ⇒ void
This method returns an undefined value.
Marks Pivotal Tracker story with given state
79 80 81 |
# File 'lib/pivotal-integration/util/story.rb', line 79 def self.mark(story, state) puts "Changed state to #{state}" if story.update(current_state: state) end |
.new(project, name, type) ⇒ Object
23 24 25 |
# File 'lib/pivotal-integration/util/story.rb', line 23 def self.new(project, name, type) project.stories.create(name: name, story_type: type) end |
.pretty_print(story) ⇒ void
This method returns an undefined value.
Print a human readable version of a story. This pretty prints the title, description, and notes for the story.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/pivotal-integration/util/story.rb', line 32 def self.pretty_print(story) print_label 'ID' print_value story.id print_label 'Project' print_value PivotalTracker::Project.find(story.project_id).account print_label LABEL_TITLE print_value story.name description = story.description if !description.nil? && !description.empty? print_label 'Description' print_value description end print_label 'Type' print_value story.story_type.titlecase print_label 'State' print_value story.current_state.titlecase print_label 'Estimate' print_value story.estimate == -1 ? 'Unestimated' : story.estimate PivotalTracker::Note.all(story).sort_by { |note| note.noted_at }.each_with_index do |note, index| print_label "Note #{index + 1}" print_value note.text end puts end |
.select_story(project, filter = nil, limit = 5) ⇒ PivotalTracker::Story
Selects a Pivotal Tracker story by doing the following steps:
101 102 103 104 105 106 107 108 109 |
# File 'lib/pivotal-integration/util/story.rb', line 101 def self.select_story(project, filter = nil, limit = 5) if filter =~ /[[:digit:]]/ story = project.stories.find filter.to_i else story = find_story project, filter, limit end story end |