Class: Story
- Inherits:
-
Object
- Object
- Story
- Extended by:
- Rally::ParsingHelperClassMethods
- Includes:
- Mongoid::Document, Rally::ParsingHelpers
- Defined in:
- lib/story.rb
Class Method Summary collapse
Instance Method Summary collapse
- #actionable_children ⇒ Object
- #ancestors ⇒ Object
- #associate(hash_values = nil) ⇒ Object
- #epic ⇒ Object
- #has_children? ⇒ Boolean
- #parse_revisions_for_status_changes ⇒ Object
- #pull_revisions ⇒ Object
- #refresh(hash_values = nil) ⇒ Object
- #refresh_points ⇒ Object
- #revision_fields ⇒ Object
- #revision_history ⇒ Object
- #revision_parser ⇒ Object
- #status_changes ⇒ Object
- #update_parent ⇒ Object
Methods included from Rally::ParsingHelperClassMethods
from_uri, node_name, rally_query
Methods included from Rally::ParsingHelpers
Class Method Details
.accepted ⇒ Object
19 20 21 |
# File 'lib/story.rb', line 19 def accepted criteria.where(:schedule_state.in => ["Accepted", "Released"]) end |
.in_progress ⇒ Object
15 16 17 |
# File 'lib/story.rb', line 15 def in_progress criteria.where(:schedule_state.in => ["In-Progress", "Defined", "Completed"]) end |
.mmf ⇒ Object
11 12 13 |
# File 'lib/story.rb', line 11 def mmf criteria.where(:is_mmf => true) end |
.next ⇒ Object
23 24 25 |
# File 'lib/story.rb', line 23 def next criteria.where(:schedule_state => "Backlog") end |
.rally_uri ⇒ Object
7 8 9 |
# File 'lib/story.rb', line 7 def rally_uri "/hierarchicalrequirement.js" end |
Instance Method Details
#actionable_children ⇒ Object
79 80 81 82 83 84 85 86 87 88 |
# File 'lib/story.rb', line 79 def actionable_children children = self.children actionables= [] if children.size > 0 actionables << children.collect{|s| s.actionable_children} else actionables = [self] end actionables.flatten end |
#ancestors ⇒ Object
70 71 72 73 74 75 76 77 |
# File 'lib/story.rb', line 70 def ancestors if parent a = parent.ancestors << self return a else return [self] end end |
#associate(hash_values = nil) ⇒ Object
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
# File 'lib/story.rb', line 190 def associate hash_values=nil @rally_hash = hash_values || RallyAPI.get(self) if @rally_hash if @rally_hash["Project"] project = Project.find_or_create_by(:rally_uri => @rally_hash["Project"]["_ref"]) self.project = project end if @rally_hash["Iteration"] iteration = Iteration.find_or_create_by(:rally_uri => @rally_hash["Iteration"]["_ref"]) self.iteration = iteration end if @rally_hash["Parent"] story = Story.find_or_create_by(:rally_uri => @rally_hash["Parent"]["_ref"]) self.parent = story story.children << self story.save end self.save end rescue JSON::ParserError => e p e end |
#epic ⇒ Object
90 91 92 93 94 95 96 |
# File 'lib/story.rb', line 90 def epic if self.parent return parent.epic else return self end end |
#has_children? ⇒ Boolean
66 67 68 |
# File 'lib/story.rb', line 66 def has_children? self.children.count > 0 end |
#parse_revisions_for_status_changes ⇒ Object
123 124 125 126 127 128 129 130 |
# File 'lib/story.rb', line 123 def parse_revisions_for_status_changes if revision_parser revision_fields.each do |field| = revision_parser.send(field, revisions) self.send("#{field}=", ) end end end |
#pull_revisions ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/story.rb', line 144 def pull_revisions revision_history.refresh revision_uris = self.revisions.collect{|r| r.rally_uri} if revision_history.revisions revision_history.revisions.each do |rally_revision| unless revision_uris.include?(rally_revision.rally_uri) rally_revision.refresh self.revisions << rally_revision end end end self.parse_revisions_for_status_changes self.save end |
#refresh(hash_values = nil) ⇒ Object
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/story.rb', line 160 def refresh hash_values=nil @rally_hash = hash_values from_rally :rally_uri, :_ref from_rally :name from_rally :notes from_rally :is_mmf, :IsMMF from_rally :created_on, :CreationDate from_rally :description from_rally :formatted_id, :FormattedID from_rally :updated_on, :LastUpdateDate from_rally :accepted_on, :AcceptedDate from_rally :blocked from_rally :plan_estimate, :PlanEstimate from_rally :rank from_rally :size from_rally :schedule_state, :ScheduleState from_rally :requested_due_date, :RequestedDueDate from_rally :requested_by, :Requestor from_rally :cycle_time, :DevCycleTime from_rally :deploy_cycle_time, :DeployCycleTime from_rally :theme parse_ref :revision_history_uri, @rally_hash["RevisionHistory"] self.refresh_points self.save rescue ArgumentError #getting some bad created_on dates puts "Errored on #{self.name}" p self self.save # save what you can end |
#refresh_points ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/story.rb', line 98 def refresh_points if self.children.empty? if self.accepted_on points = {:accepted => self.plan_estimate || 0, :unaccepted => 0} else points = {:unaccepted => self.plan_estimate || 0, :accepted => 0} end else points = self.children.inject({:accepted => 0, :unaccepted => 0}) do |sums,child| child_points = child.refresh_points sums[:accepted] += child_points[:accepted] sums[:unaccepted] += child_points[:unaccepted] sums end end self.accepted_points = points[:accepted] self.unaccepted_points = points[:unaccepted] self.save return points end |
#revision_fields ⇒ Object
119 120 121 |
# File 'lib/story.rb', line 119 def revision_fields [:sized_on, :prioritized_on, :started_on, :completed_on] end |
#revision_history ⇒ Object
222 223 224 |
# File 'lib/story.rb', line 222 def revision_history RevisionHistory.find_or_create_by(:rally_uri => self.revision_history_uri) end |
#revision_parser ⇒ Object
137 138 139 140 141 |
# File 'lib/story.rb', line 137 def revision_parser if self.project self.project.revision_parser end end |
#status_changes ⇒ Object
132 133 134 135 |
# File 'lib/story.rb', line 132 def status_changes set_revision_history revision_fields.inject({}){|h,field| h[field] = self.send(field.to_s); h} end |
#update_parent ⇒ Object
216 217 218 219 220 |
# File 'lib/story.rb', line 216 def update_parent p self.parent.children.count #self.parent.children << self self.parent.save end |