pivotal_tracker 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.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.rdoc +18 -0
- data/Rakefile +48 -0
- data/VERSION +1 -0
- data/lib/pivotal_tracker/data.rb +18 -0
- data/lib/pivotal_tracker.rb +29 -0
- data/pivotal_tracker.gemspec +63 -0
- data/spec/fixtures/membership.xml +14 -0
- data/spec/fixtures/project.xml +18 -0
- data/spec/pivotal_tracker_spec.rb +65 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +44 -0
- metadata +99 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Joslyn Esser
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
= pivotal_tracker
|
2
|
+
|
3
|
+
This is a simple ruby wrapper for the Pivotal Tracker API.
|
4
|
+
|
5
|
+
== Note on Patches/Pull Requests
|
6
|
+
|
7
|
+
* Fork the project.
|
8
|
+
* Make your feature addition or bug fix.
|
9
|
+
* Add tests for it. This is important so I don't break it in a
|
10
|
+
future version unintentionally.
|
11
|
+
* Commit, do not mess with rakefile, version, or history.
|
12
|
+
(if you want to have your own version, that is fine but
|
13
|
+
bump version in a commit by itself I can ignore when I pull)
|
14
|
+
* Send me a pull request. Bonus points for topic branches.
|
15
|
+
|
16
|
+
== Copyright
|
17
|
+
|
18
|
+
Copyright (c) 2009 Joslyn Esser. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "pivotal_tracker"
|
8
|
+
gem.summary = %Q{Simple ruby wrapper for the Pivotal Tracker API}
|
9
|
+
gem.email = "joslyn.esser@gmail.com"
|
10
|
+
gem.homepage = "http://github.com/joslynesser/pivotal_tracker"
|
11
|
+
gem.authors = ["Joslyn Esser"]
|
12
|
+
|
13
|
+
gem.add_development_dependency "rspec", ">= 1.2.9"
|
14
|
+
gem.add_development_dependency "fakeweb", ">= 1.2.7"
|
15
|
+
|
16
|
+
gem.add_dependency "httparty", ">= 0.4.5"
|
17
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
18
|
+
end
|
19
|
+
Jeweler::GemcutterTasks.new
|
20
|
+
rescue LoadError
|
21
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
22
|
+
end
|
23
|
+
|
24
|
+
require 'spec/rake/spectask'
|
25
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
26
|
+
spec.libs << 'lib' << 'spec'
|
27
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
28
|
+
end
|
29
|
+
|
30
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
31
|
+
spec.libs << 'lib' << 'spec'
|
32
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
33
|
+
spec.rcov = true
|
34
|
+
end
|
35
|
+
|
36
|
+
task :spec => :check_dependencies
|
37
|
+
|
38
|
+
task :default => :spec
|
39
|
+
|
40
|
+
require 'rake/rdoctask'
|
41
|
+
Rake::RDocTask.new do |rdoc|
|
42
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
43
|
+
|
44
|
+
rdoc.rdoc_dir = 'rdoc'
|
45
|
+
rdoc.title = "pivotal_tracker #{version}"
|
46
|
+
rdoc.rdoc_files.include('README*')
|
47
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
48
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
|
3
|
+
class PivotalTracker
|
4
|
+
class Data < OpenStruct
|
5
|
+
def initialize(data)
|
6
|
+
@table = {}
|
7
|
+
if data
|
8
|
+
for key, value in data
|
9
|
+
@table[key.to_sym] = value.instance_of?(Hash) ? Data.new(value) : value
|
10
|
+
new_ostruct_member(key)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class Project < Data; end
|
17
|
+
class Membership < Data; end
|
18
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'httparty'
|
3
|
+
|
4
|
+
class PivotalTracker
|
5
|
+
include HTTParty
|
6
|
+
base_uri 'www.pivotaltracker.com/services/v2'
|
7
|
+
format :xml
|
8
|
+
|
9
|
+
def initialize(api_token)
|
10
|
+
self.class.headers 'X-TrackerToken' => api_token
|
11
|
+
end
|
12
|
+
|
13
|
+
def create_project(name, options = {})
|
14
|
+
data = self.class.post('/projects/', :body => {:project => options.merge(:name => name)})
|
15
|
+
project = PivotalTracker::Project.new(data['project'])
|
16
|
+
end
|
17
|
+
|
18
|
+
def add_member_to_project(project_id, role, email, person_options = {})
|
19
|
+
data = self.class.post("/projects/#{project_id}/memberships/", :body => {:membership => {:role => role, :person => person_options.merge(:email => email)}})
|
20
|
+
membership = PivotalTracker::Membership.new(data['membership'])
|
21
|
+
end
|
22
|
+
|
23
|
+
def remove_member_from_project(project_id, membership_id)
|
24
|
+
data = self.class.delete("/projects/#{project_id}/memberships/#{membership_id}/")
|
25
|
+
membership = PivotalTracker::Membership.new(data['membership']) if data['membership']
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
require File.dirname(__FILE__) + '/pivotal_tracker/data'
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{pivotal_tracker}
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Joslyn Esser"]
|
12
|
+
s.date = %q{2009-11-05}
|
13
|
+
s.email = %q{joslyn.esser@gmail.com}
|
14
|
+
s.extra_rdoc_files = [
|
15
|
+
"LICENSE",
|
16
|
+
"README.rdoc"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
".document",
|
20
|
+
".gitignore",
|
21
|
+
"LICENSE",
|
22
|
+
"README.rdoc",
|
23
|
+
"Rakefile",
|
24
|
+
"VERSION",
|
25
|
+
"lib/pivotal_tracker.rb",
|
26
|
+
"lib/pivotal_tracker/data.rb",
|
27
|
+
"pivotal_tracker.gemspec",
|
28
|
+
"spec/fixtures/membership.xml",
|
29
|
+
"spec/fixtures/project.xml",
|
30
|
+
"spec/pivotal_tracker_spec.rb",
|
31
|
+
"spec/spec.opts",
|
32
|
+
"spec/spec_helper.rb"
|
33
|
+
]
|
34
|
+
s.homepage = %q{http://github.com/joslynesser/pivotal_tracker}
|
35
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
36
|
+
s.require_paths = ["lib"]
|
37
|
+
s.rubygems_version = %q{1.3.5}
|
38
|
+
s.summary = %q{Simple ruby wrapper for the Pivotal Tracker API}
|
39
|
+
s.test_files = [
|
40
|
+
"spec/pivotal_tracker_spec.rb",
|
41
|
+
"spec/spec_helper.rb"
|
42
|
+
]
|
43
|
+
|
44
|
+
if s.respond_to? :specification_version then
|
45
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
46
|
+
s.specification_version = 3
|
47
|
+
|
48
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
49
|
+
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
50
|
+
s.add_development_dependency(%q<fakeweb>, [">= 1.2.7"])
|
51
|
+
s.add_runtime_dependency(%q<httparty>, [">= 0.4.5"])
|
52
|
+
else
|
53
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
54
|
+
s.add_dependency(%q<fakeweb>, [">= 1.2.7"])
|
55
|
+
s.add_dependency(%q<httparty>, [">= 0.4.5"])
|
56
|
+
end
|
57
|
+
else
|
58
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
59
|
+
s.add_dependency(%q<fakeweb>, [">= 1.2.7"])
|
60
|
+
s.add_dependency(%q<httparty>, [">= 0.4.5"])
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<membership>
|
3
|
+
<id>15007</id>
|
4
|
+
<person>
|
5
|
+
<email>jadzia@trill.ufp</email>
|
6
|
+
<name>Jadzia Dax</name>
|
7
|
+
<initials>JD</initials>
|
8
|
+
</person>
|
9
|
+
<role>Member</role>
|
10
|
+
<project>
|
11
|
+
<id>1</id>
|
12
|
+
<name>Warp Engine Upgrades</name>
|
13
|
+
</project>
|
14
|
+
</membership>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project>
|
3
|
+
<id>27</id>
|
4
|
+
<name>Cardassian War Plans</name>
|
5
|
+
<iteration_length type="integer">2</iteration_length>
|
6
|
+
<week_start_day>Monday</week_start_day>
|
7
|
+
<point_scale>0,1,2,3</point_scale>
|
8
|
+
<velocity_scheme>Average of 4 iterations</velocity_scheme>
|
9
|
+
<initial_velocity>10</initial_velocity>
|
10
|
+
<number_of_done_iterations_to_show>12</number_of_done_iterations_to_show>
|
11
|
+
<allow_attachments>true</allow_attachments>
|
12
|
+
<public>false</public>
|
13
|
+
<use_https>true</use_https>
|
14
|
+
<bugs_and_chores_are_estimatable>false</bugs_and_chores_are_estimatable>
|
15
|
+
<commit_mode>false</commit_mode>
|
16
|
+
<memberships>
|
17
|
+
</memberships>
|
18
|
+
</project>
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "PivotalTracker" do
|
4
|
+
|
5
|
+
describe "Initialization" do
|
6
|
+
it "should require an API token" do
|
7
|
+
lambda { PivotalTracker.new }.should raise_error(ArgumentError)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should assign the token to the HTTParty request headers" do
|
11
|
+
@tracker = PivotalTracker.new('12345')
|
12
|
+
PivotalTracker.default_options[:headers].should include('X-TrackerToken' => '12345')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "Data" do
|
17
|
+
before(:each) do
|
18
|
+
@data = PivotalTracker::Data.new({'foo' => 'bar'})
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should resemble a nested OpenStruct" do
|
22
|
+
@data.foo.should == 'bar'
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should return nil for missing keys" do
|
26
|
+
@data.foobar.should be_nil
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "Projects" do
|
31
|
+
before(:each) do
|
32
|
+
@tracker = PivotalTracker.new('12345')
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should create projects" do
|
36
|
+
stub_post('/projects/', 'project.xml')
|
37
|
+
project = @tracker.create_project('Cardassian War Plans')
|
38
|
+
project.name.should == 'Cardassian War Plans'
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "Memberships" do
|
43
|
+
before(:each) do
|
44
|
+
@tracker = PivotalTracker.new('12345')
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should add members to a given project" do
|
48
|
+
stub_post('/projects/12345/memberships/', 'membership.xml')
|
49
|
+
membership = @tracker.add_member_to_project(12345, 'Member', 'jadzia@trill.ufp')
|
50
|
+
membership.person.name.should == 'Jadzia Dax'
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should remove members from a given project" do
|
54
|
+
stub_delete('/projects/12345/memberships/15007/', 'membership.xml')
|
55
|
+
membership = @tracker.remove_member_from_project(12345, 15007)
|
56
|
+
membership.person.name.should == 'Jadzia Dax'
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "Error Handling" do
|
61
|
+
it "should be handled" do
|
62
|
+
pending
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
+
|
4
|
+
require 'pivotal_tracker'
|
5
|
+
require 'spec'
|
6
|
+
require 'spec/autorun'
|
7
|
+
require 'rubygems'
|
8
|
+
require 'fakeweb'
|
9
|
+
require 'ruby-debug'
|
10
|
+
|
11
|
+
Spec::Runner.configure do |config|
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
FakeWeb.allow_net_connect = false
|
16
|
+
|
17
|
+
def fixture_file(filename)
|
18
|
+
return '' if filename == ''
|
19
|
+
file_path = File.expand_path(File.dirname(__FILE__) + '/fixtures/' + filename)
|
20
|
+
File.read(file_path)
|
21
|
+
end
|
22
|
+
|
23
|
+
def pivotal_tracker_url(url)
|
24
|
+
url =~ /^http/ ? url : "http://www.pivotaltracker.com/services/v2#{url}"
|
25
|
+
end
|
26
|
+
|
27
|
+
def stub_get(url, filename, status=nil)
|
28
|
+
options = {:body => fixture_file(filename)}
|
29
|
+
options.merge!({:status => status}) unless status.nil?
|
30
|
+
|
31
|
+
FakeWeb.register_uri(:get, pivotal_tracker_url(url), options)
|
32
|
+
end
|
33
|
+
|
34
|
+
def stub_post(url, filename)
|
35
|
+
FakeWeb.register_uri(:post, pivotal_tracker_url(url), :body => fixture_file(filename))
|
36
|
+
end
|
37
|
+
|
38
|
+
def stub_put(url, filename)
|
39
|
+
FakeWeb.register_uri(:put, pivotal_tracker_url(url), :body => fixture_file(filename))
|
40
|
+
end
|
41
|
+
|
42
|
+
def stub_delete(url, filename)
|
43
|
+
FakeWeb.register_uri(:delete, pivotal_tracker_url(url), :body => fixture_file(filename))
|
44
|
+
end
|
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pivotal_tracker
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Joslyn Esser
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-11-05 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rspec
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.2.9
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: fakeweb
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.2.7
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: httparty
|
37
|
+
type: :runtime
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 0.4.5
|
44
|
+
version:
|
45
|
+
description:
|
46
|
+
email: joslyn.esser@gmail.com
|
47
|
+
executables: []
|
48
|
+
|
49
|
+
extensions: []
|
50
|
+
|
51
|
+
extra_rdoc_files:
|
52
|
+
- LICENSE
|
53
|
+
- README.rdoc
|
54
|
+
files:
|
55
|
+
- .document
|
56
|
+
- .gitignore
|
57
|
+
- LICENSE
|
58
|
+
- README.rdoc
|
59
|
+
- Rakefile
|
60
|
+
- VERSION
|
61
|
+
- lib/pivotal_tracker.rb
|
62
|
+
- lib/pivotal_tracker/data.rb
|
63
|
+
- pivotal_tracker.gemspec
|
64
|
+
- spec/fixtures/membership.xml
|
65
|
+
- spec/fixtures/project.xml
|
66
|
+
- spec/pivotal_tracker_spec.rb
|
67
|
+
- spec/spec.opts
|
68
|
+
- spec/spec_helper.rb
|
69
|
+
has_rdoc: true
|
70
|
+
homepage: http://github.com/joslynesser/pivotal_tracker
|
71
|
+
licenses: []
|
72
|
+
|
73
|
+
post_install_message:
|
74
|
+
rdoc_options:
|
75
|
+
- --charset=UTF-8
|
76
|
+
require_paths:
|
77
|
+
- lib
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: "0"
|
83
|
+
version:
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: "0"
|
89
|
+
version:
|
90
|
+
requirements: []
|
91
|
+
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 1.3.5
|
94
|
+
signing_key:
|
95
|
+
specification_version: 3
|
96
|
+
summary: Simple ruby wrapper for the Pivotal Tracker API
|
97
|
+
test_files:
|
98
|
+
- spec/pivotal_tracker_spec.rb
|
99
|
+
- spec/spec_helper.rb
|