Class: WestAreteTrackerTools::Project
- Inherits:
-
Object
- Object
- WestAreteTrackerTools::Project
- Defined in:
- lib/westarete-tracker-tools/project.rb
Overview
Represents a project in Tracker.
Class Method Summary collapse
-
.all ⇒ Object
Return all active projects.
-
.find_by_name(project_name) ⇒ Object
Find a project by its exact name.
Instance Method Summary collapse
-
#backlog ⇒ Object
Return all of the stories in the current and future iterations.
-
#current ⇒ Object
Return all of the stories in the current iteration.
-
#done(offset = nil) ⇒ Object
Return all of the stories that have been completed in any iteration.
-
#initialize(tracker_project) ⇒ Project
constructor
Create a new Project object, given its PivotalTracker::Project object.
-
#name ⇒ Object
Return the name of this project.
-
#tracker_id ⇒ Object
The id in tracker for this project.
-
#url ⇒ Object
Return the web URL for viewing this project.
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
.all ⇒ Object
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
#backlog ⇒ Object
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 |
#current ⇒ Object
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 |
#name ⇒ Object
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_id ⇒ Object
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 |
#url ⇒ Object
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 |