peaty 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/peaty/base.rb +23 -1
- data/lib/peaty/proxy.rb +5 -1
- data/lib/peaty/story.rb +1 -1
- data/lib/peaty.rb +2 -1
- data/peaty.gemspec +4 -4
- data/test/fixtures/create_story.xml +14 -0
- data/test/peaty_test.rb +12 -0
- data/test/test_helper.rb +4 -0
- metadata +73 -70
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0
|
data/lib/peaty/base.rb
CHANGED
@@ -21,8 +21,21 @@ module Peaty
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
+
def self.build(attrs = {})
|
25
|
+
new(attrs)
|
26
|
+
end
|
27
|
+
|
24
28
|
def method_missing(method, *args)
|
25
|
-
|
29
|
+
method.to_s =~ /^([^\?\=]+)(\?|\=)?$/
|
30
|
+
method_name, predicate = $1, $2
|
31
|
+
|
32
|
+
case predicate
|
33
|
+
when '?'; return self.attributes[method_name].present?
|
34
|
+
when '='; return self.attributes[method_name] = args.first
|
35
|
+
else
|
36
|
+
return self.attributes[method_name] if respond_to?(method_name)
|
37
|
+
end
|
38
|
+
|
26
39
|
super
|
27
40
|
end
|
28
41
|
def respond_to?(method)
|
@@ -33,6 +46,15 @@ module Peaty
|
|
33
46
|
self.attributes["id"]
|
34
47
|
end
|
35
48
|
|
49
|
+
def new_record?
|
50
|
+
id.nil? or id.to_i.zero?
|
51
|
+
end
|
52
|
+
|
53
|
+
def save
|
54
|
+
query_string = @attributes.map{ |k,v| "#{CGI.escape("%s[%s]" % [self.class.element, k.to_s])}=#{CGI.escape(v.to_s)}" }.join('&')
|
55
|
+
@attributes.replace self.class.parse(self.connection["%s?%s" % [self.class.collection_path(@attributes), query_string]].post(:params => @attributes).body, self.class.element).first.attributes
|
56
|
+
end
|
57
|
+
|
36
58
|
class << self
|
37
59
|
attr_accessor :connection
|
38
60
|
|
data/lib/peaty/proxy.rb
CHANGED
@@ -4,7 +4,7 @@ module Peaty
|
|
4
4
|
attr_accessor :target, :connection, :options
|
5
5
|
|
6
6
|
def initialize(target, connection, options = {})
|
7
|
-
@target, @connection, @options = target, connection, options
|
7
|
+
@target, @connection, @options = target, connection, options.with_indifferent_access
|
8
8
|
end
|
9
9
|
|
10
10
|
def method_missing(method, *args)
|
@@ -24,6 +24,10 @@ module Peaty
|
|
24
24
|
|
25
25
|
self
|
26
26
|
end
|
27
|
+
|
28
|
+
def self.build(attrs = {})
|
29
|
+
@target.build(@options.merge(attrs.with_indifferent_access))
|
30
|
+
end
|
27
31
|
end
|
28
32
|
|
29
33
|
end
|
data/lib/peaty/story.rb
CHANGED
data/lib/peaty.rb
CHANGED
@@ -7,6 +7,7 @@ require 'active_support/core_ext/array/extract_options'
|
|
7
7
|
require 'active_support/core_ext/array/wrap'
|
8
8
|
require 'active_support/core_ext/hash/indifferent_access'
|
9
9
|
require 'active_support/core_ext/hash/reverse_merge'
|
10
|
+
require 'active_support/core_ext/object/blank'
|
10
11
|
|
11
12
|
require 'rest-client'
|
12
13
|
require 'nokogiri'
|
@@ -24,7 +25,7 @@ require 'peaty/user'
|
|
24
25
|
|
25
26
|
module Peaty
|
26
27
|
|
27
|
-
VERSION = "0.
|
28
|
+
VERSION = "0.4.0"
|
28
29
|
|
29
30
|
def self.root
|
30
31
|
@root ||= Pathname.new(__FILE__).dirname.parent
|
data/peaty.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{peaty}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.4.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Matt Todd"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2011-03-01}
|
13
13
|
s.description = %q{Just another Pivotal Tracker API Implementation}
|
14
14
|
s.email = %q{chiology@gmail.com}
|
15
15
|
s.files = [
|
@@ -30,6 +30,7 @@ Gem::Specification.new do |s|
|
|
30
30
|
"test/.gitignore",
|
31
31
|
"test/fixtures/bugs.xml",
|
32
32
|
"test/fixtures/chores.xml",
|
33
|
+
"test/fixtures/create_story.xml",
|
33
34
|
"test/fixtures/features.xml",
|
34
35
|
"test/fixtures/iterations.xml",
|
35
36
|
"test/fixtures/iterations_done.xml",
|
@@ -46,7 +47,7 @@ Gem::Specification.new do |s|
|
|
46
47
|
s.homepage = %q{http://github.com/mtodd/peaty}
|
47
48
|
s.licenses = ["MIT"]
|
48
49
|
s.require_paths = ["lib"]
|
49
|
-
s.rubygems_version = %q{1.
|
50
|
+
s.rubygems_version = %q{1.5.2}
|
50
51
|
s.summary = %q{Pivotal Tracker API Implementation}
|
51
52
|
s.test_files = [
|
52
53
|
"test/peaty_test.rb",
|
@@ -54,7 +55,6 @@ Gem::Specification.new do |s|
|
|
54
55
|
]
|
55
56
|
|
56
57
|
if s.respond_to? :specification_version then
|
57
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
58
58
|
s.specification_version = 3
|
59
59
|
|
60
60
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<story>
|
3
|
+
<id type="integer">10564869</id>
|
4
|
+
<project_id type="integer">153937</project_id>
|
5
|
+
<story_type>feature</story_type>
|
6
|
+
<url>http://www.pivotaltracker.com/story/show/10564869</url>
|
7
|
+
<estimate type="integer">-1</estimate>
|
8
|
+
<current_state>unscheduled</current_state>
|
9
|
+
<description></description>
|
10
|
+
<name>Test</name>
|
11
|
+
<requested_by>Matt Todd</requested_by>
|
12
|
+
<created_at type="datetime">2011/03/01 00:40:04 EST</created_at>
|
13
|
+
<updated_at type="datetime">2011/03/01 00:40:04 EST</updated_at>
|
14
|
+
</story>
|
data/test/peaty_test.rb
CHANGED
@@ -78,6 +78,18 @@ class PeatyTest < Test::Unit::TestCase
|
|
78
78
|
assert_equal :chore, @user.pivotal_tracker_projects.find(PROJECT_ID).chores.first.story_type
|
79
79
|
end
|
80
80
|
|
81
|
+
def test_user_can_create_a_new_story_for_a_project
|
82
|
+
story = @user.pivotal_tracker_projects.find(PROJECT_ID).stories.build(:name => name = "Test")
|
83
|
+
assert story.is_a?(Peaty::Story)
|
84
|
+
assert story.new_record?
|
85
|
+
assert_equal PROJECT_ID, story.project_id
|
86
|
+
assert_equal name, story.name
|
87
|
+
|
88
|
+
story.estimate = 3
|
89
|
+
assert story.save
|
90
|
+
assert !story.new_record?
|
91
|
+
end
|
92
|
+
|
81
93
|
# Tests for Iterations
|
82
94
|
def test_user_can_fetch_a_projects_iterations
|
83
95
|
project = @user.pivotal_tracker_projects.find(PROJECT_ID)
|
data/test/test_helper.rb
CHANGED
@@ -33,6 +33,10 @@ uri = "http://www.pivotaltracker.com/services/v3"
|
|
33
33
|
FakeWeb.register_uri(:get, uri + path, :body => File.read(File.join(File.dirname(__FILE__), "fixtures", "%s.xml" % fixture)))
|
34
34
|
end
|
35
35
|
|
36
|
+
FakeWeb.register_uri(:post, Regexp.new(uri + "/projects/#{PROJECT_ID}/stories"),
|
37
|
+
:body => File.read(File.join(File.dirname(__FILE__), "fixtures", "create_story.xml")))
|
38
|
+
# http://www.pivotaltracker.com/services/v3/projects/153937/stories?story%5Bname%5D=Test&story%5Bproject_id%5D=153937&story%5Bestimate%5D=3
|
39
|
+
|
36
40
|
class User < Struct.new(:pivotal_tracker_api_key)
|
37
41
|
pivotal_tracker_for :pivotal_tracker_api_key
|
38
42
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: peaty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 15
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 4
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.4.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Matt Todd
|
@@ -15,12 +15,11 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-03-01 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
|
-
|
23
|
-
prerelease: false
|
22
|
+
type: :runtime
|
24
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
24
|
none: false
|
26
25
|
requirements:
|
@@ -32,11 +31,11 @@ dependencies:
|
|
32
31
|
- 0
|
33
32
|
- 1
|
34
33
|
version: 3.0.1
|
35
|
-
|
34
|
+
name: activesupport
|
36
35
|
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: nokogiri
|
39
36
|
prerelease: false
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
type: :runtime
|
40
39
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
40
|
none: false
|
42
41
|
requirements:
|
@@ -46,11 +45,11 @@ dependencies:
|
|
46
45
|
segments:
|
47
46
|
- 0
|
48
47
|
version: "0"
|
49
|
-
|
48
|
+
name: nokogiri
|
50
49
|
version_requirements: *id002
|
51
|
-
- !ruby/object:Gem::Dependency
|
52
|
-
name: nokogiri-happymapper
|
53
50
|
prerelease: false
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
type: :runtime
|
54
53
|
requirement: &id003 !ruby/object:Gem::Requirement
|
55
54
|
none: false
|
56
55
|
requirements:
|
@@ -60,11 +59,11 @@ dependencies:
|
|
60
59
|
segments:
|
61
60
|
- 0
|
62
61
|
version: "0"
|
63
|
-
|
62
|
+
name: nokogiri-happymapper
|
64
63
|
version_requirements: *id003
|
65
|
-
- !ruby/object:Gem::Dependency
|
66
|
-
name: rest-client
|
67
64
|
prerelease: false
|
65
|
+
- !ruby/object:Gem::Dependency
|
66
|
+
type: :runtime
|
68
67
|
requirement: &id004 !ruby/object:Gem::Requirement
|
69
68
|
none: false
|
70
69
|
requirements:
|
@@ -74,11 +73,11 @@ dependencies:
|
|
74
73
|
segments:
|
75
74
|
- 0
|
76
75
|
version: "0"
|
77
|
-
|
76
|
+
name: rest-client
|
78
77
|
version_requirements: *id004
|
79
|
-
- !ruby/object:Gem::Dependency
|
80
|
-
name: xml_to_json
|
81
78
|
prerelease: false
|
79
|
+
- !ruby/object:Gem::Dependency
|
80
|
+
type: :runtime
|
82
81
|
requirement: &id005 !ruby/object:Gem::Requirement
|
83
82
|
none: false
|
84
83
|
requirements:
|
@@ -90,11 +89,11 @@ dependencies:
|
|
90
89
|
- 0
|
91
90
|
- 1
|
92
91
|
version: 0.0.1
|
93
|
-
|
92
|
+
name: xml_to_json
|
94
93
|
version_requirements: *id005
|
95
|
-
- !ruby/object:Gem::Dependency
|
96
|
-
name: yajl-ruby
|
97
94
|
prerelease: false
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
type: :runtime
|
98
97
|
requirement: &id006 !ruby/object:Gem::Requirement
|
99
98
|
none: false
|
100
99
|
requirements:
|
@@ -104,11 +103,11 @@ dependencies:
|
|
104
103
|
segments:
|
105
104
|
- 0
|
106
105
|
version: "0"
|
107
|
-
type: :runtime
|
108
|
-
version_requirements: *id006
|
109
|
-
- !ruby/object:Gem::Dependency
|
110
106
|
name: yajl-ruby
|
107
|
+
version_requirements: *id006
|
111
108
|
prerelease: false
|
109
|
+
- !ruby/object:Gem::Dependency
|
110
|
+
type: :development
|
112
111
|
requirement: &id007 !ruby/object:Gem::Requirement
|
113
112
|
none: false
|
114
113
|
requirements:
|
@@ -118,11 +117,11 @@ dependencies:
|
|
118
117
|
segments:
|
119
118
|
- 0
|
120
119
|
version: "0"
|
121
|
-
|
120
|
+
name: yajl-ruby
|
122
121
|
version_requirements: *id007
|
123
|
-
- !ruby/object:Gem::Dependency
|
124
|
-
name: builder
|
125
122
|
prerelease: false
|
123
|
+
- !ruby/object:Gem::Dependency
|
124
|
+
type: :development
|
126
125
|
requirement: &id008 !ruby/object:Gem::Requirement
|
127
126
|
none: false
|
128
127
|
requirements:
|
@@ -132,11 +131,11 @@ dependencies:
|
|
132
131
|
segments:
|
133
132
|
- 0
|
134
133
|
version: "0"
|
135
|
-
|
134
|
+
name: builder
|
136
135
|
version_requirements: *id008
|
137
|
-
- !ruby/object:Gem::Dependency
|
138
|
-
name: rspec
|
139
136
|
prerelease: false
|
137
|
+
- !ruby/object:Gem::Dependency
|
138
|
+
type: :development
|
140
139
|
requirement: &id009 !ruby/object:Gem::Requirement
|
141
140
|
none: false
|
142
141
|
requirements:
|
@@ -148,11 +147,11 @@ dependencies:
|
|
148
147
|
- 1
|
149
148
|
- 0
|
150
149
|
version: 2.1.0
|
151
|
-
|
150
|
+
name: rspec
|
152
151
|
version_requirements: *id009
|
153
|
-
- !ruby/object:Gem::Dependency
|
154
|
-
name: bundler
|
155
152
|
prerelease: false
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
type: :development
|
156
155
|
requirement: &id010 !ruby/object:Gem::Requirement
|
157
156
|
none: false
|
158
157
|
requirements:
|
@@ -164,28 +163,29 @@ dependencies:
|
|
164
163
|
- 0
|
165
164
|
- 0
|
166
165
|
version: 1.0.0
|
167
|
-
|
166
|
+
name: bundler
|
168
167
|
version_requirements: *id010
|
169
|
-
- !ruby/object:Gem::Dependency
|
170
|
-
name: jeweler
|
171
168
|
prerelease: false
|
169
|
+
- !ruby/object:Gem::Dependency
|
170
|
+
type: :development
|
172
171
|
requirement: &id011 !ruby/object:Gem::Requirement
|
173
172
|
none: false
|
174
173
|
requirements:
|
175
174
|
- - ~>
|
176
175
|
- !ruby/object:Gem::Version
|
177
|
-
hash:
|
176
|
+
hash: 1923832021
|
178
177
|
segments:
|
179
178
|
- 1
|
180
179
|
- 5
|
181
180
|
- 0
|
182
|
-
-
|
181
|
+
- pre
|
182
|
+
- 6
|
183
183
|
version: 1.5.0.pre6
|
184
|
-
|
184
|
+
name: jeweler
|
185
185
|
version_requirements: *id011
|
186
|
-
- !ruby/object:Gem::Dependency
|
187
|
-
name: rails_code_qa
|
188
186
|
prerelease: false
|
187
|
+
- !ruby/object:Gem::Dependency
|
188
|
+
type: :development
|
189
189
|
requirement: &id012 !ruby/object:Gem::Requirement
|
190
190
|
none: false
|
191
191
|
requirements:
|
@@ -195,11 +195,11 @@ dependencies:
|
|
195
195
|
segments:
|
196
196
|
- 0
|
197
197
|
version: "0"
|
198
|
-
|
198
|
+
name: rails_code_qa
|
199
199
|
version_requirements: *id012
|
200
|
-
- !ruby/object:Gem::Dependency
|
201
|
-
name: nokogiri
|
202
200
|
prerelease: false
|
201
|
+
- !ruby/object:Gem::Dependency
|
202
|
+
type: :runtime
|
203
203
|
requirement: &id013 !ruby/object:Gem::Requirement
|
204
204
|
none: false
|
205
205
|
requirements:
|
@@ -212,11 +212,11 @@ dependencies:
|
|
212
212
|
- 3
|
213
213
|
- 1
|
214
214
|
version: 1.4.3.1
|
215
|
-
|
215
|
+
name: nokogiri
|
216
216
|
version_requirements: *id013
|
217
|
-
- !ruby/object:Gem::Dependency
|
218
|
-
name: yajl-ruby
|
219
217
|
prerelease: false
|
218
|
+
- !ruby/object:Gem::Dependency
|
219
|
+
type: :development
|
220
220
|
requirement: &id014 !ruby/object:Gem::Requirement
|
221
221
|
none: false
|
222
222
|
requirements:
|
@@ -228,11 +228,11 @@ dependencies:
|
|
228
228
|
- 7
|
229
229
|
- 8
|
230
230
|
version: 0.7.8
|
231
|
-
|
231
|
+
name: yajl-ruby
|
232
232
|
version_requirements: *id014
|
233
|
-
- !ruby/object:Gem::Dependency
|
234
|
-
name: activesupport
|
235
233
|
prerelease: false
|
234
|
+
- !ruby/object:Gem::Dependency
|
235
|
+
type: :development
|
236
236
|
requirement: &id015 !ruby/object:Gem::Requirement
|
237
237
|
none: false
|
238
238
|
requirements:
|
@@ -244,11 +244,11 @@ dependencies:
|
|
244
244
|
- 0
|
245
245
|
- 1
|
246
246
|
version: 3.0.1
|
247
|
-
|
247
|
+
name: activesupport
|
248
248
|
version_requirements: *id015
|
249
|
-
- !ruby/object:Gem::Dependency
|
250
|
-
name: builder
|
251
249
|
prerelease: false
|
250
|
+
- !ruby/object:Gem::Dependency
|
251
|
+
type: :development
|
252
252
|
requirement: &id016 !ruby/object:Gem::Requirement
|
253
253
|
none: false
|
254
254
|
requirements:
|
@@ -260,11 +260,11 @@ dependencies:
|
|
260
260
|
- 1
|
261
261
|
- 2
|
262
262
|
version: 2.1.2
|
263
|
-
|
263
|
+
name: builder
|
264
264
|
version_requirements: *id016
|
265
|
-
- !ruby/object:Gem::Dependency
|
266
|
-
name: rspec
|
267
265
|
prerelease: false
|
266
|
+
- !ruby/object:Gem::Dependency
|
267
|
+
type: :development
|
268
268
|
requirement: &id017 !ruby/object:Gem::Requirement
|
269
269
|
none: false
|
270
270
|
requirements:
|
@@ -276,11 +276,11 @@ dependencies:
|
|
276
276
|
- 1
|
277
277
|
- 0
|
278
278
|
version: 2.1.0
|
279
|
-
|
279
|
+
name: rspec
|
280
280
|
version_requirements: *id017
|
281
|
-
- !ruby/object:Gem::Dependency
|
282
|
-
name: bundler
|
283
281
|
prerelease: false
|
282
|
+
- !ruby/object:Gem::Dependency
|
283
|
+
type: :development
|
284
284
|
requirement: &id018 !ruby/object:Gem::Requirement
|
285
285
|
none: false
|
286
286
|
requirements:
|
@@ -292,28 +292,29 @@ dependencies:
|
|
292
292
|
- 0
|
293
293
|
- 0
|
294
294
|
version: 1.0.0
|
295
|
-
|
295
|
+
name: bundler
|
296
296
|
version_requirements: *id018
|
297
|
-
- !ruby/object:Gem::Dependency
|
298
|
-
name: jeweler
|
299
297
|
prerelease: false
|
298
|
+
- !ruby/object:Gem::Dependency
|
299
|
+
type: :development
|
300
300
|
requirement: &id019 !ruby/object:Gem::Requirement
|
301
301
|
none: false
|
302
302
|
requirements:
|
303
303
|
- - ~>
|
304
304
|
- !ruby/object:Gem::Version
|
305
|
-
hash:
|
305
|
+
hash: 1923832021
|
306
306
|
segments:
|
307
307
|
- 1
|
308
308
|
- 5
|
309
309
|
- 0
|
310
|
-
-
|
310
|
+
- pre
|
311
|
+
- 6
|
311
312
|
version: 1.5.0.pre6
|
312
|
-
|
313
|
+
name: jeweler
|
313
314
|
version_requirements: *id019
|
314
|
-
- !ruby/object:Gem::Dependency
|
315
|
-
name: rails_code_qa
|
316
315
|
prerelease: false
|
316
|
+
- !ruby/object:Gem::Dependency
|
317
|
+
type: :development
|
317
318
|
requirement: &id020 !ruby/object:Gem::Requirement
|
318
319
|
none: false
|
319
320
|
requirements:
|
@@ -323,8 +324,9 @@ dependencies:
|
|
323
324
|
segments:
|
324
325
|
- 0
|
325
326
|
version: "0"
|
326
|
-
|
327
|
+
name: rails_code_qa
|
327
328
|
version_requirements: *id020
|
329
|
+
prerelease: false
|
328
330
|
description: Just another Pivotal Tracker API Implementation
|
329
331
|
email: chiology@gmail.com
|
330
332
|
executables: []
|
@@ -351,6 +353,7 @@ files:
|
|
351
353
|
- test/.gitignore
|
352
354
|
- test/fixtures/bugs.xml
|
353
355
|
- test/fixtures/chores.xml
|
356
|
+
- test/fixtures/create_story.xml
|
354
357
|
- test/fixtures/features.xml
|
355
358
|
- test/fixtures/iterations.xml
|
356
359
|
- test/fixtures/iterations_done.xml
|
@@ -393,7 +396,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
393
396
|
requirements: []
|
394
397
|
|
395
398
|
rubyforge_project:
|
396
|
-
rubygems_version: 1.
|
399
|
+
rubygems_version: 1.5.2
|
397
400
|
signing_key:
|
398
401
|
specification_version: 3
|
399
402
|
summary: Pivotal Tracker API Implementation
|