pivotal-tracker 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,28 +1,36 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- activesupport (2.3.8)
4
+ activesupport (3.2.1)
5
+ i18n (~> 0.6)
6
+ multi_json (~> 1.0)
5
7
  archive-tar-minitar (0.5.2)
6
- builder (2.1.2)
7
- columnize (0.3.2)
8
- fakeweb (1.2.8)
9
- gemcutter (0.6.1)
8
+ builder (3.0.0)
9
+ columnize (0.3.6)
10
+ fakeweb (1.3.0)
10
11
  git (1.2.5)
11
- happymapper (0.3.2)
12
- libxml-ruby (~> 1.1.3)
13
- jeweler (1.4.0)
14
- gemcutter (>= 0.1.0)
12
+ happymapper (0.4.0)
13
+ libxml-ruby (~> 2.0)
14
+ i18n (0.6.0)
15
+ jeweler (1.8.3)
16
+ bundler (~> 1.0)
15
17
  git (>= 1.2.5)
16
- rubyforge (>= 2.0.0)
17
- json_pure (1.4.5)
18
- libxml-ruby (1.1.4)
19
- linecache (0.43)
18
+ rake
19
+ rdoc
20
+ json (1.6.5)
21
+ libxml-ruby (2.2.2)
22
+ linecache (0.46)
23
+ rbx-require-relative (> 0.0.4)
20
24
  linecache19 (0.5.12)
21
25
  ruby_core_source (>= 0.1.4)
22
- mime-types (1.16)
23
- nokogiri (1.4.4)
24
- rake (0.8.7)
25
- rest-client (1.6.0)
26
+ mime-types (1.17.2)
27
+ multi_json (1.0.4)
28
+ nokogiri (1.5.0)
29
+ rake (0.9.2.2)
30
+ rbx-require-relative (0.0.5)
31
+ rdoc (3.12)
32
+ json (~> 1.4)
33
+ rest-client (1.6.7)
26
34
  mime-types (>= 1.16)
27
35
  rspec (1.3.2)
28
36
  ruby-debug (0.10.4)
@@ -40,8 +48,6 @@ GEM
40
48
  ruby-debug-base19 (>= 0.11.19)
41
49
  ruby_core_source (0.1.5)
42
50
  archive-tar-minitar (>= 0.5.2)
43
- rubyforge (2.0.4)
44
- json_pure (>= 1.1.7)
45
51
  stale_fish (1.3.0)
46
52
  activesupport
47
53
  fakeweb
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.1
1
+ 0.5.0
@@ -26,7 +26,7 @@ module PivotalTracker
26
26
 
27
27
  @connections ||= {}
28
28
 
29
- @connections[@token] ||= RestClient::Resource.new("#{protocol}://www.pivotaltracker.com/services/v3", :headers => {'X-TrackerToken' => @token, 'Content-Type' => 'application/xml'})
29
+ cached_connection? && !protocol_changed? ? cached_connection : new_connection
30
30
  end
31
31
 
32
32
  protected
@@ -35,6 +35,25 @@ module PivotalTracker
35
35
  use_ssl ? 'https' : 'http'
36
36
  end
37
37
 
38
+ def cached_connection?
39
+ !@connections[@token].nil?
40
+ end
41
+
42
+ def cached_connection
43
+ @connections[@token]
44
+ end
45
+
46
+ def new_connection
47
+ @connections[@token] = RestClient::Resource.new("#{protocol}://www.pivotaltracker.com/services/v3", :headers => {'X-TrackerToken' => @token, 'Content-Type' => 'application/xml'})
48
+ end
49
+
50
+ def protocol_changed?
51
+ cached_connection? ? (cached_connection_protocol != protocol) : false
52
+ end
53
+
54
+ def cached_connection_protocol
55
+ cached_connection.url.match(/^(.*):\/\//).captures.first
56
+ end
38
57
  end
39
58
 
40
59
  end
@@ -21,6 +21,7 @@ module PivotalTracker
21
21
  element :account, String
22
22
  element :week_start_day, String
23
23
  element :point_scale, String
24
+ element :labels, String
24
25
  element :week_start_day, String
25
26
  element :velocity_scheme, String
26
27
  element :iteration_length, Integer
@@ -29,6 +30,16 @@ module PivotalTracker
29
30
  element :last_activity_at, DateTime
30
31
  element :use_https, Boolean
31
32
 
33
+ def initialize(attributes={})
34
+ update_attributes(attributes)
35
+ end
36
+
37
+ def create
38
+ response = Client.connection["/projects"].post(self.to_xml, :content_type => 'application/xml')
39
+ project = Project.parse(response)
40
+ return project
41
+ end
42
+
32
43
  def activities
33
44
  @activities ||= Proxy.new(self, Activity)
34
45
  end
@@ -54,5 +65,28 @@ module PivotalTracker
54
65
  raise ArgumentError, "Invalid group. Use :done, :current or :backlog instead."
55
66
  end
56
67
  end
68
+
69
+ protected
70
+
71
+ def to_xml
72
+ builder = Nokogiri::XML::Builder.new do |xml|
73
+ xml.project {
74
+ xml.name "#{name}"
75
+ xml.iteration_length.integer "#{iteration_length}" unless iteration_length.nil?
76
+ xml.point_scale "#{point_scale}" unless point_scale.nil?
77
+ }
78
+ end
79
+ return builder.to_xml
80
+ end
81
+
82
+ def update_attributes(attrs)
83
+ attrs.each do |key, value|
84
+ self.send("#{key}=", value.is_a?(Array) ? value.join(',') : value )
85
+ end
86
+ end
87
+
88
+ end
89
+ class Project
90
+ include Validation
57
91
  end
58
92
  end
@@ -18,6 +18,16 @@ module PivotalTracker
18
18
  element :complete, Boolean
19
19
  element :created_at, DateTime
20
20
 
21
+ def initialize(attributes={})
22
+ if attributes[:owner]
23
+ self.story = attributes.delete(:owner)
24
+ self.project_id = self.story.project_id
25
+ self.story_id = self.story.id
26
+ end
27
+
28
+ update_attributes(attributes)
29
+ end
30
+
21
31
  def create
22
32
  response = Client.connection["/projects/#{project_id}/stories/#{story_id}/tasks"].post(self.to_xml, :content_type => 'application/xml')
23
33
  return Task.parse(response)
@@ -44,6 +54,12 @@ module PivotalTracker
44
54
  end
45
55
  return builder.to_xml
46
56
  end
57
+
58
+ def update_attributes(attrs)
59
+ attrs.each do |key, value|
60
+ self.send("#{key}=", value.is_a?(Array) ? value.join(',') : value )
61
+ end
62
+ end
47
63
 
48
64
  end
49
65
 
@@ -4,13 +4,13 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{pivotal-tracker}
8
- s.version = "0.4.1"
7
+ s.name = "pivotal-tracker"
8
+ s.version = "0.5.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Justin Smestad", "Josh Nichols", "Terence Lee"]
12
- s.date = %q{2011-07-10}
13
- s.email = %q{justin.smestad@gmail.com}
12
+ s.date = "2012-02-15"
13
+ s.email = "justin.smestad@gmail.com"
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE",
16
16
  "README.rdoc"
@@ -65,10 +65,10 @@ Gem::Specification.new do |s|
65
65
  "spec/unit/pivotal-tracker/story_spec.rb",
66
66
  "spec/unit/pivotal-tracker/task_spec.rb"
67
67
  ]
68
- s.homepage = %q{http://github.com/jsmestad/pivotal-tracker}
68
+ s.homepage = "http://github.com/jsmestad/pivotal-tracker"
69
69
  s.require_paths = ["lib"]
70
- s.rubygems_version = %q{1.7.2}
71
- s.summary = %q{Ruby wrapper for the Pivotal Tracker API}
70
+ s.rubygems_version = "1.8.11"
71
+ s.summary = "Ruby wrapper for the Pivotal Tracker API"
72
72
 
73
73
  if s.respond_to? :specification_version then
74
74
  s.specification_version = 3
@@ -14,6 +14,13 @@
14
14
  request_type: GET
15
15
  update_method: StaleFishFixtures.update_projects_fixture
16
16
  last_updated_at: 2010-07-29T20:15:09+01:00
17
+ - create_projects:
18
+ file: 'projects.xml'
19
+ update_interval: 2.weeks
20
+ check_against: http://www.pivotaltracker.com/services/v3/projects
21
+ request_type: POST
22
+ update_method: StaleFishFixtures.update_projects_fixture
23
+ last_updated_at: 2010-07-29T13:15:09-06:00
17
24
  - tasks:
18
25
  file: 'tasks.xml'
19
26
  update_interval: 2.weeks
@@ -52,4 +52,38 @@ describe PivotalTracker::Project do
52
52
  @project.respond_to?(:memberships).should be_true
53
53
  end
54
54
  end
55
+
56
+ context ".create" do
57
+ before do
58
+ @project = PivotalTracker::Project.new(:name => 'Pivotal Tracker API Gem')
59
+ end
60
+
61
+ it "should return the created project" do
62
+ @project.create
63
+ @project.should be_a(PivotalTracker::Project)
64
+ @project.name.should == 'Pivotal Tracker API Gem'
65
+ end
66
+
67
+ context "on failure" do
68
+ before do
69
+ FakeWeb.register_uri(:post, "http://www.pivotaltracker.com/services/v3/projects",
70
+ :body => %{<?xml version="1.0" encoding="UTF-8"?>
71
+ <errors>
72
+ <error>error#1 message</error>
73
+ <error>error#2 message</error>
74
+ </errors>%},
75
+ :status => "422")
76
+ end
77
+
78
+ it "should not raise an exception" do
79
+ expect { @project.create }.to_not raise_error(Exception)
80
+ end
81
+
82
+ it "should report errors encountered" do
83
+ @project.create
84
+ @project.errors.messages.should =~ ["error#1 message", "error#2 message"]
85
+ end
86
+ end
87
+ end
88
+
55
89
  end
metadata CHANGED
@@ -1,161 +1,158 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: pivotal-tracker
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.0
4
5
  prerelease:
5
- version: 0.4.1
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Justin Smestad
9
9
  - Josh Nichols
10
10
  - Terence Lee
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
-
15
- date: 2011-07-10 00:00:00 Z
16
- dependencies:
17
- - !ruby/object:Gem::Dependency
14
+ date: 2012-02-15 00:00:00.000000000 Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
18
17
  name: rest-client
19
- requirement: &id001 !ruby/object:Gem::Requirement
18
+ requirement: &70278836038760 !ruby/object:Gem::Requirement
20
19
  none: false
21
- requirements:
20
+ requirements:
22
21
  - - ~>
23
- - !ruby/object:Gem::Version
22
+ - !ruby/object:Gem::Version
24
23
  version: 1.6.0
25
24
  type: :runtime
26
25
  prerelease: false
27
- version_requirements: *id001
28
- - !ruby/object:Gem::Dependency
26
+ version_requirements: *70278836038760
27
+ - !ruby/object:Gem::Dependency
29
28
  name: happymapper
30
- requirement: &id002 !ruby/object:Gem::Requirement
29
+ requirement: &70278836038280 !ruby/object:Gem::Requirement
31
30
  none: false
32
- requirements:
33
- - - ">="
34
- - !ruby/object:Gem::Version
31
+ requirements:
32
+ - - ! '>='
33
+ - !ruby/object:Gem::Version
35
34
  version: 0.3.2
36
35
  type: :runtime
37
36
  prerelease: false
38
- version_requirements: *id002
39
- - !ruby/object:Gem::Dependency
37
+ version_requirements: *70278836038280
38
+ - !ruby/object:Gem::Dependency
40
39
  name: builder
41
- requirement: &id003 !ruby/object:Gem::Requirement
40
+ requirement: &70278836037800 !ruby/object:Gem::Requirement
42
41
  none: false
43
- requirements:
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- version: "0"
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
47
46
  type: :runtime
48
47
  prerelease: false
49
- version_requirements: *id003
50
- - !ruby/object:Gem::Dependency
48
+ version_requirements: *70278836037800
49
+ - !ruby/object:Gem::Dependency
51
50
  name: nokogiri
52
- requirement: &id004 !ruby/object:Gem::Requirement
51
+ requirement: &70278836037320 !ruby/object:Gem::Requirement
53
52
  none: false
54
- requirements:
53
+ requirements:
55
54
  - - ~>
56
- - !ruby/object:Gem::Version
57
- version: "1.4"
55
+ - !ruby/object:Gem::Version
56
+ version: '1.4'
58
57
  type: :runtime
59
58
  prerelease: false
60
- version_requirements: *id004
61
- - !ruby/object:Gem::Dependency
59
+ version_requirements: *70278836037320
60
+ - !ruby/object:Gem::Dependency
62
61
  name: rest-client
63
- requirement: &id005 !ruby/object:Gem::Requirement
62
+ requirement: &70278835501260 !ruby/object:Gem::Requirement
64
63
  none: false
65
- requirements:
64
+ requirements:
66
65
  - - ~>
67
- - !ruby/object:Gem::Version
66
+ - !ruby/object:Gem::Version
68
67
  version: 1.6.0
69
68
  type: :runtime
70
69
  prerelease: false
71
- version_requirements: *id005
72
- - !ruby/object:Gem::Dependency
70
+ version_requirements: *70278835501260
71
+ - !ruby/object:Gem::Dependency
73
72
  name: happymapper
74
- requirement: &id006 !ruby/object:Gem::Requirement
73
+ requirement: &70278835500640 !ruby/object:Gem::Requirement
75
74
  none: false
76
- requirements:
77
- - - ">="
78
- - !ruby/object:Gem::Version
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
79
78
  version: 0.3.2
80
79
  type: :runtime
81
80
  prerelease: false
82
- version_requirements: *id006
83
- - !ruby/object:Gem::Dependency
81
+ version_requirements: *70278835500640
82
+ - !ruby/object:Gem::Dependency
84
83
  name: builder
85
- requirement: &id007 !ruby/object:Gem::Requirement
84
+ requirement: &70278835499920 !ruby/object:Gem::Requirement
86
85
  none: false
87
- requirements:
88
- - - ">="
89
- - !ruby/object:Gem::Version
90
- version: "0"
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
91
90
  type: :runtime
92
91
  prerelease: false
93
- version_requirements: *id007
94
- - !ruby/object:Gem::Dependency
92
+ version_requirements: *70278835499920
93
+ - !ruby/object:Gem::Dependency
95
94
  name: nokogiri
96
- requirement: &id008 !ruby/object:Gem::Requirement
95
+ requirement: &70278835499060 !ruby/object:Gem::Requirement
97
96
  none: false
98
- requirements:
99
- - - ">="
100
- - !ruby/object:Gem::Version
97
+ requirements:
98
+ - - ! '>='
99
+ - !ruby/object:Gem::Version
101
100
  version: 1.4.3
102
101
  type: :runtime
103
102
  prerelease: false
104
- version_requirements: *id008
105
- - !ruby/object:Gem::Dependency
103
+ version_requirements: *70278835499060
104
+ - !ruby/object:Gem::Dependency
106
105
  name: rspec
107
- requirement: &id009 !ruby/object:Gem::Requirement
106
+ requirement: &70278835498360 !ruby/object:Gem::Requirement
108
107
  none: false
109
- requirements:
110
- - - ">="
111
- - !ruby/object:Gem::Version
112
- version: "0"
108
+ requirements:
109
+ - - ! '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
113
112
  type: :development
114
113
  prerelease: false
115
- version_requirements: *id009
116
- - !ruby/object:Gem::Dependency
114
+ version_requirements: *70278835498360
115
+ - !ruby/object:Gem::Dependency
117
116
  name: bundler
118
- requirement: &id010 !ruby/object:Gem::Requirement
117
+ requirement: &70278835497640 !ruby/object:Gem::Requirement
119
118
  none: false
120
- requirements:
119
+ requirements:
121
120
  - - ~>
122
- - !ruby/object:Gem::Version
121
+ - !ruby/object:Gem::Version
123
122
  version: 1.0.12
124
123
  type: :development
125
124
  prerelease: false
126
- version_requirements: *id010
127
- - !ruby/object:Gem::Dependency
125
+ version_requirements: *70278835497640
126
+ - !ruby/object:Gem::Dependency
128
127
  name: jeweler
129
- requirement: &id011 !ruby/object:Gem::Requirement
128
+ requirement: &70278835496780 !ruby/object:Gem::Requirement
130
129
  none: false
131
- requirements:
132
- - - ">="
133
- - !ruby/object:Gem::Version
134
- version: "0"
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
135
134
  type: :development
136
135
  prerelease: false
137
- version_requirements: *id011
138
- - !ruby/object:Gem::Dependency
136
+ version_requirements: *70278835496780
137
+ - !ruby/object:Gem::Dependency
139
138
  name: stale_fish
140
- requirement: &id012 !ruby/object:Gem::Requirement
139
+ requirement: &70278835495780 !ruby/object:Gem::Requirement
141
140
  none: false
142
- requirements:
141
+ requirements:
143
142
  - - ~>
144
- - !ruby/object:Gem::Version
143
+ - !ruby/object:Gem::Version
145
144
  version: 1.3.0
146
145
  type: :development
147
146
  prerelease: false
148
- version_requirements: *id012
147
+ version_requirements: *70278835495780
149
148
  description:
150
149
  email: justin.smestad@gmail.com
151
150
  executables: []
152
-
153
151
  extensions: []
154
-
155
- extra_rdoc_files:
152
+ extra_rdoc_files:
156
153
  - LICENSE
157
154
  - README.rdoc
158
- files:
155
+ files:
159
156
  - Gemfile
160
157
  - Gemfile.lock
161
158
  - LICENSE
@@ -206,30 +203,29 @@ files:
206
203
  - spec/unit/pivotal-tracker/task_spec.rb
207
204
  homepage: http://github.com/jsmestad/pivotal-tracker
208
205
  licenses: []
209
-
210
206
  post_install_message:
211
207
  rdoc_options: []
212
-
213
- require_paths:
208
+ require_paths:
214
209
  - lib
215
- required_ruby_version: !ruby/object:Gem::Requirement
210
+ required_ruby_version: !ruby/object:Gem::Requirement
216
211
  none: false
217
- requirements:
218
- - - ">="
219
- - !ruby/object:Gem::Version
220
- version: "0"
221
- required_rubygems_version: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - ! '>='
214
+ - !ruby/object:Gem::Version
215
+ version: '0'
216
+ segments:
217
+ - 0
218
+ hash: 3342751684468911007
219
+ required_rubygems_version: !ruby/object:Gem::Requirement
222
220
  none: false
223
- requirements:
224
- - - ">="
225
- - !ruby/object:Gem::Version
226
- version: "0"
221
+ requirements:
222
+ - - ! '>='
223
+ - !ruby/object:Gem::Version
224
+ version: '0'
227
225
  requirements: []
228
-
229
226
  rubyforge_project:
230
- rubygems_version: 1.7.2
227
+ rubygems_version: 1.8.11
231
228
  signing_key:
232
229
  specification_version: 3
233
230
  summary: Ruby wrapper for the Pivotal Tracker API
234
231
  test_files: []
235
-