track-r 1.8.0 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/track-r.rb +1 -0
- data/lib/track-r/project.rb +25 -9
- data/lib/track-r/story.rb +19 -4
- data/pkg/track-r-1.0.0.gem +0 -0
- data/test/unit/story_test.rb +1 -1
- data/track-r.gemspec +1 -1
- metadata +1 -1
data/lib/track-r.rb
CHANGED
data/lib/track-r/project.rb
CHANGED
@@ -36,12 +36,19 @@ class Project
|
|
36
36
|
def create_story(attributes = {})
|
37
37
|
api_url = URI.parse("#{CONFIG[:api_url]}projects/#{@id}/stories")
|
38
38
|
query_string = attributes.map { |key, value| "story[#{key}]=#{CGI::escape(value)}"}.join('&')
|
39
|
-
|
40
|
-
http.
|
41
|
-
|
39
|
+
begin
|
40
|
+
http = Net::HTTP.new(api_url.host, api_url.port)
|
41
|
+
http.use_ssl = true
|
42
|
+
response, data = http.post(api_url.path, query_string.concat("&token=#{@token}"))
|
42
43
|
|
43
|
-
|
44
|
-
|
44
|
+
raise ResponseError, "Wrong response code" unless response.code.to_i == 200
|
45
|
+
story = (Hpricot(response.body)/:story)
|
46
|
+
Story.new(:story => story, :project_id => @id, :token => @token)
|
47
|
+
rescue ResponseError => e
|
48
|
+
print "Got response code [#{response.code}]:\t"
|
49
|
+
puts response.message
|
50
|
+
raise
|
51
|
+
end
|
45
52
|
end
|
46
53
|
|
47
54
|
# Deletes a story given a Story object or a story_id
|
@@ -53,11 +60,18 @@ class Project
|
|
53
60
|
else
|
54
61
|
raise ArgumentError, "Should receive a story id or a Story object."
|
55
62
|
end
|
56
|
-
|
57
|
-
http.
|
63
|
+
begin
|
64
|
+
http = Net::HTTP.new(api_url.host, api_url.port)
|
65
|
+
http.use_ssl = true
|
66
|
+
response, data = http.delete(api_url.path, {"X-TrackerToken" => @token})
|
67
|
+
raise ResponseError, "Wrong response code" unless response.code.to_i == 200
|
68
|
+
story = (Hpricot(response.body)/:story)
|
69
|
+
Story.new(:story => story, :project_id => @id, :token => @token)
|
70
|
+
rescue ResponseError => e
|
71
|
+
print "Got response code [#{response.code}]:\t"
|
72
|
+
puts response.message
|
73
|
+
raise
|
58
74
|
end
|
59
|
-
story = (Hpricot(response.body)/:story)
|
60
|
-
Story.new(:story => story, :project_id => @id, :token => @token)
|
61
75
|
end
|
62
76
|
|
63
77
|
# Gets the backlog's stories
|
@@ -112,3 +126,5 @@ class Project
|
|
112
126
|
end
|
113
127
|
|
114
128
|
end # class Tracker::Project
|
129
|
+
|
130
|
+
class ResponseError < Exception ;end
|
data/lib/track-r/story.rb
CHANGED
@@ -58,8 +58,16 @@ class Story
|
|
58
58
|
def save
|
59
59
|
parameters = build_story_xml
|
60
60
|
api_url = URI.parse("#{CONFIG[:api_url]}projects/#{@project_id}/stories/#{@id}")
|
61
|
-
|
62
|
-
http.
|
61
|
+
begin
|
62
|
+
http = Net::HTTP.new(api_url.host, api_url.port)
|
63
|
+
http.use_ssl = true
|
64
|
+
response, data = http.put(api_url.path, parameters, {'X-TrackerToken' => @token, 'Content-Type' => 'application/xml'})
|
65
|
+
|
66
|
+
raise ResponseError, "Wrong response code" unless response.code.to_i == 200
|
67
|
+
rescue ResponseError => e
|
68
|
+
print "Got response code [#{response.code}]:\t"
|
69
|
+
puts response.message
|
70
|
+
raise
|
63
71
|
end
|
64
72
|
|
65
73
|
@story = (Hpricot(response.body)/:story)
|
@@ -69,8 +77,15 @@ class Story
|
|
69
77
|
# TODO: test this method:
|
70
78
|
def destroy
|
71
79
|
api_url = URI.parse("#{CONFIG[:api_url]}projects/#{@project_id}/stories/#{@id}")
|
72
|
-
|
73
|
-
http.
|
80
|
+
begin
|
81
|
+
http = Net::HTTP.new(api_url.host, api_url.port)
|
82
|
+
http.use_ssl = true
|
83
|
+
response, data = http.delete(api_url.path, {"X-TrackerToken" => @token})
|
84
|
+
raise ResponseError, "Wrong response code" unless response.code.to_i == 200
|
85
|
+
rescue ResponseError => e
|
86
|
+
print "Got response code [#{response.code}]:\t"
|
87
|
+
puts response.message
|
88
|
+
raise
|
74
89
|
end
|
75
90
|
end
|
76
91
|
|
data/pkg/track-r-1.0.0.gem
CHANGED
Binary file
|
data/test/unit/story_test.rb
CHANGED
@@ -24,7 +24,7 @@ class TestStoryTest < Test::Unit::TestCase
|
|
24
24
|
@story.description = "ZOMG!"
|
25
25
|
@story.save
|
26
26
|
|
27
|
-
assert_equal "
|
27
|
+
assert_equal "More power to the shields", @project.story(@story.id).name
|
28
28
|
end
|
29
29
|
|
30
30
|
end
|
data/track-r.gemspec
CHANGED