Class: Pv::Story
Instance Attribute Summary collapse
-
#current_state ⇒ Object
Returns the value of attribute current_state.
-
#description ⇒ Object
Returns the value of attribute description.
-
#estimate ⇒ Object
Returns the value of attribute estimate.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#owned_by ⇒ Object
Returns the value of attribute owned_by.
-
#pivotal_story ⇒ Object
readonly
Returns the value of attribute pivotal_story.
-
#requested_by ⇒ Object
Returns the value of attribute requested_by.
-
#story_type ⇒ Object
Returns the value of attribute story_type.
Class Method Summary collapse
-
.create(from_attributes = {}) ⇒ Object
Build a new Pivotal story with the given attributes.
-
.find(by_id) ⇒ Object
Find a story by its Pivotal ID.
Instance Method Summary collapse
-
#errors ⇒ Object
Show all errors related to this story.
-
#in_progress? ⇒ Boolean
This story is “in progress” if its code has not left the dev machine, or is on stage and hasn’t been pushed to production yet.
-
#initialize(from_pivotal_story) ⇒ Story
constructor
A new instance of Story.
-
#render ⇒ Object
Render this Story in plain text.
-
#saved? ⇒ Boolean
Test if this story has been saved on Pivotal.
-
#update(status) ⇒ Object
Update the current status of a Story.
-
#valid? ⇒ Boolean
Test if this story has any errors.
Constructor Details
#initialize(from_pivotal_story) ⇒ Story
Returns a new instance of Story.
9 10 11 12 13 14 |
# File 'lib/pv/story.rb', line 9 def initialize from_pivotal_story @pivotal_story = from_pivotal_story %w(id story_type requested_by owned_by current_state name description estimate).each do |attr| self.send "#{attr}=", from_pivotal_story.send(attr) end end |
Instance Attribute Details
#current_state ⇒ Object
Returns the value of attribute current_state.
5 6 7 |
# File 'lib/pv/story.rb', line 5 def current_state @current_state end |
#description ⇒ Object
Returns the value of attribute description.
5 6 7 |
# File 'lib/pv/story.rb', line 5 def description @description end |
#estimate ⇒ Object
Returns the value of attribute estimate.
5 6 7 |
# File 'lib/pv/story.rb', line 5 def estimate @estimate end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/pv/story.rb', line 5 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/pv/story.rb', line 5 def name @name end |
#owned_by ⇒ Object
Returns the value of attribute owned_by.
5 6 7 |
# File 'lib/pv/story.rb', line 5 def owned_by @owned_by end |
#pivotal_story ⇒ Object (readonly)
Returns the value of attribute pivotal_story.
7 8 9 |
# File 'lib/pv/story.rb', line 7 def pivotal_story @pivotal_story end |
#requested_by ⇒ Object
Returns the value of attribute requested_by.
5 6 7 |
# File 'lib/pv/story.rb', line 5 def requested_by @requested_by end |
#story_type ⇒ Object
Returns the value of attribute story_type.
5 6 7 |
# File 'lib/pv/story.rb', line 5 def story_type @story_type end |
Class Method Details
Instance Method Details
#errors ⇒ Object
Show all errors related to this story.
60 61 62 |
# File 'lib/pv/story.rb', line 60 def errors @pivotal_story.errors end |
#in_progress? ⇒ Boolean
This story is “in progress” if its code has not left the dev machine, or is on stage and hasn’t been pushed to production yet.
36 37 38 39 40 41 42 |
# File 'lib/pv/story.rb', line 36 def in_progress? if current_state =~ /\A(started|finished)\Z/ true else false end end |
#render ⇒ Object
Render this Story in plain text.
27 28 29 30 31 |
# File 'lib/pv/story.rb', line 27 def render source = IO.read "#{Pv.root}/lib/templates/story.txt.erb" template = ERB.new(source) template.result(binding) end |
#saved? ⇒ Boolean
Test if this story has been saved on Pivotal.
50 51 52 |
# File 'lib/pv/story.rb', line 50 def saved? Pv.tracker.project.stories.find(id).present? end |
#update(status) ⇒ Object
Update the current status of a Story.
45 46 47 |
# File 'lib/pv/story.rb', line 45 def update(status) @pivotal_story.update(current_state: status) end |
#valid? ⇒ Boolean
Test if this story has any errors.
55 56 57 |
# File 'lib/pv/story.rb', line 55 def valid? errors.any? end |