tracker_api 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3fbc8caee5a56cdf59e58fc545d0390f76685dc2
4
- data.tar.gz: cae843ef9bdc193e763d440db310a79e9fb7fe4a
3
+ metadata.gz: 0c36830bc748e4e3d5a45d61f64ba9df00e4f6d2
4
+ data.tar.gz: 15b700b9490e7b950862bc23ef55d7965e7de984
5
5
  SHA512:
6
- metadata.gz: 81a23229a778910df741e89fea770bec3096cadeb85c40dc9f79b587fc8fa1e6617c4e853f7f0722d6eb6037162276d49a6f6132e0501a8dfd0fdd1aa6db2e58
7
- data.tar.gz: 5be684a973dd96a30c032fd50179790505bab01ba8be8a61d0fb7b9a9bd30ec8a25bb697b8836764f116e7c0070f130d21d69f548e7e80c67ea171c19e4da36c
6
+ metadata.gz: 0411d1435854aa5c42dd379340caed6fb4e515e6279d873af31398088d871314d05f06a1bc153a56936c467a5ee208fc921fcabd652a2df8d84dfcfe581e8da0
7
+ data.tar.gz: 526003eba259c2f63e49aa0ffdb428ef723bfe438b2a88440b351d2aa01cad084a096591b3c858441d0dce88922b8dd816b2f5a9f2df64ddf8cb1d9cad2f99d7
data/.travis.yml CHANGED
@@ -4,9 +4,7 @@ rvm:
4
4
  - "2.0.0"
5
5
  - "2.1.0"
6
6
  - "2.2.3"
7
- # Faraday::ConnectionFailed: Could not generate DH keypair (Java::JavaLang::RuntimeException)
8
- # http://bugs.java.com/bugdatabase/view_bug.do?bug_id=7044060
9
- - "jruby"
7
+ # - "jruby"
10
8
  # - rbx
11
9
  # - "1.8.7"
12
10
  # uncomment this line if your project needs to run something other than `rake`:
data/README.md CHANGED
@@ -59,8 +59,11 @@ story.save # Save
59
59
  story = TrackerApi::Resources::Story.new( client: client,
60
60
  project_id: 123456,
61
61
  id: 847762630) # Use the Story resource to get the story
62
- comments = story.comments # comments without first fetching the story.
62
+ comments = story.comments # comments without first fetching the story
63
63
 
64
+ task = story.tasks.first # Get story tasks
65
+ task.complete = true
66
+ task.save # Mark a task complete
64
67
 
65
68
  epics = project.epics # Get all epics for a project
66
69
  epic = epics.first
@@ -86,6 +89,17 @@ story.comments(fields: ':default,person') # Eage
86
89
  - Add missing resources and endpoints
87
90
  - Add create, update, delete for resources
88
91
 
92
+ ## Semantic Versioning
93
+ http://semver.org/
94
+
95
+ Given a version number MAJOR.MINOR.PATCH, increment the:
96
+
97
+ 1. MAJOR version when you make incompatible API changes,
98
+ 2. MINOR version when you add functionality in a backwards-compatible manner, and
99
+ 3. PATCH version when you make backwards-compatible bug fixes.
100
+
101
+ Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.
102
+
89
103
  ## Contributing
90
104
 
91
105
  Currently this client supports read-only access to Pivotal Tracker.
@@ -9,7 +9,18 @@ module TrackerApi
9
9
 
10
10
  def create(project_id, story_id, params={})
11
11
  data = client.post("/projects/#{project_id}/stories/#{story_id}/tasks", params: params).body
12
- Resources::Task.new(data)
12
+ Resources::Task.new({ client: client }.merge(data))
13
+ end
14
+
15
+ def update(task, params={})
16
+ raise ArgumentError, 'Valid task required to update.' unless task.instance_of?(Resources::Task)
17
+
18
+ data = client.put("/projects/#{task.project_id}/stories/#{task.story_id}/tasks/#{task.id}",
19
+ params: params).body
20
+
21
+ task.attributes = data
22
+ task.clean!
23
+ task
13
24
  end
14
25
  end
15
26
  end
@@ -12,7 +12,9 @@ module TrackerApi
12
12
  raise Errors::UnexpectedData, 'Array of tasks expected' unless data.is_a? Array
13
13
 
14
14
  data.map do |task|
15
- Resources::Task.new({ story_id: story_id }.merge(task))
15
+ Resources::Task.new({ client: client,
16
+ project_id: project_id,
17
+ story_id: story_id }.merge(task))
16
18
  end
17
19
  end
18
20
  end
@@ -3,6 +3,9 @@ module TrackerApi
3
3
  class Task
4
4
  include Shared::Base
5
5
 
6
+ attribute :client
7
+
8
+ attribute :project_id, Integer
6
9
  attribute :story_id, Integer
7
10
  attribute :description, String
8
11
  attribute :complete, Boolean
@@ -10,6 +13,22 @@ module TrackerApi
10
13
  attribute :created_at, DateTime
11
14
  attribute :updated_at, DateTime
12
15
  attribute :kind, String
16
+
17
+ class UpdateRepresenter < Representable::Decorator
18
+ include Representable::JSON
19
+
20
+ property :id
21
+ property :description
22
+ property :complete
23
+ property :position
24
+ end
25
+
26
+ def save
27
+ raise ArgumentError, 'Cannot update a task with an unknown project_id.' if project_id.nil?
28
+ raise ArgumentError, 'Cannot update a task with an unknown story_id.' if story_id.nil?
29
+
30
+ Endpoints::Task.new(client).update(self, UpdateRepresenter.new(Task.new(self.dirty_attributes)))
31
+ end
13
32
  end
14
33
  end
15
34
  end
@@ -1,3 +1,3 @@
1
1
  module TrackerApi
2
- VERSION = '1.0.0'
2
+ VERSION = '1.1.0'
3
3
  end
data/test/task_test.rb ADDED
@@ -0,0 +1,27 @@
1
+ require_relative 'minitest_helper'
2
+
3
+ describe TrackerApi::Resources::Task do
4
+ let(:pt_user) { PT_USER_1 }
5
+ let(:client) { TrackerApi::Client.new token: pt_user[:token] }
6
+ let(:project_id) { pt_user[:project_id] }
7
+ let(:project) { VCR.use_cassette('get project') { client.project(project_id) } }
8
+ let(:story_id) { '66728004' }
9
+ let(:story) { VCR.use_cassette('get story') { project.story(story_id) } }
10
+ let(:tasks) { VCR.use_cassette('get tasks', record: :new_episodes) {
11
+ VCR.use_cassette('get tasks for story') { story.tasks } } }
12
+ let(:task) { tasks.first }
13
+
14
+ it 'can update an existing task' do
15
+ new_description = "#{task.description}+"
16
+ task.description = new_description
17
+ task.complete = true
18
+
19
+ VCR.use_cassette('save task', record: :new_episodes) do
20
+ task.save
21
+ end
22
+
23
+ task.description.must_equal new_description
24
+ task.complete.must_equal true
25
+ task.clean?.must_equal true
26
+ end
27
+ end
@@ -0,0 +1 @@
1
+ {"http_interactions":[{"request":{"method":"put","uri":"https://www.pivotaltracker.com/services/v5/projects/1027488/stories/66728004/tasks/22778038","body":{"encoding":"UTF-8","string":"{\"description\":\"Check unscaled+\",\"complete\":true}"},"headers":{"User-Agent":["Ruby/2.1.3 (x86_64-darwin15.0; ruby) TrackerApi/1.0.0 Faraday/0.9.2"],"X-TrackerToken":["d55c3bc1f74346b843ca84ba340b29bf"],"Content-Type":["application/json"]}},"response":{"status":{"code":200,"message":null},"headers":{"Content-Type":["application/json; charset=utf-8"],"Status":["200 OK"],"Cache-Control":["max-age=0, private, must-revalidate"],"Date":["Fri, 18 Mar 2016 19:14:30 GMT"],"X-Tracker-Project-Version":["122"],"X-Request-Id":["8e0ec08fef65b2f8fa9bae27a697c8db"],"X-UA-Compatible":["IE=Edge,chrome=1"],"ETag":["\"914ce4063b95be351bc4878e1242b175\""],"X-Runtime":["0.175452"],"X-Rack-Cache":["invalidate, pass"],"X-Powered-By":["Phusion Passenger Enterprise"],"Server":["nginx + Phusion Passenger"],"Access-Control-Allow-Origin":["*"],"Access-Control-Allow-Credentials":["false"],"Access-Control-Allow-Methods":["GET, POST, PUT, DELETE, OPTIONS"],"Access-Control-Allow-Headers":["X-TrackerToken,DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,X-Tracker-Warn-Unless-Project-Version-Is"],"X-Tracker-Client-Pinger-Interval":["12"]},"body":{"encoding":"UTF-8","string":"{\"kind\":\"task\",\"id\":22778038,\"story_id\":66728004,\"description\":\"Check unscaled+\",\"complete\":true,\"position\":1,\"created_at\":\"2014-06-02T12:44:52Z\",\"updated_at\":\"2016-03-18T19:14:30Z\"}"},"http_version":null},"recorded_at":"Fri, 18 Mar 2016 19:14:30 GMT"}],"recorded_with":"VCR 3.0.1"}
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: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Forest Carlisle
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-18 00:00:00.000000000 Z
11
+ date: 2016-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -268,6 +268,7 @@ files:
268
268
  - test/minitest_helper.rb
269
269
  - test/project_test.rb
270
270
  - test/story_test.rb
271
+ - test/task_test.rb
271
272
  - test/vcr/cassettes/client_done_iterations_with_pagination.json
272
273
  - test/vcr/cassettes/client_get_all_stories_with_pagination.json
273
274
  - test/vcr/cassettes/client_get_limited_stories_with_no_pagination.json
@@ -304,6 +305,7 @@ files:
304
305
  - test/vcr/cassettes/save_story.json
305
306
  - test/vcr/cassettes/save_story_with_multiple_changes.json
306
307
  - test/vcr/cassettes/save_story_with_new_label.json
308
+ - test/vcr/cassettes/save_task.json
307
309
  - test/vcr/cassettes/update_story_to_create_activity.json
308
310
  - tracker_api.gemspec
309
311
  homepage: https://github.com/dashofcode/tracker_api
@@ -335,6 +337,7 @@ test_files:
335
337
  - test/minitest_helper.rb
336
338
  - test/project_test.rb
337
339
  - test/story_test.rb
340
+ - test/task_test.rb
338
341
  - test/vcr/cassettes/client_done_iterations_with_pagination.json
339
342
  - test/vcr/cassettes/client_get_all_stories_with_pagination.json
340
343
  - test/vcr/cassettes/client_get_limited_stories_with_no_pagination.json
@@ -371,4 +374,5 @@ test_files:
371
374
  - test/vcr/cassettes/save_story.json
372
375
  - test/vcr/cassettes/save_story_with_multiple_changes.json
373
376
  - test/vcr/cassettes/save_story_with_new_label.json
377
+ - test/vcr/cassettes/save_task.json
374
378
  - test/vcr/cassettes/update_story_to_create_activity.json