Class: WestAreteTrackerTools::Project

Inherits:
Object
  • Object
show all
Defined in:
lib/westarete-tracker-tools/project.rb

Overview

Represents a project in Tracker.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tracker_project) ⇒ Project

Create a new Project object, given its PivotalTracker::Project object.



16
17
18
# File 'lib/westarete-tracker-tools/project.rb', line 16

def initialize(tracker_project)
  @tracker_project = tracker_project
end

Class Method Details

.allObject

Return all active projects



6
7
8
# File 'lib/westarete-tracker-tools/project.rb', line 6

def self.all
  PivotalTracker::Project.all.map { |p| new p }
end

.find_by_name(project_name) ⇒ Object

Find a project by its exact name.



11
12
13
# File 'lib/westarete-tracker-tools/project.rb', line 11

def self.find_by_name(project_name)
  all.detect { |project| project.name == project_name }
end

Instance Method Details

#backlogObject

Return all of the stories in the current and future iterations.



21
22
23
24
25
# File 'lib/westarete-tracker-tools/project.rb', line 21

def backlog
  tracker_stories = @tracker_project.iteration(:current).stories
  tracker_stories += @tracker_project.iteration(:backlog).collect(&:stories).flatten
  tracker_stories.map { |tracker_story| Story.new(tracker_story) }
end

#currentObject

Return all of the stories in the current iteration.



28
29
30
31
# File 'lib/westarete-tracker-tools/project.rb', line 28

def current
  tracker_stories = @tracker_project.iteration(:current).stories
  tracker_stories.map { |tracker_story| Story.new(tracker_story) }
end

#done(offset = nil) ⇒ Object

Return all of the stories that have been completed in any iteration. You can optionally specify an offset of zero or less to limit the results to a particular iteration, where zero is the current iteration, -1 is the prior iteration, -2 is two iteratons ago, etc.



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/westarete-tracker-tools/project.rb', line 37

def done(offset=nil)
  if offset.nil?
    tracker_stories = @tracker_project.iteration(:done).collect(&:stories).flatten
    tracker_stories += @tracker_project.iteration(:current).stories
  elsif offset < 0
    iterations = PivotalTracker::Iteration.done(@tracker_project, :offset => offset.to_s)
    tracker_stories = iterations.any? ? iterations.first.stories : []
  elsif offset == 0
    tracker_stories = @tracker_project.iteration(:current).stories
  else
    raise ArgumentError, 'offset should be an integer less than or equal to zero'
  end
  tracker_stories.map! { |tracker_story| Story.new(tracker_story) }
  tracker_stories.select(&:complete?)
end

#nameObject

Return the name of this project.



54
55
56
# File 'lib/westarete-tracker-tools/project.rb', line 54

def name
  @tracker_project.name
end

#tracker_idObject

The id in tracker for this project.



59
60
61
# File 'lib/westarete-tracker-tools/project.rb', line 59

def tracker_id
  @tracker_project.id
end

#urlObject

Return the web URL for viewing this project.



64
65
66
# File 'lib/westarete-tracker-tools/project.rb', line 64

def url
  "http://www.pivotaltracker.com/projects/#{tracker_id}"
end