pivotal_tracker_api 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NGI5Mjg3YWU0NzQwMzhmM2IwOGE0ZjU3YTM3NDQ0OTliODQxNjAzZg==
5
+ data.tar.gz: !binary |-
6
+ MTA2MzNlNTI2NmMwMTRkZTFkN2RjNjMyMDhkZTc3Y2EyMmQ3NGQ0NQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ Y2U3YjY2ZGU3ZjFkMzBmYzYxMjI1OTY5MmRjM2FmMGU2MmVlNmE1NmYxNGE3
10
+ ZjQ1MDdjZmYyZmRjNGQzYjc2YTg1ZjA3MmUzODM1NzM3MjQ3NDAzYTBjMjE1
11
+ ZjJlNzQ0OTBjNmFjOGQzMWQzNDk1MzI1YTk0NzVjYjhjZGYyMjc=
12
+ data.tar.gz: !binary |-
13
+ OTZlMmQ0YTNjMmY1ZjY1ZWNjM2Y1NmYwOTVjYWU0OGI2ZTk0ZjViNGJjNzUx
14
+ NTE1MTY0YjZmMzg2MTJkMmUyOTEwOWUxNWQzOGU3NjZiM2M3NDlmZDY3YWZh
15
+ NzdiMTU2MzAzNTk3NjQ1ZGFiZDA5YTYwYWM3ZWI3ZmIyYjM4Y2E=
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in pivotal_tracker_api.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Fabien Garcia
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,31 @@
1
+ # PivotalTrackerApi
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'pivotal_tracker_api'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install pivotal_tracker_api
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/pivotal_tracker_api/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,73 @@
1
+ require 'rest_client'
2
+ require 'net/http/post/multipart'
3
+ require "pivotal_tracker_api/version"
4
+ require "pivotal_tracker_api/project_membership"
5
+ require "pivotal_tracker_api/project"
6
+ require "pivotal_tracker_api/story"
7
+
8
+ module PivotalTrackerApi
9
+ class ArgumentError < Exception; end
10
+ class NotFound < Exception; end
11
+ class ApiError < Exception; end
12
+ class API
13
+ include PivotalTrackerApi::Story
14
+ include PivotalTrackerApi::Project
15
+ include PivotalTrackerApi::ProjectMembership
16
+ DOMAIN_URL = "https://www.pivotaltracker.com"
17
+ API_URL = "https://www.pivotaltracker.com/services/v5"
18
+
19
+ attr_accessor :token
20
+
21
+ def initialize(token_api, params={})
22
+ @token= token_api
23
+ end
24
+
25
+ def get(path, params={})
26
+ parse_response service[path].get(params)
27
+ end
28
+
29
+ def put(path, params={} )
30
+ parse_response service[path].put(params)
31
+ end
32
+
33
+ def post(path, params={}, headers={})
34
+ parse_response service[path].post(params, headers)
35
+ end
36
+
37
+ def upload(path, filename)
38
+ url = URI.parse(API_URL+path)
39
+ req = Net::HTTP::Post::Multipart.new( url.path, "file" => UploadIO.new(filename, "multipart/form-data"))
40
+ http = Net::HTTP.new(url.host, url.port)
41
+ req["X-TrackerToken"] = @token
42
+ # to debug
43
+ # http.set_debug_output($stderr)
44
+
45
+ if url.scheme == 'https'
46
+ http.use_ssl = true
47
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
48
+ end
49
+
50
+ response = http.request(req)
51
+ parse_response response
52
+ end
53
+
54
+ def delete(path, params={})
55
+ parse_response service[path].delete
56
+ end
57
+ protected
58
+ def parse_response(response)
59
+ case response.code.to_i
60
+ when 200, 201
61
+ JSON.parse(response.body)
62
+ when 404
63
+ raise NotFound.new(response)
64
+ else
65
+ raise ApiError.new(response)
66
+ end
67
+ end
68
+ def service
69
+ return @service if @service
70
+ @service = ::RestClient::Resource.new(API_URL, :headers => {'X-TrackerToken' => @token} )
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,12 @@
1
+ module PivotalTrackerApi
2
+ module Project
3
+
4
+ def projects(params={})
5
+ get '/projects', params
6
+ end
7
+
8
+ def find_project_by_id(id, params={})
9
+ get "/projects/#{id}", params
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,9 @@
1
+ module PivotalTrackerApi
2
+ module ProjectMembership
3
+
4
+ def find_membership_by_project_id(project_id, params={})
5
+ get "/projects/#{project_id}/memberships", params
6
+ end
7
+
8
+ end
9
+ end
@@ -0,0 +1,35 @@
1
+ module PivotalTrackerApi
2
+ module Story
3
+
4
+ def find_stories_by_project_id(project_id, params={})
5
+ get "/projects/#{project_id}/stories"
6
+ end
7
+
8
+ def find_story_by_project_id_and_id(project_id, id, params={})
9
+ get "/projects/#{project_id}/stories/#{id}"
10
+ end
11
+
12
+ def upload_attachment(project_id, id, filename, params={})
13
+ raise ArgumentError.new(":project_id is required") unless project_id
14
+ raise ArgumentError.new(":id is required") unless id
15
+ raise ArgumentError.new(":filename is required") unless filename
16
+ attachment = create_attachment project_id, filename
17
+ upload_url = "https://www.pivotaltracker.com/#{attachment['download_url']}"
18
+ create_comment project_id, id, "text" => upload_url
19
+ end
20
+ def update_story(project_id, id, params)
21
+ put "projects/#{project_id}/stories/#{id}", params
22
+ end
23
+ def create_comment(project_id, story_id, params={})
24
+ post "/projects/#{project_id}/stories/#{story_id}/comments", params
25
+ end
26
+ def create_story(project_id, params={})
27
+ raise ArgumentError.new(":name is required") if params[:name].nil?
28
+ post "/projects/#{project_id}/stories", params
29
+ end
30
+ def create_attachment(project_id, filename)
31
+ upload "/projects/#{project_id}/uploads", File.new(filename)
32
+ # post "/projects/#{project_id}/uploads", :file => File.new(filename), :multipart => true
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,3 @@
1
+ module PivotalTrackerApi
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'pivotal_tracker_api/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "pivotal_tracker_api"
8
+ spec.version = PivotalTrackerApi::VERSION
9
+ spec.authors = ["Fabien Garcia"]
10
+ spec.email = ["fab0670312047@gmail.com"]
11
+ spec.summary = "Ruby wrapper for the Pivotal Tracker API"
12
+ spec.description = "Ruby wrapper for the Pivotal Tracker API based on V5"
13
+ spec.homepage = "https://github.com/testCloud"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "rspec", ">= 0"
24
+ spec.add_runtime_dependency "rest-client", ">= 1.6.0"
25
+ spec.add_development_dependency "pry"
26
+ spec.add_development_dependency "webmock"
27
+ spec.add_dependency "multipart-post"
28
+ end
@@ -0,0 +1,14 @@
1
+ {
2
+ "big_url": "#",
3
+ "content_type": "image/jpeg",
4
+ "created_at": "2014-10-07T12:00:00Z",
5
+ "download_url": "/file_attachments/300/download",
6
+ "filename": "new-imperial-logo-6.jpg",
7
+ "id": 300,
8
+ "kind": "file_attachment",
9
+ "size": 7683,
10
+ "thumbnail_url": "#",
11
+ "thumbnailable": true,
12
+ "uploaded": false,
13
+ "uploader_id": 101
14
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "created_at": "2014-10-07T12:00:00Z",
3
+ "id": 300,
4
+ "kind": "comment",
5
+ "person_id": 101,
6
+ "story_id": 555,
7
+ "text": "If this is a consular ship, then where is the ambassador?",
8
+ "updated_at": "2014-10-07T12:00:00Z"
9
+ }
@@ -0,0 +1,135 @@
1
+ [
2
+ {
3
+ "kind": "project_membership",
4
+ "id": 100,
5
+ "person":
6
+ {
7
+ "kind": "person",
8
+ "id": 100,
9
+ "name": "Emperor Palpatine",
10
+ "email": "emperor@galacticrepublic.gov",
11
+ "initials": "EP",
12
+ "username": "palpatine"
13
+ },
14
+ "project_id": 99,
15
+ "role": "owner",
16
+ "project_color": "8100ea",
17
+ "last_viewed_at": "2014-10-07T12:00:00Z",
18
+ "wants_comment_notification_emails": false,
19
+ "will_receive_mention_notifications_or_emails": true
20
+ },
21
+ {
22
+ "kind": "project_membership",
23
+ "id": 101,
24
+ "person":
25
+ {
26
+ "kind": "person",
27
+ "id": 101,
28
+ "name": "Darth Vader",
29
+ "email": "vader@deathstar.mil",
30
+ "initials": "DV",
31
+ "username": "vader"
32
+ },
33
+ "project_id": 99,
34
+ "role": "member",
35
+ "project_color": "8100ea",
36
+ "last_viewed_at": "2014-10-07T12:00:00Z",
37
+ "wants_comment_notification_emails": true,
38
+ "will_receive_mention_notifications_or_emails": true
39
+ },
40
+ {
41
+ "kind": "project_membership",
42
+ "id": 102,
43
+ "person":
44
+ {
45
+ "kind": "person",
46
+ "id": 102,
47
+ "name": "Wilhuff Tarkin",
48
+ "email": "governor@eriadu.gov",
49
+ "initials": "WT",
50
+ "username": "tarkin"
51
+ },
52
+ "project_id": 99,
53
+ "role": "owner",
54
+ "project_color": "8100ea",
55
+ "last_viewed_at": "2014-10-07T12:00:00Z",
56
+ "wants_comment_notification_emails": false,
57
+ "will_receive_mention_notifications_or_emails": true
58
+ },
59
+ {
60
+ "kind": "project_membership",
61
+ "id": 103,
62
+ "person":
63
+ {
64
+ "kind": "person",
65
+ "id": 103,
66
+ "name": "Moradmin Bast",
67
+ "email": "bast@deathstar.mil",
68
+ "initials": "MB",
69
+ "username": "bast"
70
+ },
71
+ "project_id": 99,
72
+ "role": "member",
73
+ "project_color": "8100ea",
74
+ "last_viewed_at": "2014-10-07T12:00:00Z",
75
+ "wants_comment_notification_emails": true,
76
+ "will_receive_mention_notifications_or_emails": true
77
+ },
78
+ {
79
+ "kind": "project_membership",
80
+ "id": 104,
81
+ "person":
82
+ {
83
+ "kind": "person",
84
+ "id": 104,
85
+ "name": "Clone TK421",
86
+ "email": "tk421@deathstar.mil",
87
+ "initials": "TK421",
88
+ "username": "tk421"
89
+ },
90
+ "project_id": 99,
91
+ "role": "member",
92
+ "project_color": "8100ea",
93
+ "last_viewed_at": "2014-10-07T12:00:00Z",
94
+ "wants_comment_notification_emails": true,
95
+ "will_receive_mention_notifications_or_emails": true
96
+ },
97
+ {
98
+ "kind": "project_membership",
99
+ "id": 105,
100
+ "person":
101
+ {
102
+ "kind": "person",
103
+ "id": 105,
104
+ "name": "Robotic Maintenance Team 4",
105
+ "email": "I662@deathstar.mil",
106
+ "initials": "i662",
107
+ "username": "i662"
108
+ },
109
+ "project_id": 99,
110
+ "role": "member",
111
+ "project_color": "8100ea",
112
+ "last_viewed_at": "2014-10-07T12:00:00Z",
113
+ "wants_comment_notification_emails": true,
114
+ "will_receive_mention_notifications_or_emails": true
115
+ },
116
+ {
117
+ "kind": "project_membership",
118
+ "id": 107,
119
+ "person":
120
+ {
121
+ "kind": "person",
122
+ "id": 107,
123
+ "name": "Bevel Lemelisk",
124
+ "email": "bevel@sith.mil",
125
+ "initials": "bl",
126
+ "username": "bevel"
127
+ },
128
+ "project_id": 99,
129
+ "role": "viewer",
130
+ "project_color": "8100ea",
131
+ "last_viewed_at": "2014-10-07T12:00:05Z",
132
+ "wants_comment_notification_emails": false,
133
+ "will_receive_mention_notifications_or_emails": true
134
+ }
135
+ ]
@@ -0,0 +1,18 @@
1
+ {
2
+ "created_at": "2014-10-07T12:00:00Z",
3
+ "current_state": "unscheduled",
4
+ "id": 2300,
5
+ "kind": "story",
6
+ "labels":
7
+ [
8
+ ],
9
+ "name": "Exhaust ports are ray shielded",
10
+ "owner_ids":
11
+ [
12
+ ],
13
+ "project_id": 99,
14
+ "requested_by_id": 101,
15
+ "story_type": "feature",
16
+ "updated_at": "2014-10-07T12:00:00Z",
17
+ "url": "http://localhost/story/show/2300"
18
+ }
@@ -0,0 +1,35 @@
1
+ {
2
+ "account_id": 100,
3
+ "atom_enabled": true,
4
+ "automatic_planning": true,
5
+ "bugs_and_chores_are_estimatable": false,
6
+ "created_at": "2014-10-07T12:00:05Z",
7
+ "current_iteration_number": 15,
8
+ "description": "Expeditionary Battle Planetoid",
9
+ "enable_following": true,
10
+ "enable_incoming_emails": true,
11
+ "enable_tasks": true,
12
+ "has_google_domain": false,
13
+ "id": 99,
14
+ "initial_velocity": 10,
15
+ "iteration_length": 1,
16
+ "kind": "project",
17
+ "name": "Death Star",
18
+ "number_of_done_iterations_to_show": 12,
19
+ "point_scale": "0,1,2,3",
20
+ "point_scale_is_custom": false,
21
+ "profile_content": "This is a machine of war such as the universe has never known. It's colossal, the size of a class-four moon. And it possesses firepower unequaled in the history of warfare.",
22
+ "public": false,
23
+ "start_date": "2014-06-23",
24
+ "start_time": "2014-10-07T12:00:10Z",
25
+ "time_zone":
26
+ {
27
+ "kind": "time_zone",
28
+ "olson_name": "America/Los_Angeles",
29
+ "offset": "-07:00"
30
+ },
31
+ "updated_at": "2014-10-07T12:00:10Z",
32
+ "velocity_averaged_over": 3,
33
+ "version": 62,
34
+ "week_start_day": "Monday"
35
+ }
@@ -0,0 +1,69 @@
1
+ [
2
+ {
3
+ "id": 98,
4
+ "kind": "project",
5
+ "name": "Learn About the Force",
6
+ "version": 2,
7
+ "iteration_length": 1,
8
+ "week_start_day": "Monday",
9
+ "point_scale": "0,1,2,3",
10
+ "point_scale_is_custom": false,
11
+ "bugs_and_chores_are_estimatable": false,
12
+ "automatic_planning": true,
13
+ "enable_tasks": true,
14
+ "time_zone":
15
+ {
16
+ "kind": "time_zone",
17
+ "olson_name": "America/Los_Angeles",
18
+ "offset": "-07:00"
19
+ },
20
+ "velocity_averaged_over": 3,
21
+ "number_of_done_iterations_to_show": 12,
22
+ "has_google_domain": false,
23
+ "enable_incoming_emails": true,
24
+ "initial_velocity": 10,
25
+ "public": false,
26
+ "atom_enabled": true,
27
+ "start_time": "2014-10-07T12:00:05Z",
28
+ "created_at": "2014-10-07T12:00:10Z",
29
+ "updated_at": "2014-10-07T12:00:15Z",
30
+ "account_id": 100,
31
+ "current_iteration_number": 1,
32
+ "enable_following": true
33
+ },
34
+ {
35
+ "id": 99,
36
+ "kind": "project",
37
+ "name": "Death Star",
38
+ "version": 62,
39
+ "iteration_length": 1,
40
+ "week_start_day": "Monday",
41
+ "point_scale": "0,1,2,3",
42
+ "point_scale_is_custom": false,
43
+ "bugs_and_chores_are_estimatable": false,
44
+ "automatic_planning": true,
45
+ "enable_tasks": true,
46
+ "time_zone":
47
+ {
48
+ "kind": "time_zone",
49
+ "olson_name": "America/Los_Angeles",
50
+ "offset": "-07:00"
51
+ },
52
+ "velocity_averaged_over": 3,
53
+ "number_of_done_iterations_to_show": 12,
54
+ "has_google_domain": false,
55
+ "description": "Expeditionary Battle Planetoid",
56
+ "profile_content": "This is a machine of war such as the universe has never known. It's colossal, the size of a class-four moon. And it possesses firepower unequaled in the history of warfare.",
57
+ "enable_incoming_emails": true,
58
+ "initial_velocity": 10,
59
+ "public": false,
60
+ "atom_enabled": true,
61
+ "start_date": "2014-06-23",
62
+ "start_time": "2014-10-07T12:00:15Z",
63
+ "created_at": "2014-10-07T12:00:10Z",
64
+ "updated_at": "2014-10-07T12:00:15Z",
65
+ "account_id": 100,
66
+ "current_iteration_number": 15,
67
+ "enable_following": true
68
+ }
69
+ ]
@@ -0,0 +1 @@
1
+ {"comment":{"text":"Here are the new plans.","file_attachments":[{"type":"file_attachment","id":21,"filename":"Corellian corvette deck plan.tiff","created_at":1412683200000,"uploader_id":101,"thumbnailable":false,"height":216,"width":650,"size":561878,"download_url":"/attachments/0000/0021/Corellian corvette deck plan_big.tiff","thumbnail_url":"/attachments/0000/0021/Corellian corvette deck plan_thumb.tiff"}]},"current_state":"rejected"}
@@ -0,0 +1,87 @@
1
+ [
2
+ {
3
+ "kind": "story",
4
+ "id": 560,
5
+ "created_at": 1412683200000,
6
+ "updated_at": 1412683200000,
7
+ "story_type": "bug",
8
+ "name": "Tractor beam loses power intermittently",
9
+ "current_state": "unstarted",
10
+ "requested_by_id": 102,
11
+ "project_id": 99,
12
+ "url": "http://localhost/story/show/560",
13
+ "owner_ids":
14
+ [
15
+ ],
16
+ "labels":
17
+ [
18
+ ]
19
+ },
20
+ {
21
+ "kind": "story",
22
+ "id": 565,
23
+ "created_at": 1412683200000,
24
+ "updated_at": 1412683200000,
25
+ "story_type": "chore",
26
+ "name": "Repair CommLink",
27
+ "description": "It's malfunctioning.",
28
+ "current_state": "unstarted",
29
+ "requested_by_id": 104,
30
+ "project_id": 99,
31
+ "url": "http://localhost/story/show/565",
32
+ "owner_ids":
33
+ [
34
+ ],
35
+ "labels":
36
+ [
37
+ {
38
+ "id": 2010,
39
+ "project_id": 99,
40
+ "kind": "label",
41
+ "name": "mnt",
42
+ "created_at": 1412683200000,
43
+ "updated_at": 1412683200000
44
+ }
45
+ ]
46
+ },
47
+ {
48
+ "kind": "story",
49
+ "id": 552,
50
+ "created_at": 1412683200000,
51
+ "updated_at": 1412683200000,
52
+ "deadline": 1412683205000,
53
+ "story_type": "release",
54
+ "name": "Battlestation fully operational",
55
+ "description": "Everything is proceeding as I have foreseen.",
56
+ "current_state": "unstarted",
57
+ "requested_by_id": 100,
58
+ "project_id": 99,
59
+ "url": "http://localhost/story/show/552",
60
+ "owner_ids":
61
+ [
62
+ ],
63
+ "labels":
64
+ [
65
+ ]
66
+ },
67
+ {
68
+ "kind": "story",
69
+ "id": 555,
70
+ "created_at": 1412683200000,
71
+ "updated_at": 1412683200000,
72
+ "estimate": 2,
73
+ "story_type": "feature",
74
+ "name": "Bring me the passengers",
75
+ "description": "ignore the droids",
76
+ "current_state": "unstarted",
77
+ "requested_by_id": 101,
78
+ "project_id": 99,
79
+ "url": "http://localhost/story/show/555",
80
+ "owner_ids":
81
+ [
82
+ ],
83
+ "labels":
84
+ [
85
+ ]
86
+ }
87
+ ]
@@ -0,0 +1,20 @@
1
+ {
2
+ "created_at": "2014-10-07T12:00:00Z",
3
+ "current_state": "unstarted",
4
+ "description": "ignore the droids",
5
+ "estimate": 2,
6
+ "id": 555,
7
+ "kind": "story",
8
+ "labels":
9
+ [
10
+ ],
11
+ "name": "Bring me the passengers",
12
+ "owner_ids":
13
+ [
14
+ ],
15
+ "project_id": 99,
16
+ "requested_by_id": 101,
17
+ "story_type": "feature",
18
+ "updated_at": "2014-10-07T12:00:00Z",
19
+ "url": "http://localhost/story/show/555"
20
+ }
@@ -0,0 +1,74 @@
1
+ {
2
+ "comments":
3
+ [
4
+ {
5
+ "text": "I want them alive!",
6
+ "file_attachments":
7
+ [
8
+ {
9
+ "kind": "file_attachment",
10
+ "id": 21,
11
+ "filename": "Corellian corvette deck plan.tiff",
12
+ "created_at": "2014-10-07T12:00:05Z",
13
+ "uploader_id": 101,
14
+ "thumbnailable": false,
15
+ "height": 216,
16
+ "width": 650,
17
+ "size": 561878,
18
+ "download_url": "/attachments/0000/0021/Corellian corvette deck plan_big.tiff",
19
+ "thumbnail_url": "/attachments/0000/0021/Corellian corvette deck plan_thumb.tiff"
20
+ },
21
+ {
22
+ "kind": "file_attachment",
23
+ "id": 20,
24
+ "filename": "empire.png",
25
+ "created_at": "2014-10-07T12:00:00Z",
26
+ "uploader_id": 100,
27
+ "thumbnailable": true,
28
+ "height": 804,
29
+ "width": 1000,
30
+ "size": 82382,
31
+ "download_url": "/attachments/0000/0020/empire_big.png",
32
+ "thumbnail_url": "/attachments/0000/0020/empire_thumb.png"
33
+ }
34
+ ],
35
+ "id": 111
36
+ },
37
+ {
38
+ "text": "Here are the new plans.",
39
+ "file_attachments":
40
+ [
41
+ {
42
+ "kind": "file_attachment",
43
+ "id": 21,
44
+ "filename": "Corellian corvette deck plan.tiff",
45
+ "created_at": "2014-10-07T12:00:05Z",
46
+ "uploader_id": 101,
47
+ "thumbnailable": false,
48
+ "height": 216,
49
+ "width": 650,
50
+ "size": 561878,
51
+ "download_url": "/attachments/0000/0021/Corellian corvette deck plan_big.tiff",
52
+ "thumbnail_url": "/attachments/0000/0021/Corellian corvette deck plan_thumb.tiff"
53
+ }
54
+ ],
55
+ "id": 300
56
+ }
57
+ ],
58
+ "id": 555,
59
+ "labels":
60
+ [
61
+ ],
62
+ "requested_by":
63
+ {
64
+ "kind": "person",
65
+ "id": 101,
66
+ "name": "Darth Vader",
67
+ "email": "vader@deathstar.mil",
68
+ "initials": "DV",
69
+ "username": "vader"
70
+ },
71
+ "tasks":
72
+ [
73
+ ]
74
+ }
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Comment" do
4
+ before :all do
5
+ @token = "wertyuioppoiuyt"
6
+ @project_id = 99
7
+ @story_id = 555
8
+ @service = PivotalTrackerApi::API.new(@token)
9
+ end
10
+ it "should create comment on story" do
11
+ comment = File.read "spec/fixtures/comment.json"
12
+ stub_request(:post, "#{API_URL}/projects/#{@project_id}/stories/#{@story_id}/comments").to_return(:status => 200, :body => comment)
13
+
14
+ res = @service.create_comment(@project_id, @story_id, :text => "If this is a consular ship, then where is the ambassador?")
15
+ expect(res).to eq(JSON.parse(comment))
16
+ end
17
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Membership" do
4
+ before :all do
5
+ @token = "wertyuioppoiuyt"
6
+ @project_id = 99
7
+ @service = PivotalTrackerApi::API.new(@token)
8
+ end
9
+ it "should find every membership by project id" do
10
+ memberships = File.read "spec/fixtures/memberships.json"
11
+ stub_request(:get, "#{API_URL}/projects/#{@project_id}/memberships").to_return(:status => 200, :body => memberships)
12
+
13
+ res = @service.find_membership_by_project_id(@project_id)
14
+ expect(res).to eq(JSON.parse(memberships))
15
+
16
+ end
17
+
18
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Project" do
4
+ before :all do
5
+ @token = "wertyuioppoiuyt"
6
+ @project_id = 99
7
+ @service = PivotalTrackerApi::API.new(@token)
8
+ end
9
+ it "should find every project" do
10
+ projects = File.read "spec/fixtures/projects.json"
11
+ stub_request(:get, "#{API_URL}/projects")
12
+ .with(:headers => {'Accept'=>'*/*; q=0.5, application/xml', 'Accept-Encoding'=>'gzip, deflate', 'User-Agent'=>'Ruby', 'X-Trackertoken'=> @token })
13
+ .to_return(:status => 200, :body => projects)
14
+
15
+ res = @service.projects
16
+ expect(res).to eq(JSON.parse(projects))
17
+ end
18
+
19
+ it "should find specific project" do
20
+ project = File.read "spec/fixtures/project.json"
21
+ stub_request(:get, "#{API_URL}/projects/#{@project_id}").to_return(:status => 200, :body => project)
22
+
23
+ res = @service.find_project_by_id(@project_id)
24
+ expect(res).to eq(JSON.parse(project))
25
+ end
26
+ end
@@ -0,0 +1,52 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Stories" do
4
+ before :all do
5
+ @project_id = 99
6
+ @story_id = 555
7
+ @token = "wertyuioppoiuyt"
8
+ @service = PivotalTrackerApi::API.new(@token)
9
+ end
10
+ it "should find every stories of a project" do
11
+ stories = File.read "spec/fixtures/stories.json"
12
+ stub_request(:get, "#{API_URL}/projects/#{@project_id}/stories").to_return(:status => 200, :body => stories)
13
+ res = @service.find_stories_by_project_id(@project_id)
14
+ expect(res).to eq(JSON.parse(stories))
15
+ end
16
+
17
+ it "should find specfic story" do
18
+ story = File.read "spec/fixtures/story.json"
19
+ stub_request(:get, "#{API_URL}/projects/#{@project_id}/stories/#{@story_id}").to_return(:status => 200, :body => story)
20
+ res = @service.find_story_by_project_id_and_id(@project_id, @story_id)
21
+ expect(res).to eq(JSON.parse(story))
22
+ end
23
+ it "should create a story" do
24
+ new_story = File.read "spec/fixtures/new_story.json"
25
+ stub_request(:post, "#{API_URL}/projects/#{@project_id}/stories")
26
+ .with(:body => {"name" => "Exhaust ports are ray shielded"} )
27
+ .to_return(:status => 200, :body => new_story)
28
+
29
+ res = @service.create_story(@project_id, :name => "Exhaust ports are ray shielded")
30
+ expect(res).to eq(JSON.parse(new_story))
31
+ end
32
+ it "should raise an error for unvalid story creation" do
33
+ expect { @service.create_story(@project_id, :other_attribute => "wrong") }.to raise_error(PivotalTrackerApi::ArgumentError)
34
+ end
35
+ it "should upload attachment" do
36
+ attachment = File.read "spec/fixtures/attachment.json"
37
+ request_story_update = File.read "spec/fixtures/request_story_update.json"
38
+ story_updated = File.read "spec/fixtures/story_updated.json"
39
+
40
+ stub_request(:post, "#{API_URL}/projects/#{@project_id}/uploads").to_return(:status => 200, :body => attachment)
41
+ # stub_request(:put, "#{API_URL}/projects/#{@project_id}/stories/#{@story_id}").with(:body => request_story_update).to_return(:status => 200, :body => story_updated)
42
+
43
+ stub_request(:post, "https://www.pivotaltracker.com/services/v5/projects/#{@project_id}/stories/#{@story_id}/comments")
44
+ .with(:body => {"text"=>"https://www.pivotaltracker.com/file_attachments/300/download"},
45
+ :headers => {'Accept'=>'*/*; q=0.5, application/xml', 'Accept-Encoding'=>'gzip, deflate', 'Content-Length'=>'77', 'Content-Type'=>'application/x-www-form-urlencoded', 'User-Agent'=>'Ruby', 'X-Trackertoken'=>@token})
46
+ .to_return(:status => 200, :body => story_updated)
47
+
48
+
49
+ res = @service.upload_attachment(@project_id, @story_id, "spec/fixtures/new-imperial-logo-6.jpg")
50
+ expect(res).to eq(JSON.parse(story_updated))
51
+ end
52
+ end
@@ -0,0 +1,15 @@
1
+ require 'rspec'
2
+ require 'webmock/rspec'
3
+ require 'pry'
4
+ require 'pivotal_tracker_api'
5
+ # Requires supporting files with custom matchers and macros, etc,
6
+ # in ./support/ and its subdirectories.
7
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
8
+ API_URL = PivotalTrackerApi::API.const_get("API_URL")
9
+
10
+ RSpec.configure do |config|
11
+
12
+ # Allow focus on a specific test if specified
13
+ config.filter_run :focus => true
14
+ config.run_all_when_everything_filtered = true
15
+ end
metadata ADDED
@@ -0,0 +1,187 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pivotal_tracker_api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Fabien Garcia
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rest-client
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 1.6.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: 1.6.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: webmock
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'
97
+ - !ruby/object:Gem::Dependency
98
+ name: multipart-post
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ! '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: Ruby wrapper for the Pivotal Tracker API based on V5
112
+ email:
113
+ - fab0670312047@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - .gitignore
119
+ - .rspec
120
+ - Gemfile
121
+ - LICENSE.txt
122
+ - README.md
123
+ - Rakefile
124
+ - lib/pivotal_tracker_api.rb
125
+ - lib/pivotal_tracker_api/project.rb
126
+ - lib/pivotal_tracker_api/project_membership.rb
127
+ - lib/pivotal_tracker_api/story.rb
128
+ - lib/pivotal_tracker_api/version.rb
129
+ - pivotal_tracker_api.gemspec
130
+ - spec/fixtures/attachment.json
131
+ - spec/fixtures/comment.json
132
+ - spec/fixtures/memberships.json
133
+ - spec/fixtures/new-imperial-logo-6.jpg
134
+ - spec/fixtures/new_story.json
135
+ - spec/fixtures/project.json
136
+ - spec/fixtures/projects.json
137
+ - spec/fixtures/request_story_update.json
138
+ - spec/fixtures/stories.json
139
+ - spec/fixtures/story.json
140
+ - spec/fixtures/story_updated.json
141
+ - spec/pivotal_traker_api/comment_spec.rb
142
+ - spec/pivotal_traker_api/membership_spec.rb
143
+ - spec/pivotal_traker_api/project_spec.rb
144
+ - spec/pivotal_traker_api/story_spec.rb
145
+ - spec/spec_helper.rb
146
+ homepage: https://github.com/testCloud
147
+ licenses:
148
+ - MIT
149
+ metadata: {}
150
+ post_install_message:
151
+ rdoc_options: []
152
+ require_paths:
153
+ - lib
154
+ required_ruby_version: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - ! '>='
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
159
+ required_rubygems_version: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - ! '>='
162
+ - !ruby/object:Gem::Version
163
+ version: '0'
164
+ requirements: []
165
+ rubyforge_project:
166
+ rubygems_version: 2.0.14
167
+ signing_key:
168
+ specification_version: 4
169
+ summary: Ruby wrapper for the Pivotal Tracker API
170
+ test_files:
171
+ - spec/fixtures/attachment.json
172
+ - spec/fixtures/comment.json
173
+ - spec/fixtures/memberships.json
174
+ - spec/fixtures/new-imperial-logo-6.jpg
175
+ - spec/fixtures/new_story.json
176
+ - spec/fixtures/project.json
177
+ - spec/fixtures/projects.json
178
+ - spec/fixtures/request_story_update.json
179
+ - spec/fixtures/stories.json
180
+ - spec/fixtures/story.json
181
+ - spec/fixtures/story_updated.json
182
+ - spec/pivotal_traker_api/comment_spec.rb
183
+ - spec/pivotal_traker_api/membership_spec.rb
184
+ - spec/pivotal_traker_api/project_spec.rb
185
+ - spec/pivotal_traker_api/story_spec.rb
186
+ - spec/spec_helper.rb
187
+ has_rdoc: