track-r 1.7.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/config/config.yml +2 -2
- data/lib/track-r.rb +3 -3
- data/lib/track-r/project.rb +8 -8
- data/lib/track-r/story.rb +6 -6
- data/lib/track-r/tracker.rb +1 -1
- data/test/test_helper.rb +1 -0
- data/test/unit/project_test.rb +5 -5
- data/test/unit/story_test.rb +5 -5
- data/track-r.gemspec +1 -1
- metadata +2 -2
data/config/config.yml
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
---
|
2
|
-
:
|
1
|
+
---
|
2
|
+
:api_url: "https://www.pivotaltracker.com/services/v2/"
|
data/lib/track-r.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
# Load configuration globals
|
2
|
+
require 'yaml'
|
3
|
+
CONFIG = YAML.load_file(File.join(File.dirname(__FILE__), '/../config/config.yml'))
|
1
4
|
$:.unshift(File.dirname(__FILE__))
|
2
5
|
require File.join(File.dirname(__FILE__), '/../config/environment.rb')
|
3
6
|
require 'track-r/project'
|
@@ -7,6 +10,3 @@ require 'track-r/token'
|
|
7
10
|
require 'track-r/tracker'
|
8
11
|
require 'cgi'
|
9
12
|
require 'net/http'
|
10
|
-
|
11
|
-
# Load configuration globals
|
12
|
-
CONFIG = YAML.load_file(File.join(File.dirname(__FILE__), '/../config/config.yml'))
|
data/lib/track-r/project.rb
CHANGED
@@ -9,7 +9,7 @@ class Project
|
|
9
9
|
if options.include?(:project_id) && options.include?(:token)
|
10
10
|
@id = options[:project_id]
|
11
11
|
@token = options[:token].to_s
|
12
|
-
@api_url = "
|
12
|
+
@api_url = "#{CONFIG[:api_url]}projects/#{@id}"
|
13
13
|
@url = "http://www.pivotaltracker.com/projects/#{@id}"
|
14
14
|
@project = Hpricot(open(@api_url, {"X-TrackerToken" => @token}))
|
15
15
|
@stories = nil
|
@@ -34,7 +34,7 @@ class Project
|
|
34
34
|
# Returns a Story object
|
35
35
|
# TODO: Validate attributes
|
36
36
|
def create_story(attributes = {})
|
37
|
-
api_url = URI.parse("
|
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
39
|
response = Net::HTTP.start(api_url.host, api_url.port) do |http|
|
40
40
|
http.post(api_url.path, query_string.concat("&token=#{@token}"))
|
@@ -47,9 +47,9 @@ class Project
|
|
47
47
|
# Deletes a story given a Story object or a story_id
|
48
48
|
def delete_story(story)
|
49
49
|
if story.is_a?(Story)
|
50
|
-
api_url = URI.parse("
|
50
|
+
api_url = URI.parse("#{CONFIG[:api_url]}projects/#{@id}/stories/#{story.id}")
|
51
51
|
elsif story.is_a?(Integer) || story.to_i.is_a?(Integer)
|
52
|
-
api_url = URI.parse("
|
52
|
+
api_url = URI.parse("#{CONFIG[:api_url]}projects/#{@id}/stories/#{story}")
|
53
53
|
else
|
54
54
|
raise ArgumentError, "Should receive a story id or a Story object."
|
55
55
|
end
|
@@ -86,7 +86,7 @@ class Project
|
|
86
86
|
# @project
|
87
87
|
def build_project
|
88
88
|
@id ||= @project.at('id').inner_html
|
89
|
-
@api_url ||= "
|
89
|
+
@api_url ||= "#{CONFIG[:api_url]}projects/#{@id}"
|
90
90
|
@url ||= "http://www.pivotaltracker.com/projects/#{@id}"
|
91
91
|
@name = @project.at('name').inner_html
|
92
92
|
@iteration_length = @project.at('iteration_length').inner_html
|
@@ -96,7 +96,7 @@ class Project
|
|
96
96
|
|
97
97
|
# Builds an array containing the project's stories
|
98
98
|
def get_stories
|
99
|
-
api_url = "#{CONFIG[:
|
99
|
+
api_url = "#{CONFIG[:api_url]}projects/#{@id}/stories"
|
100
100
|
@stories = (Hpricot(open(api_url, {"X-TrackerToken" => @token.to_s}))/:story).map {|story| Story.new(:story => story, :project_id => @id, :token => @token)}
|
101
101
|
end
|
102
102
|
|
@@ -104,9 +104,9 @@ class Project
|
|
104
104
|
def get_stories_by_iteration(name)
|
105
105
|
case name
|
106
106
|
when "icebox"
|
107
|
-
api_url = "
|
107
|
+
api_url = "#{CONFIG[:api_url]}projects/#{@id}/stories?filter=current_state%3Aunscheduled"
|
108
108
|
else
|
109
|
-
api_url = "
|
109
|
+
api_url = "#{CONFIG[:api_url]}projects/#{@id}/iterations/#{name}"
|
110
110
|
end
|
111
111
|
@stories = (Hpricot(open(api_url, {"X-TrackerToken" => @token.to_s}))/:story).map {|story| Story.new(:story => story, :project_id => @id, :token => @token)}
|
112
112
|
end
|
data/lib/track-r/story.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
class Story
|
3
3
|
attr_accessor :story_type, :estimate, :current_state,
|
4
4
|
:description, :name, :requested_by, :owned_by, :created_at, :accepted_at,
|
5
|
-
:labels, :project_id, :comments
|
5
|
+
:labels, :project_id, :comments, :story
|
6
6
|
|
7
7
|
attr_reader :id, :url
|
8
8
|
|
@@ -12,7 +12,7 @@ class Story
|
|
12
12
|
@id = options[:story_id]
|
13
13
|
@project_id = options[:project_id]
|
14
14
|
@url = "http://www.pivotaltracker.com/story/show/#{@id}"
|
15
|
-
@api_url = "
|
15
|
+
@api_url = "#{CONFIG[:api_url]}projects/#{@project_id}/stories/#{@id}"
|
16
16
|
@story = Hpricot(open(@api_url, {"X-TrackerToken" => @token}))
|
17
17
|
elsif options.include?(:story) && options.include?(:project_id) && options.include?(:token)
|
18
18
|
@project_id = options[:project_id]
|
@@ -24,9 +24,9 @@ class Story
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def build_story
|
27
|
-
@id ||= @story.at('id').inner_html
|
27
|
+
@id ||= @story.at('id').inner_html if @story.at('id')
|
28
28
|
@url ||= "http://www.pivotaltracker.com/story/show/#{@id}"
|
29
|
-
@api_url ||= "
|
29
|
+
@api_url ||= "#{CONFIG[:api_url]}projects/#{@project_id}/stories/#{@id}"
|
30
30
|
@story_type = @story.at('story_type').inner_html unless @story.at('story_type').nil?
|
31
31
|
@estimate = @story.at('estimate').inner_html unless @story.at('estimate').nil?
|
32
32
|
@current_state = @story.at('current_state').inner_html unless @story.at('current_state').nil?
|
@@ -57,7 +57,7 @@ class Story
|
|
57
57
|
|
58
58
|
def save
|
59
59
|
parameters = build_story_xml
|
60
|
-
api_url = URI.parse("
|
60
|
+
api_url = URI.parse("#{CONFIG[:api_url]}projects/#{@project_id}/stories/#{@id}")
|
61
61
|
response = Net::HTTP.start(api_url.host, api_url.port) do |http|
|
62
62
|
http.put(api_url.path, parameters, {'X-TrackerToken' => @token, 'Content-Type' => 'application/xml'})
|
63
63
|
end
|
@@ -68,7 +68,7 @@ class Story
|
|
68
68
|
|
69
69
|
# TODO: test this method:
|
70
70
|
def destroy
|
71
|
-
api_url = URI.parse("
|
71
|
+
api_url = URI.parse("#{CONFIG[:api_url]}projects/#{@project_id}/stories/#{@id}")
|
72
72
|
response = Net::HTTP.start(api_url.host, api_url.port) do |http|
|
73
73
|
http.delete(api_url.path, {"X-TrackerToken" => @token})
|
74
74
|
end
|
data/lib/track-r/tracker.rb
CHANGED
@@ -43,7 +43,7 @@ class Tracker
|
|
43
43
|
# Fills @projects. NOTE: call sync method to refill/sync @projects
|
44
44
|
# Returns an Array stored in @projects
|
45
45
|
def get_projects
|
46
|
-
api_url = "#{CONFIG[:
|
46
|
+
api_url = "#{CONFIG[:api_url]}projects/"
|
47
47
|
@projects ||= (Hpricot(open(api_url, {"X-TrackerToken" => @token.to_s}))/:project).map {|project| Project.new(:project => project, :token => @token)}
|
48
48
|
end
|
49
49
|
|
data/test/test_helper.rb
CHANGED
data/test/unit/project_test.rb
CHANGED
@@ -14,14 +14,14 @@ class ProjectTest < Test::Unit::TestCase
|
|
14
14
|
assert_equal $config[:project_1][:story_count], @project.stories.size
|
15
15
|
end
|
16
16
|
|
17
|
-
should "show a story with @project.story and passing the story id as argument" do
|
17
|
+
should "show a story with @project.story and passing the story id as argument" do
|
18
18
|
assert_equal $config[:story_1][:name], @project.story($config[:story_1][:id]).name
|
19
19
|
end
|
20
20
|
|
21
|
-
should "be able to add and remove a story" do
|
21
|
+
should "be able to add and remove a story" do
|
22
22
|
story_count = @project.stories.size
|
23
23
|
attributes = { :name => "Finish Track-R (sorry for cluttering :))",
|
24
|
-
:requested_by => "Jose Felix Gomez",
|
24
|
+
:requested_by => "Jose Felix Gomez",
|
25
25
|
:description => "This story was made with Track-R library. Sorry for the clutter, you're free to delete me." }
|
26
26
|
new_story = @project.create_story(attributes)
|
27
27
|
assert_equal "Finish Track-R (sorry for cluttering :))", new_story.name
|
@@ -29,12 +29,12 @@ class ProjectTest < Test::Unit::TestCase
|
|
29
29
|
assert_equal story_count, @project.stories.size
|
30
30
|
end
|
31
31
|
|
32
|
-
should "be able to get the backlog stories" do
|
32
|
+
should "be able to get the backlog stories" do
|
33
33
|
story_count = $config[:project_1][:backlog_stories]
|
34
34
|
assert_equal story_count, @project.backlog.size
|
35
35
|
end
|
36
36
|
|
37
|
-
should "be able to get the current iteration stories" do
|
37
|
+
should "be able to get the current iteration stories" do
|
38
38
|
story_count = $config[:project_1][:current_stories]
|
39
39
|
assert_equal story_count, @project.current.size
|
40
40
|
end
|
data/test/unit/story_test.rb
CHANGED
@@ -2,15 +2,15 @@ require File.dirname(__FILE__) + '/../test_helper'
|
|
2
2
|
|
3
3
|
class TestStoryTest < Test::Unit::TestCase
|
4
4
|
|
5
|
-
context "A given story" do
|
5
|
+
context "A given story" do
|
6
6
|
|
7
|
-
setup do
|
7
|
+
setup do
|
8
8
|
token_options = {:username => $config[:username], :password => $config[:password]}
|
9
9
|
@tracker = Tracker.new(Token.new(token_options))
|
10
10
|
@project_id = $config[:project_1][:id]
|
11
11
|
@project = @tracker.project(@project_id)
|
12
12
|
attributes = { :name => "Finish Track-R (sorry for cluttering :))",
|
13
|
-
:requested_by => "Jose Felix Gomez",
|
13
|
+
:requested_by => "Jose Felix Gomez",
|
14
14
|
:description => "This story was made with Track-R library. Sorry for the clutter, you're free to delete me." }
|
15
15
|
@story = @project.create_story(attributes)
|
16
16
|
end
|
@@ -19,12 +19,12 @@ class TestStoryTest < Test::Unit::TestCase
|
|
19
19
|
@project.delete_story(@story)
|
20
20
|
end
|
21
21
|
|
22
|
-
should "be updated after story.save call" do
|
22
|
+
should "be updated after story.save call" do
|
23
23
|
@story.name = "More power to the shields"
|
24
24
|
@story.description = "ZOMG!"
|
25
25
|
@story.save
|
26
26
|
|
27
|
-
assert_equal "
|
27
|
+
assert_equal "Combo Koombea mañaneo???", @project.story(@story.id).name
|
28
28
|
end
|
29
29
|
|
30
30
|
end
|
data/track-r.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: track-r
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jose Felix Gomez
|
@@ -68,7 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
68
68
|
requirements: []
|
69
69
|
|
70
70
|
rubyforge_project:
|
71
|
-
rubygems_version: 1.3.
|
71
|
+
rubygems_version: 1.3.5
|
72
72
|
signing_key:
|
73
73
|
specification_version: 3
|
74
74
|
summary: A wrapper library for pivotal tracker's API
|