Class: WestAreteTrackerTools::Story
- Inherits:
-
Object
- Object
- WestAreteTrackerTools::Story
- Includes:
- ActiveModel::Validations
- Defined in:
- lib/westarete-tracker-tools/story.rb
Overview
Represents a story in tracker.
Constant Summary collapse
- RISK_REGEXP =
/(\s*\[\s*(G|PG|PG\-?13|R|X)\s*\]\s*)/i
Instance Attribute Summary collapse
-
#tracker_story ⇒ Object
readonly
Returns the value of attribute tracker_story.
Instance Method Summary collapse
-
#accepted_at ⇒ Object
When was this story accepted?.
-
#bug? ⇒ Boolean
Is this story a bug?.
-
#chore? ⇒ Boolean
Is this story a chore?.
-
#comments ⇒ Object
Return all notes in chronological order.
-
#complete? ⇒ Boolean
Is this story complete?.
-
#current_state ⇒ Object
Return a string that describes the story’s current state.
-
#description ⇒ Object
Return the description for this story.
-
#feature? ⇒ Boolean
Is this story a feature?.
-
#finished? ⇒ Boolean
Is this story in a state of being finished, delivered, or rejected?.
-
#incomplete? ⇒ Boolean
Is this story incomplete?.
-
#initialize(tracker_story) ⇒ Story
constructor
A new instance of Story.
-
#name ⇒ Object
Return the name of this story.
-
#owner ⇒ Object
Return the full name of the story’s owner.
-
#points ⇒ Object
Return the point estimate for this story.
-
#price ⇒ Object
Determined by the most recent comment by Scott that mentions cost or price and a dollar amount.
-
#release? ⇒ Boolean
Is this story a release?.
-
#requester ⇒ Object
Return the Requester object for.
-
#risk ⇒ Object
Return the risk rating for this story.
-
#story_type ⇒ Object
Return the type (of type string) for this story.
-
#tracker_id ⇒ Object
The id in tracker for this story.
-
#url ⇒ Object
Return the web URL for viewing this story.
Constructor Details
#initialize(tracker_story) ⇒ Story
Returns a new instance of Story.
18 19 20 |
# File 'lib/westarete-tracker-tools/story.rb', line 18 def initialize(tracker_story) @tracker_story = tracker_story end |
Instance Attribute Details
#tracker_story ⇒ Object (readonly)
Returns the value of attribute tracker_story.
14 15 16 |
# File 'lib/westarete-tracker-tools/story.rb', line 14 def tracker_story @tracker_story end |
Instance Method Details
#accepted_at ⇒ Object
When was this story accepted?
23 24 25 |
# File 'lib/westarete-tracker-tools/story.rb', line 23 def accepted_at @tracker_story.accepted_at end |
#bug? ⇒ Boolean
Is this story a bug?
28 29 30 |
# File 'lib/westarete-tracker-tools/story.rb', line 28 def bug? story_type == 'bug' end |
#chore? ⇒ Boolean
Is this story a chore?
33 34 35 |
# File 'lib/westarete-tracker-tools/story.rb', line 33 def chore? story_type == 'chore' end |
#comments ⇒ Object
Return all notes in chronological order.
38 39 40 |
# File 'lib/westarete-tracker-tools/story.rb', line 38 def comments @comments ||= @tracker_story.notes.all.sort_by(&:noted_at) end |
#complete? ⇒ Boolean
Is this story complete?
43 44 45 |
# File 'lib/westarete-tracker-tools/story.rb', line 43 def complete? ! incomplete? end |
#current_state ⇒ Object
Return a string that describes the story’s current state.
48 49 50 |
# File 'lib/westarete-tracker-tools/story.rb', line 48 def current_state @tracker_story.current_state end |
#description ⇒ Object
Return the description for this story.
53 54 55 |
# File 'lib/westarete-tracker-tools/story.rb', line 53 def description @tracker_story.description end |
#feature? ⇒ Boolean
Is this story a feature?
58 59 60 |
# File 'lib/westarete-tracker-tools/story.rb', line 58 def feature? story_type == 'feature' end |
#finished? ⇒ Boolean
Is this story in a state of being finished, delivered, or rejected?
63 64 65 |
# File 'lib/westarete-tracker-tools/story.rb', line 63 def finished? %w(finished delivered rejected).include?(current_state) end |
#incomplete? ⇒ Boolean
Is this story incomplete?
68 69 70 |
# File 'lib/westarete-tracker-tools/story.rb', line 68 def incomplete? accepted_at.nil? end |
#name ⇒ Object
Return the name of this story.
73 74 75 |
# File 'lib/westarete-tracker-tools/story.rb', line 73 def name @tracker_story.name.gsub(RISK_REGEXP, '') end |
#owner ⇒ Object
Return the full name of the story’s owner.
78 79 80 |
# File 'lib/westarete-tracker-tools/story.rb', line 78 def owner @tracker_story.owned_by end |
#points ⇒ Object
Return the point estimate for this story.
83 84 85 86 87 |
# File 'lib/westarete-tracker-tools/story.rb', line 83 def points points = @tracker_story.estimate points = nil if points && points < 0 points end |
#price ⇒ Object
Determined by the most recent comment by Scott that mentions cost or price and a dollar amount.
90 91 92 93 94 95 96 97 98 99 |
# File 'lib/westarete-tracker-tools/story.rb', line 90 def price amount = nil comments.reverse.each do |comment| if comment. == 'Scott Woods' && comment.text =~ /(cost|price)[^\w].*\$([\d,]+)/i amount = $2.gsub(/,/, '').to_i break end end amount end |
#release? ⇒ Boolean
Is this story a release?
102 103 104 |
# File 'lib/westarete-tracker-tools/story.rb', line 102 def release? story_type == 'release' end |
#requester ⇒ Object
Return the Requester object for
107 108 109 |
# File 'lib/westarete-tracker-tools/story.rb', line 107 def requester @tracker_story.requested_by end |
#risk ⇒ Object
Return the risk rating for this story. It’s extracted from square braces at the beginning of the story name.
113 114 115 116 117 118 119 |
# File 'lib/westarete-tracker-tools/story.rb', line 113 def risk if @tracker_story.name =~ RISK_REGEXP $2.upcase else nil end end |
#story_type ⇒ Object
Return the type (of type string) for this story.
122 123 124 |
# File 'lib/westarete-tracker-tools/story.rb', line 122 def story_type @tracker_story.story_type end |
#tracker_id ⇒ Object
The id in tracker for this story.
127 128 129 |
# File 'lib/westarete-tracker-tools/story.rb', line 127 def tracker_id @tracker_story.id end |
#url ⇒ Object
Return the web URL for viewing this story.
132 133 134 |
# File 'lib/westarete-tracker-tools/story.rb', line 132 def url @tracker_story.url end |