pivit 0.1.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.
- checksums.yaml +15 -0
- data/.gitignore +30 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +94 -0
- data/Rakefile +1 -0
- data/lib/pivit.rb +20 -0
- data/lib/pivit/authentication.rb +22 -0
- data/lib/pivit/client.rb +40 -0
- data/lib/pivit/client/activity.rb +34 -0
- data/lib/pivit/client/iteration.rb +88 -0
- data/lib/pivit/client/membership.rb +92 -0
- data/lib/pivit/client/note.rb +47 -0
- data/lib/pivit/client/project.rb +58 -0
- data/lib/pivit/client/story.rb +177 -0
- data/lib/pivit/client/task.rb +112 -0
- data/lib/pivit/configuration.rb +29 -0
- data/lib/pivit/connection.rb +24 -0
- data/lib/pivit/error.rb +6 -0
- data/lib/pivit/request.rb +56 -0
- data/lib/pivit/version.rb +3 -0
- data/pivit.gemspec +37 -0
- data/spec/fixtures/authentications.yml.sample +11 -0
- data/spec/fixtures/stubs/iteration.xml +77 -0
- data/spec/fixtures/stubs/membership.xml +15 -0
- data/spec/fixtures/stubs/note.xml +7 -0
- data/spec/fixtures/stubs/project/project.xml +29 -0
- data/spec/fixtures/stubs/story/delete_story.xml +13 -0
- data/spec/fixtures/stubs/task.xml +8 -0
- data/spec/fixtures/stubs/task_update.xml +8 -0
- data/spec/fixtures/test.png +0 -0
- data/spec/pivit/client/activity_spec.rb +26 -0
- data/spec/pivit/client/iteration_spec.rb +104 -0
- data/spec/pivit/client/membership_spec.rb +91 -0
- data/spec/pivit/client/note_spec.rb +48 -0
- data/spec/pivit/client/project_spec.rb +64 -0
- data/spec/pivit/client/story_spec.rb +156 -0
- data/spec/pivit/client/task_spec.rb +124 -0
- data/spec/pivit/client_spec.rb +47 -0
- data/spec/pivit/configuration_spec.rb +29 -0
- data/spec/spec_helper.rb +54 -0
- metadata +314 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
YzVkYzI3ZjE4Zjk1ZjJjNzIxM2IxZDc4YWE0MDE0YzVmZWY3ZjkwYQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZjMzNDg1ZjRjZDY0ZGQ2MjQyYWUwMTJmMzJkYzYyNzlkMWZhNDdlZA==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NDFhYzMxMzM3NjZiM2I0ODZlZDg4MTA0M2VjNjU4NGQ0ZjhiZWE5YWUzOTAw
|
10
|
+
MDE2MmZjZjZhNjRkMjE5NDJjY2JlMDE5ZDJlZDBkZmUzYzFjYjhkY2I0NWE1
|
11
|
+
MTU4YWE0ODg4ZTc5YjhiM2ZmZGFhZDgzMjliNzc5MjQ3YTk2YTA=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
M2RlZWZmYzEyMmYzNzQxM2Q3ZTI2NTQ2NWNiM2MxY2Q1OTZjMjhiOGQ2YTdk
|
14
|
+
YzNiMTRjZTRmYzlmYjdjMTlkOGZiYmYxMGNkMDVkZDRjOTQ3Mzc2MzUyNWFi
|
15
|
+
OTgyNjdjN2VjN2U3NzUxM2Q2MGU2OGQ4NmQyMWVhOTQ0YTIwMjc=
|
data/.gitignore
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
|
19
|
+
spec/fixtures/authentications.yml
|
20
|
+
|
21
|
+
spec/cassettes/*
|
22
|
+
spec/.DS_Store
|
23
|
+
|
24
|
+
spec/pivit/.DS_Store
|
25
|
+
|
26
|
+
spec/pivit/client/.DS_Store
|
27
|
+
|
28
|
+
spec/irb_setup_script.rb
|
29
|
+
|
30
|
+
.DS_Store
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Jason Truluck
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
# Pivit
|
2
|
+
|
3
|
+
Pivit is a api wrapper for the Pivotal Tracker API. Most features are currently
|
4
|
+
build out but some are still being implemented.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
gem 'pivit'
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle install
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install pivit
|
19
|
+
|
20
|
+
## Documentation
|
21
|
+
|
22
|
+
http://rdoc.info/github/jasontruluck/pivit/master/index
|
23
|
+
|
24
|
+
## Configuration
|
25
|
+
|
26
|
+
Configuration allows for specifying your Pivotal Tracker instances variables. To connect to the API you only need either the `api_token` or the `username` and `password` not both.
|
27
|
+
|
28
|
+
`api_token` - The api token provided via Pivotal Tracker
|
29
|
+
|
30
|
+
`username` - The username of the user you use for Pivotal Tracker
|
31
|
+
|
32
|
+
`password` - The password associated with your account
|
33
|
+
|
34
|
+
`ssl` - If you would like to use SSL to communicate with Pivotal Tracker (default: true)
|
35
|
+
|
36
|
+
Within an initializer `config/initializer/pivit.rb`
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
Pivit.configure do |c|
|
40
|
+
c.ssl = true
|
41
|
+
c.api_token = "super-secret-token"
|
42
|
+
end
|
43
|
+
```
|
44
|
+
|
45
|
+
### Setting up a new client
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
client = Pivit::Client.new(:username => "username", :password =>"super-secret")
|
49
|
+
```
|
50
|
+
or
|
51
|
+
```ruby
|
52
|
+
client = Pivit.new(:username => "username", :password =>"super-secret")
|
53
|
+
```
|
54
|
+
|
55
|
+
You can also pass configuration keys such as etc. as well.
|
56
|
+
|
57
|
+
### Using Limit and Offset
|
58
|
+
|
59
|
+
For methods that allow you to specify a limit and/or offset simply pass the limit or offset you want via an option
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
client.iteration(My-Awesome-Project-ID, {:limit => 1})
|
63
|
+
```
|
64
|
+
|
65
|
+
## Testing
|
66
|
+
|
67
|
+
This gem uses VCR to record requests to the api so you must test using a valid Pivotal Tracker server and credentails to test
|
68
|
+
|
69
|
+
Add a sample authentications file to your `spec/fixtures` directory:
|
70
|
+
|
71
|
+
```ruby
|
72
|
+
#spec/fixtures/authentications.yml
|
73
|
+
USERNAME: myusername
|
74
|
+
PASSWORD: supersecret
|
75
|
+
TOKEN: supersecret
|
76
|
+
PROJECT: "12345" # ID of a project
|
77
|
+
STORY: "12345" # ID of a story
|
78
|
+
STORY_B: "12345" # ID of an alternate story
|
79
|
+
MEMBERSHIP: "12345" # a id of a membership of a user in your project
|
80
|
+
NOTE: "This some note text" # Some test text
|
81
|
+
TASK: "12345" # ID of a task within your pivotal tracker project
|
82
|
+
FILE: "../../../fixtures/test.png" # File locatin of the image/doc/text you would like to use to test with
|
83
|
+
```
|
84
|
+
|
85
|
+
sample is included in the [source](https://github.com/jasontruluck/pivit/blob/master/spec/fixtures/authentications.yml.sample).
|
86
|
+
|
87
|
+
*Note: for tests concerning disabling, deleting, restarting, etc they are mocked explicitly with webmock and will not effect your project*
|
88
|
+
|
89
|
+
## Contributing
|
90
|
+
1. Fork it
|
91
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
92
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
93
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
94
|
+
5. Create new Pull Request</job>)
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/pivit.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require "pivit/version"
|
2
|
+
require "pivit/configuration"
|
3
|
+
require "pivit/client"
|
4
|
+
require "pivit/error"
|
5
|
+
|
6
|
+
module Pivit
|
7
|
+
extend Configuration
|
8
|
+
|
9
|
+
class << self
|
10
|
+
# Alias for Pivit::Client.new
|
11
|
+
# @return [Pivit::Client]
|
12
|
+
def new(options = {})
|
13
|
+
Pivit::Client.new(options)
|
14
|
+
end
|
15
|
+
|
16
|
+
def respond_to?(method, include_private=false)
|
17
|
+
new.respond_to?(method, include_private) || super(method, include_private)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# Authentication Module
|
2
|
+
module Pivit
|
3
|
+
module Authentication
|
4
|
+
def authenticated?
|
5
|
+
!self.api_token.nil?
|
6
|
+
end
|
7
|
+
|
8
|
+
def authenticate(options)
|
9
|
+
if !options[:username].nil? && !options[:password].nil?
|
10
|
+
self.username = URI::encode(options[:username])
|
11
|
+
self.password = URI::encode(options[:password])
|
12
|
+
self.api_token = get("tokens/active").token.guid
|
13
|
+
build_endpoint
|
14
|
+
elsif !options[:token].nil?
|
15
|
+
self.api_token = options[:token]
|
16
|
+
build_endpoint
|
17
|
+
else
|
18
|
+
raise "Your authentication credentials are invalid."
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/pivit/client.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
#Client Module
|
2
|
+
require "pivit/authentication"
|
3
|
+
require "pivit/connection"
|
4
|
+
require "pivit/request"
|
5
|
+
|
6
|
+
require "pivit/client/activity"
|
7
|
+
require "pivit/client/iteration"
|
8
|
+
require "pivit/client/membership"
|
9
|
+
require "pivit/client/note"
|
10
|
+
require "pivit/client/project"
|
11
|
+
require "pivit/client/story"
|
12
|
+
require "pivit/client/task"
|
13
|
+
|
14
|
+
module Pivit
|
15
|
+
class Client
|
16
|
+
attr_accessor(*Configuration::VALID_OPTIONS_KEYS)
|
17
|
+
|
18
|
+
def initialize(options = {})
|
19
|
+
options = Pivit.options.merge(options)
|
20
|
+
|
21
|
+
Configuration::VALID_OPTIONS_KEYS.each do |key|
|
22
|
+
send("#{key}=", options[key])
|
23
|
+
end
|
24
|
+
|
25
|
+
authenticate(options)
|
26
|
+
end
|
27
|
+
|
28
|
+
include Pivit::Authentication
|
29
|
+
include Pivit::Connection
|
30
|
+
include Pivit::Request
|
31
|
+
|
32
|
+
include Pivit::Client::Activity
|
33
|
+
include Pivit::Client::Iteration
|
34
|
+
include Pivit::Client::Membership
|
35
|
+
include Pivit::Client::Note
|
36
|
+
include Pivit::Client::Project
|
37
|
+
include Pivit::Client::Story
|
38
|
+
include Pivit::Client::Task
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Pivit
|
2
|
+
class Client
|
3
|
+
# Activity management
|
4
|
+
#
|
5
|
+
# @see http://www.pivotaltracker.com/help/api?version=v3#getting_activity
|
6
|
+
module Activity
|
7
|
+
# Retrieve all activity from your account
|
8
|
+
#
|
9
|
+
# Pass any of the specified query parameters via options
|
10
|
+
# Available from Pivotal Tracker:
|
11
|
+
# limit - you can limit the number of activity feed items to a desired
|
12
|
+
# number. Note the default value is 10, and there is a upper cap of 100
|
13
|
+
# occurred_since_date - allows restricting the activity feed to only those
|
14
|
+
# items that occurred after a supplied date (example format: 2009/12/18
|
15
|
+
# 21:00:00 UTC)
|
16
|
+
# newer_than_version - allows restricting the activity feed to only those
|
17
|
+
# items that have a greater than supplied version
|
18
|
+
#
|
19
|
+
# @see http://www.pivotaltracker.com/help/api?version=v3#getting_activity
|
20
|
+
#
|
21
|
+
# @return [Hashie::Mash] activity response
|
22
|
+
#
|
23
|
+
# @example
|
24
|
+
# Pivit::Client.activity
|
25
|
+
#
|
26
|
+
# Pivit::Client.activity({:limit => 50})
|
27
|
+
#
|
28
|
+
# @author Jason Truluck
|
29
|
+
def activity(options = {})
|
30
|
+
get("activities", options).activities
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
module Pivit
|
2
|
+
class Client
|
3
|
+
# Iteration management
|
4
|
+
#
|
5
|
+
# @see http://www.pivotaltracker.com/help/api?version=v3#getting_iterations
|
6
|
+
module Iteration
|
7
|
+
# Retrieve all iterations from the project
|
8
|
+
#
|
9
|
+
# @see http://www.pivotaltracker.com/help/api?version=v3#getting_iterations
|
10
|
+
#
|
11
|
+
# @param project_id the id of the project
|
12
|
+
#
|
13
|
+
# @return [Hashie::Mash] iterations response
|
14
|
+
#
|
15
|
+
# @example
|
16
|
+
# Pivit::Client.iterations(1111111)
|
17
|
+
#
|
18
|
+
# @author Jason Truluck
|
19
|
+
def iterations(project_id, options = {})
|
20
|
+
get("projects/#{project_id}/iterations", options).iterations
|
21
|
+
end
|
22
|
+
|
23
|
+
# Retrieve all done iterations from the project
|
24
|
+
#
|
25
|
+
# @see http://www.pivotaltracker.com/help/api?version=v3#getting_iterations
|
26
|
+
#
|
27
|
+
# @param project_id the id of the project
|
28
|
+
#
|
29
|
+
# @return [Hashie::Mash] iterations response
|
30
|
+
#
|
31
|
+
# @example
|
32
|
+
# Pivit::Client.done_iterations(1111111)
|
33
|
+
#
|
34
|
+
# @author Jason Truluck
|
35
|
+
def done_iterations(project_id, options = {})
|
36
|
+
get("projects/#{project_id}/iterations/done", options).iterations
|
37
|
+
end
|
38
|
+
|
39
|
+
# Retrieve all iterations from the project
|
40
|
+
#
|
41
|
+
# @see http://www.pivotaltracker.com/help/api?version=v3#getting_iterations
|
42
|
+
#
|
43
|
+
# @param project_id the id of the project
|
44
|
+
#
|
45
|
+
# @return [Hashie::Mash] iterations response
|
46
|
+
#
|
47
|
+
# @example
|
48
|
+
# Pivit::Client.iteration_backlog(1111111)
|
49
|
+
#
|
50
|
+
# @author Jason Truluck
|
51
|
+
def iteration_backlog(project_id, options = {})
|
52
|
+
get("projects/#{project_id}/iterations/backlog", options).iterations
|
53
|
+
end
|
54
|
+
|
55
|
+
# Retrieve all iterations from the project
|
56
|
+
#
|
57
|
+
# @see http://www.pivotaltracker.com/help/api?version=v3#getting_iterations
|
58
|
+
#
|
59
|
+
# @param project_id the id of the project
|
60
|
+
#
|
61
|
+
# @return [Hashie::Mash] iterations response
|
62
|
+
#
|
63
|
+
# @example
|
64
|
+
# Pivit::Client.iteration_current(1111111)
|
65
|
+
#
|
66
|
+
# @author Jason Truluck
|
67
|
+
def iteration_current(project_id, options = {})
|
68
|
+
get("projects/#{project_id}/iterations/current", options).iterations
|
69
|
+
end
|
70
|
+
|
71
|
+
# Retrieve all iterations from the project
|
72
|
+
#
|
73
|
+
# @see http://www.pivotaltracker.com/help/api?version=v3#getting_iterations
|
74
|
+
#
|
75
|
+
# @param project_id the id of the project
|
76
|
+
#
|
77
|
+
# @return [Hashie::Mash] iterations response
|
78
|
+
#
|
79
|
+
# @example
|
80
|
+
# Pivit::Client.iteration_current_and_backlog(1111111)
|
81
|
+
#
|
82
|
+
# @author Jason Truluck
|
83
|
+
def iteration_current_and_backlog(project_id, options = {})
|
84
|
+
get("projects/#{project_id}/iterations/current_backlog", options).iterations
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
# Membership
|
2
|
+
|
3
|
+
module Pivit
|
4
|
+
class Client
|
5
|
+
# Membership management
|
6
|
+
#
|
7
|
+
# @see http://www.pivotaltracker.com/help/api?version=v3#getting_memberships
|
8
|
+
module Membership
|
9
|
+
# Retrieve a single membership from your account
|
10
|
+
#
|
11
|
+
# @see http://www.pivotaltracker.com/help/api?version=v3#getting_memberships
|
12
|
+
#
|
13
|
+
# @param [Integer] project_id the id of the project that you want to
|
14
|
+
# retrieve memberships from
|
15
|
+
# @param [Integer] membership_id the id of the membership that you want to
|
16
|
+
# retrieve
|
17
|
+
#
|
18
|
+
# @param [Integer] project_id the id of the project that contains the
|
19
|
+
# membership
|
20
|
+
#
|
21
|
+
# @return [Hashie::Mash] membership response
|
22
|
+
#
|
23
|
+
# @example
|
24
|
+
# Pivit::Client.membership(1111111, 123456)
|
25
|
+
#
|
26
|
+
# @author Jason Truluck
|
27
|
+
def membership(project_id, membership_id, options = {})
|
28
|
+
get("projects/#{project_id}/memberships/#{membership_id}", options).memberships.first
|
29
|
+
end
|
30
|
+
|
31
|
+
# Retrieve all memberships from your account
|
32
|
+
#
|
33
|
+
# @see http://www.pivotaltracker.com/help/api?version=v3#getting_memberships
|
34
|
+
#
|
35
|
+
# @param [Integer] project_id the id of the project that contains the
|
36
|
+
#memberships
|
37
|
+
#
|
38
|
+
# @return [Hashie::Mash] memberships response
|
39
|
+
#
|
40
|
+
# @example
|
41
|
+
# Pivit::Client.memberships(1111111)
|
42
|
+
#
|
43
|
+
# @author Jason Truluck
|
44
|
+
def memberships(project_id, options = {})
|
45
|
+
get("projects/#{project_id}/memberships", options).memberships
|
46
|
+
end
|
47
|
+
|
48
|
+
# Create a membership
|
49
|
+
#
|
50
|
+
# Provide the parameters you want to use for the membership via the options
|
51
|
+
# hash.
|
52
|
+
#
|
53
|
+
# @see http://www.pivotaltracker.com/help/api?version=v3#add_membership
|
54
|
+
#
|
55
|
+
# @param [Integer] project_id the id of the project that contains the
|
56
|
+
# membership
|
57
|
+
# @param [Integer] email the email address of the member that is being
|
58
|
+
# added
|
59
|
+
# @param [Integer] role the role of the member that is being added
|
60
|
+
#
|
61
|
+
# @return [Hashie::Mash] membership created response
|
62
|
+
#
|
63
|
+
# @example
|
64
|
+
# Pivit::Client.create_membership(12345, "test@example.com", "Member")
|
65
|
+
#
|
66
|
+
# @author Jason Truluck
|
67
|
+
def create_membership(project_id, email, role, options = {})
|
68
|
+
options.merge!({ :membership => { :role => role, :person => { :email => email }}})
|
69
|
+
post("projects/#{project_id}/memberships", options).membership
|
70
|
+
end
|
71
|
+
|
72
|
+
# Delete a membership
|
73
|
+
#
|
74
|
+
#
|
75
|
+
# @see http://www.pivotaltracker.com/help/api?version=v3#delete_membership
|
76
|
+
#
|
77
|
+
# @param [Integer] project_id the id of the project that contains the
|
78
|
+
# membership
|
79
|
+
# @param [Integer] membership_id the id of the membership that is getting deleted
|
80
|
+
#
|
81
|
+
# @return [Hashie::Mash] membership deleted response
|
82
|
+
#
|
83
|
+
# @example
|
84
|
+
# Pivit::Client.update_membership(12345, 11111)
|
85
|
+
##
|
86
|
+
# @author Jason Truluck
|
87
|
+
def delete_membership(project_id, membership_id, options = {})
|
88
|
+
delete("projects/#{project_id}/memberships/#{membership_id}", options).membership
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|