Class: WestAreteTrackerTools::Story

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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_storyObject (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_atObject

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?

Returns:

  • (Boolean)


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?

Returns:

  • (Boolean)


33
34
35
# File 'lib/westarete-tracker-tools/story.rb', line 33

def chore?
  story_type == 'chore'
end

#commentsObject

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?

Returns:

  • (Boolean)


43
44
45
# File 'lib/westarete-tracker-tools/story.rb', line 43

def complete?
  ! incomplete?
end

#current_stateObject

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

#descriptionObject

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?

Returns:

  • (Boolean)


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?

Returns:

  • (Boolean)


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?

Returns:

  • (Boolean)


68
69
70
# File 'lib/westarete-tracker-tools/story.rb', line 68

def incomplete?
  accepted_at.nil?
end

#nameObject

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

#ownerObject

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

#pointsObject

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

#priceObject

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.author == '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?

Returns:

  • (Boolean)


102
103
104
# File 'lib/westarete-tracker-tools/story.rb', line 102

def release?
  story_type == 'release'
end

#requesterObject

Return the Requester object for



107
108
109
# File 'lib/westarete-tracker-tools/story.rb', line 107

def requester
  @tracker_story.requested_by
end

#riskObject

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_typeObject

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_idObject

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

#urlObject

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