Class: Toolshed::TicketTracking::PivotalTracker
- Inherits:
-
Object
- Object
- Toolshed::TicketTracking::PivotalTracker
show all
- Extended by:
- Toolshed::TicketTracking
- Includes:
- HTTParty
- Defined in:
- lib/toolshed/ticket_tracking/pivotal_tracker.rb
Constant Summary
collapse
- DEFAULT_COMPLETED_STATUS =
'finished'
- USE_PROJECT_ID =
true
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
clean, story_id_from_branch_name
Constructor Details
Returns a new instance of PivotalTracker.
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/toolshed/ticket_tracking/pivotal_tracker.rb', line 12
def initialize(options={})
username = Toolshed::Client::pivotal_tracker_username
password = Toolshed::Client::pivotal_tracker_password
unless (options[:username].nil?)
username = options[:username]
end
unless (options[:password].nil?)
password = options[:password]
end
self.token = ::PivotalTracker::Client.token(username, password)
self.project_id = (options[:project_id].nil?) ? Toolshed::Client.default_pivotal_tracker_project_id : options[:project_id]
@pt_project = ::PivotalTracker::Project.find(self.project_id)
self.story = @pt_project.stories.find(options[:ticket_id])
end
|
Instance Attribute Details
#project_id ⇒ Object
Returns the value of attribute project_id.
10
11
12
|
# File 'lib/toolshed/ticket_tracking/pivotal_tracker.rb', line 10
def project_id
@project_id
end
|
#story ⇒ Object
Returns the value of attribute story.
10
11
12
|
# File 'lib/toolshed/ticket_tracking/pivotal_tracker.rb', line 10
def story
@story
end
|
#token ⇒ Object
Returns the value of attribute token.
10
11
12
|
# File 'lib/toolshed/ticket_tracking/pivotal_tracker.rb', line 10
def token
@token
end
|
Class Method Details
.create_instance(options = {}) ⇒ Object
.password ⇒ Object
81
82
83
84
85
86
87
88
89
90
91
92
|
# File 'lib/toolshed/ticket_tracking/pivotal_tracker.rb', line 81
def password
password = Toolshed::Client::pivotal_tracker_password
if (password.nil?)
system "stty -echo"
puts "PivotalTracker password? "
password = $stdin.gets.chomp.strip
system "stty echo"
end
return password
end
|
.username ⇒ Object
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/toolshed/ticket_tracking/pivotal_tracker.rb', line 70
def username
username = Toolshed::Client::pivotal_tracker_username
if (username.nil?)
puts "PivotalTracker username? "
username = $stdin.gets.chomp.strip
end
return username
end
|
Instance Method Details
#add_note(note_text) ⇒ Object
35
36
37
|
# File 'lib/toolshed/ticket_tracking/pivotal_tracker.rb', line 35
def add_note(note_text)
results = self.story.notes.create(text: note_text)
end
|
#ticket ⇒ Object
31
32
33
|
# File 'lib/toolshed/ticket_tracking/pivotal_tracker.rb', line 31
def ticket
self.story
end
|
#title ⇒ Object
61
62
63
|
# File 'lib/toolshed/ticket_tracking/pivotal_tracker.rb', line 61
def title
self.clean(self.story.name)
end
|
#update_ticket_status(current_state, options = {}) ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/toolshed/ticket_tracking/pivotal_tracker.rb', line 39
def update_ticket_status(current_state, options={})
options.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/#{self.story.id}", options).response
response = JSON.parse(response.body)
if (response["error"].nil?)
response
else
raise "validation errors #{response.inspect}"
end
end
|
#url(ticket_id) ⇒ Object
65
66
67
|
# File 'lib/toolshed/ticket_tracking/pivotal_tracker.rb', line 65
def url(ticket_id)
self.story.url
end
|