Class: Toolshed::PivotalTracker
- Inherits:
-
Object
- Object
- Toolshed::PivotalTracker
- Includes:
- HTTParty
- Defined in:
- lib/toolshed/pivotal_tracker.rb
Constant Summary collapse
- STORY_STATUS_DEFAULT =
'finished'
Instance Attribute Summary collapse
-
#project_id ⇒ Object
Returns the value of attribute project_id.
-
#token ⇒ Object
Returns the value of attribute token.
Class Method Summary collapse
Instance Method Summary collapse
- #add_note(story_id, note_text) ⇒ Object
-
#initialize(options = {}) ⇒ PivotalTracker
constructor
A new instance of PivotalTracker.
- #story_information(story_id) ⇒ Object
- #update_story_state(story_id, current_state, options = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ PivotalTracker
Returns a new instance of PivotalTracker.
9 10 11 12 13 14 |
# File 'lib/toolshed/pivotal_tracker.rb', line 9 def initialize(={}) self.token = ::PivotalTracker::Client.token(Toolshed::Client.pivotal_tracker_username, Toolshed::Client.pivotal_tracker_password) self.project_id = ([:project_id].nil?) ? Toolshed::Client.default_pivotal_tracker_project_id : [:project_id] @pt_project = ::PivotalTracker::Project.find(self.project_id) end |
Instance Attribute Details
#project_id ⇒ Object
Returns the value of attribute project_id.
7 8 9 |
# File 'lib/toolshed/pivotal_tracker.rb', line 7 def project_id @project_id end |
#token ⇒ Object
Returns the value of attribute token.
7 8 9 |
# File 'lib/toolshed/pivotal_tracker.rb', line 7 def token @token end |
Class Method Details
.story_id_from_branch_name(branch_name) ⇒ Object
16 17 18 |
# File 'lib/toolshed/pivotal_tracker.rb', line 16 def self.story_id_from_branch_name(branch_name) story_id = branch_name.split("_")[0] end |
Instance Method Details
#add_note(story_id, note_text) ⇒ Object
24 25 26 27 |
# File 'lib/toolshed/pivotal_tracker.rb', line 24 def add_note(story_id, note_text) story = @pt_project.stories.find(story_id) results = story.notes.create(text: note_text) end |
#story_information(story_id) ⇒ Object
20 21 22 |
# File 'lib/toolshed/pivotal_tracker.rb', line 20 def story_information(story_id) return @pt_project.stories.find(story_id) end |
#update_story_state(story_id, current_state, options = {}) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/toolshed/pivotal_tracker.rb', line 29 def update_story_state(story_id, current_state, ={}) .merge!({ :headers => { "X-TrackerToken" => self.token, "User-Agent" => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1309.0 Safari/537.17", "Content-Type" => "application/json", }, body: { current_state: current_state }.to_json }) response = HTTParty.put("#{Toolshed::Client::PIVOTAL_TRACKER_BASE_API_URL}projects/#{self.project_id}/stories/#{story_id}", ).response response = JSON.parse(response.body) if (response["error"].nil?) response else raise "validation errors #{response.inspect}" end end |