tracker_api 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/tracker_api/client.rb +11 -1
- data/lib/tracker_api/endpoints/epic.rb +1 -1
- data/lib/tracker_api/endpoints/epics.rb +3 -1
- data/lib/tracker_api/endpoints/iterations.rb +3 -1
- data/lib/tracker_api/endpoints/memberships.rb +3 -1
- data/lib/tracker_api/endpoints/stories.rb +3 -1
- data/lib/tracker_api/endpoints/story.rb +7 -1
- data/lib/tracker_api/endpoints/tasks.rb +3 -1
- data/lib/tracker_api/resources/project.rb +6 -0
- data/lib/tracker_api/version.rb +1 -1
- data/test/client_test.rb +11 -0
- data/test/minitest_helper.rb +1 -1
- data/test/project_test.rb +11 -0
- data/test/story_test.rb +14 -1
- data/tracker_api.gemspec +2 -1
- metadata +19 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9b4b422159e2a7ed286a626f35cc996a8dcb218
|
4
|
+
data.tar.gz: fa36b559c306a27b509d2314d52b9a795c6d69f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 620622ef5cc89906fb1d025d83c2507f9ae92f965501f8acf756fe8780ba30e37fa589c2c777e9cbfcd8c143419915537ec7c64ea195a9a190e3155916747cce
|
7
|
+
data.tar.gz: e8af9bb5b17c3863ebe7e5f1e2e6c5656a238ad6702fbd5c8c96a07a92390ed493ccf862d209be87f89f72a72c500dedaeeee3c752651d346276649377838862
|
data/README.md
CHANGED
@@ -44,6 +44,7 @@ project.stories # Get
|
|
44
44
|
project.stories(with_state: :unscheduled, limit: 10) # Get 10 unscheduled stories for a project
|
45
45
|
project.stories(filter: 'requester:OWK label:"jedi stuff"') # Get all stories that match the given filters
|
46
46
|
project.story(847762630) # Find a story with the given ID
|
47
|
+
project.create_story(name: 'Destroy death star') # Create a story with the name 'Destroy death star'
|
47
48
|
|
48
49
|
epics = project.epics # Get all epics for a project
|
49
50
|
epic = epics.first
|
data/lib/tracker_api/client.rb
CHANGED
@@ -54,6 +54,15 @@ module TrackerApi
|
|
54
54
|
request(:get, parse_query_and_convenience_headers(path, options))
|
55
55
|
end
|
56
56
|
|
57
|
+
# Make a HTTP POST request
|
58
|
+
#
|
59
|
+
# @param path [String] The path, relative to api endpoint
|
60
|
+
# @param options [Hash] Query and header params for request
|
61
|
+
# @return [Faraday::Response]
|
62
|
+
def post(path, options = {})
|
63
|
+
request(:post, parse_query_and_convenience_headers(path, options))
|
64
|
+
end
|
65
|
+
|
57
66
|
# Make one or more HTTP GET requests, optionally fetching
|
58
67
|
# the next page of results from information passed back in headers
|
59
68
|
# based on value in {#auto_paginate}.
|
@@ -67,11 +76,12 @@ module TrackerApi
|
|
67
76
|
# @return [Array]
|
68
77
|
def paginate(path, options = {}, &block)
|
69
78
|
opts = parse_query_and_convenience_headers path, options.dup
|
79
|
+
auto_paginate = opts[:params].delete(:auto_paginate) { |k| @auto_paginate }
|
70
80
|
@last_response = request :get, opts
|
71
81
|
data = @last_response.body
|
72
82
|
raise TrackerApi::Errors::UnexpectedData, 'Array expected' unless data.is_a? Array
|
73
83
|
|
74
|
-
if
|
84
|
+
if auto_paginate
|
75
85
|
pager = Pagination.new @last_response.headers
|
76
86
|
|
77
87
|
while pager.more?
|
@@ -10,7 +10,7 @@ module TrackerApi
|
|
10
10
|
def get(project_id, id)
|
11
11
|
data = client.get("/projects/#{project_id}/epics/#{id}").body
|
12
12
|
|
13
|
-
Resources::Epic.new({ client: client }.merge(data))
|
13
|
+
Resources::Epic.new({ client: client, project_id: project_id }.merge(data))
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -11,7 +11,9 @@ module TrackerApi
|
|
11
11
|
data = client.paginate("/projects/#{project_id}/epics", params: params)
|
12
12
|
raise TrackerApi::Errors::UnexpectedData, 'Array of epics expected' unless data.is_a? Array
|
13
13
|
|
14
|
-
data.map
|
14
|
+
data.map do |epic|
|
15
|
+
Resources::Epic.new({ client: client, project_id: project_id }.merge(epic))
|
16
|
+
end
|
15
17
|
end
|
16
18
|
end
|
17
19
|
end
|
@@ -11,7 +11,9 @@ module TrackerApi
|
|
11
11
|
data = client.paginate("/projects/#{project_id}/iterations", params: params)
|
12
12
|
raise TrackerApi::Errors::UnexpectedData, 'Array of iterations expected' unless data.is_a? Array
|
13
13
|
|
14
|
-
data.map
|
14
|
+
data.map do |iteration|
|
15
|
+
Resources::Iteration.new({ client: client, project_id: project_id }.merge(iteration))
|
16
|
+
end
|
15
17
|
end
|
16
18
|
end
|
17
19
|
end
|
@@ -11,7 +11,9 @@ module TrackerApi
|
|
11
11
|
data = client.paginate("/projects/#{project_id}/memberships", params: params)
|
12
12
|
raise TrackerApi::Errors::UnexpectedData, 'Array of memberships expected' unless data.is_a? Array
|
13
13
|
|
14
|
-
data.map
|
14
|
+
data.map do |membership|
|
15
|
+
Resources::ProjectMembership.new({ client: client, project_id: project_id }.merge(membership))
|
16
|
+
end
|
15
17
|
end
|
16
18
|
end
|
17
19
|
end
|
@@ -11,7 +11,9 @@ module TrackerApi
|
|
11
11
|
data = client.paginate("/projects/#{project_id}/stories", params: params)
|
12
12
|
raise TrackerApi::Errors::UnexpectedData, 'Array of stories expected' unless data.is_a? Array
|
13
13
|
|
14
|
-
data.map
|
14
|
+
data.map do |story|
|
15
|
+
Resources::Story.new({ client: client, project_id: project_id }.merge(story))
|
16
|
+
end
|
15
17
|
end
|
16
18
|
end
|
17
19
|
end
|
@@ -10,7 +10,7 @@ module TrackerApi
|
|
10
10
|
def get(project_id, id)
|
11
11
|
data = client.get("/projects/#{project_id}/stories/#{id}").body
|
12
12
|
|
13
|
-
Resources::Story.new({ client: client }.merge(data))
|
13
|
+
Resources::Story.new({ client: client, project_id: project_id }.merge(data))
|
14
14
|
end
|
15
15
|
|
16
16
|
def get_story(story_id)
|
@@ -18,6 +18,12 @@ module TrackerApi
|
|
18
18
|
|
19
19
|
Resources::Story.new({ client: client }.merge(data))
|
20
20
|
end
|
21
|
+
|
22
|
+
def create(project_id, params={})
|
23
|
+
data = client.post("/projects/#{project_id}/stories", params: params).body
|
24
|
+
|
25
|
+
Resources::Story.new({ client: client }.merge(data))
|
26
|
+
end
|
21
27
|
end
|
22
28
|
end
|
23
29
|
end
|
@@ -11,7 +11,9 @@ module TrackerApi
|
|
11
11
|
data = client.paginate("/projects/#{project_id}/stories/#{story_id}/tasks", params: params)
|
12
12
|
raise TrackerApi::Errors::UnexpectedData, 'Array of tasks expected' unless data.is_a? Array
|
13
13
|
|
14
|
-
data.map
|
14
|
+
data.map do |task|
|
15
|
+
Resources::Task.new({ client: client, project_id: project_id }.merge(task))
|
16
|
+
end
|
15
17
|
end
|
16
18
|
end
|
17
19
|
end
|
@@ -90,6 +90,12 @@ module TrackerApi
|
|
90
90
|
def story(story_id)
|
91
91
|
Endpoints::Story.new(client).get(id, story_id)
|
92
92
|
end
|
93
|
+
|
94
|
+
# @param [Hash] hash of attributes to create the story
|
95
|
+
# @return [Story] Story with given id
|
96
|
+
def create_story(params)
|
97
|
+
Endpoints::Story.new(client).create(id, params)
|
98
|
+
end
|
93
99
|
end
|
94
100
|
end
|
95
101
|
end
|
data/lib/tracker_api/version.rb
CHANGED
data/test/client_test.rb
CHANGED
@@ -101,6 +101,17 @@ describe TrackerApi::Client do
|
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
104
|
+
it 'allows auto pagination to be turned off when just a subset of a list is desired' do
|
105
|
+
VCR.use_cassette('client: get limited stories with no pagination', record: :new_episodes) do
|
106
|
+
project = client.project(project_id)
|
107
|
+
|
108
|
+
# force no pagination
|
109
|
+
stories = project.stories(limit: 7, auto_paginate: false)
|
110
|
+
stories.wont_be_empty
|
111
|
+
stories.length.must_equal 7
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
104
115
|
it 'can handle negative offsets' do
|
105
116
|
VCR.use_cassette('client: done iterations with pagination', record: :new_episodes) do
|
106
117
|
project = client.project(project_id)
|
data/test/minitest_helper.rb
CHANGED
@@ -19,7 +19,7 @@ VCR.configure do |c|
|
|
19
19
|
c.ignore_localhost = true
|
20
20
|
c.cassette_library_dir = File.expand_path('../vcr/cassettes', __FILE__).to_s
|
21
21
|
c.default_cassette_options = { serialize_with: :json }
|
22
|
-
c.hook_into :
|
22
|
+
c.hook_into :excon
|
23
23
|
c.allow_http_connections_when_no_cassette = false
|
24
24
|
end
|
25
25
|
|
data/test/project_test.rb
CHANGED
@@ -77,5 +77,16 @@ describe TrackerApi::Resources::Project do
|
|
77
77
|
story.current_state.must_equal 'unscheduled'
|
78
78
|
end
|
79
79
|
end
|
80
|
+
|
81
|
+
it 'can create story' do
|
82
|
+
VCR.use_cassette('create story') do
|
83
|
+
story = project.create_story(name: 'Test story')
|
84
|
+
|
85
|
+
story.must_be_instance_of TrackerApi::Resources::Story
|
86
|
+
story.id.wont_be_nil
|
87
|
+
story.id.must_be :>, 0
|
88
|
+
story.name.must_equal 'Test story'
|
89
|
+
end
|
90
|
+
end
|
80
91
|
end
|
81
92
|
end
|
data/test/story_test.rb
CHANGED
@@ -7,7 +7,7 @@ describe TrackerApi::Resources::Story do
|
|
7
7
|
let(:project) { VCR.use_cassette('get project') { client.project(project_id) } }
|
8
8
|
|
9
9
|
describe '.tasks' do
|
10
|
-
it
|
10
|
+
it 'gets all tasks for this story' do
|
11
11
|
VCR.use_cassette('get tasks', record: :new_episodes) do
|
12
12
|
tasks = project.story('66728004').tasks
|
13
13
|
|
@@ -16,5 +16,18 @@ describe TrackerApi::Resources::Story do
|
|
16
16
|
task.must_be_instance_of TrackerApi::Resources::Task
|
17
17
|
end
|
18
18
|
end
|
19
|
+
|
20
|
+
it 'gets all tasks even when the project_id is excluded from the story fields' do
|
21
|
+
VCR.use_cassette('get tasks when stories filtered', record: :new_episodes) do
|
22
|
+
stories = project.stories(with_state: 'unstarted', fields: 'name,story_type')
|
23
|
+
stories.each do |story|
|
24
|
+
tasks = story.tasks
|
25
|
+
unless tasks.empty?
|
26
|
+
task = tasks.first
|
27
|
+
task.must_be_instance_of TrackerApi::Resources::Task
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
19
32
|
end
|
20
33
|
end
|
data/tracker_api.gemspec
CHANGED
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_development_dependency 'minitest'
|
24
24
|
spec.add_development_dependency 'awesome_print'
|
25
25
|
spec.add_development_dependency 'vcr'
|
26
|
+
spec.add_development_dependency 'excon'
|
26
27
|
spec.add_development_dependency 'multi_json'
|
27
28
|
# spec.add_development_dependency 'byebug'
|
28
29
|
# spec.add_development_dependency 'pry-byebug'
|
@@ -30,7 +31,7 @@ Gem::Specification.new do |spec|
|
|
30
31
|
|
31
32
|
spec.add_dependency 'addressable'
|
32
33
|
spec.add_dependency 'virtus'
|
33
|
-
spec.add_dependency 'faraday', '~> 0.
|
34
|
+
spec.add_dependency 'faraday', '~> 0.9.0'
|
34
35
|
spec.add_dependency 'faraday_middleware'
|
35
36
|
# spec.add_dependency 'excon'
|
36
37
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tracker_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Forest Carlisle
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: excon
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: multi_json
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,14 +142,14 @@ dependencies:
|
|
128
142
|
requirements:
|
129
143
|
- - ~>
|
130
144
|
- !ruby/object:Gem::Version
|
131
|
-
version: 0.
|
145
|
+
version: 0.9.0
|
132
146
|
type: :runtime
|
133
147
|
prerelease: false
|
134
148
|
version_requirements: !ruby/object:Gem::Requirement
|
135
149
|
requirements:
|
136
150
|
- - ~>
|
137
151
|
- !ruby/object:Gem::Version
|
138
|
-
version: 0.
|
152
|
+
version: 0.9.0
|
139
153
|
- !ruby/object:Gem::Dependency
|
140
154
|
name: faraday_middleware
|
141
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -228,7 +242,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
228
242
|
version: '0'
|
229
243
|
requirements: []
|
230
244
|
rubyforge_project:
|
231
|
-
rubygems_version: 2.
|
245
|
+
rubygems_version: 2.0.14
|
232
246
|
signing_key:
|
233
247
|
specification_version: 4
|
234
248
|
summary: API client for the Pivotal Tracker v5 API
|