peaty 0.5.0 → 0.6.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
data/Readme.textile CHANGED
@@ -20,6 +20,7 @@ u.pt_projects.each do |project|
20
20
  project.stories.all
21
21
  project.releases.all
22
22
  project.stories(:type => :release)
23
+ project.stories.first.tasks
23
24
 
24
25
  # add team members to team list
25
26
  team.concat project.users # but ensure uniqueness later
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.0
1
+ 0.6.0.beta1
data/lib/peaty/story.rb CHANGED
@@ -16,6 +16,11 @@ module Peaty
16
16
  Project.with_connection(self.class.connection).find(self.project_id)
17
17
  end
18
18
 
19
+ def tasks(options = {})
20
+ Proxy.new(Task, self.class.connection, options.merge(:project_id => self.project_id,
21
+ :story_id => self.id))
22
+ end
23
+
19
24
  # Moves a story before or after another story
20
25
  #
21
26
  # story1.move(:before => story2)
data/lib/peaty/task.rb ADDED
@@ -0,0 +1,27 @@
1
+ module Peaty
2
+ class Task < Base
3
+ def complete?
4
+ self.attributes["complete"] == "true"
5
+ end
6
+
7
+ def position
8
+ self.attributes["position"].to_i
9
+ end
10
+
11
+ def story
12
+ Story.with_connection(self.class.connection).find(self.story_id)
13
+ end
14
+
15
+ class << self
16
+ def element
17
+ "task"
18
+ end
19
+ def collection_path(options = {})
20
+ "/projects/%i/stories/%i/tasks" % [options[:project_id].to_i, options[:story_id].to_i]
21
+ end
22
+ def member_path(id, options = {})
23
+ "/projects/%i/stories/%i/tasks/%i" % [options[:project_id].to_i, options[:story_id].to_i, id]
24
+ end
25
+ end
26
+ end
27
+ end
data/lib/peaty.rb CHANGED
@@ -23,10 +23,11 @@ require 'peaty/project'
23
23
  require 'peaty/iteration'
24
24
  require 'peaty/story'
25
25
  require 'peaty/user'
26
+ require 'peaty/task'
26
27
 
27
28
  module Peaty
28
29
 
29
- VERSION = "0.4.6"
30
+ VERSION = "0.6.0.beta1"
30
31
 
31
32
  def self.root
32
33
  @root ||= Pathname.new(__FILE__).dirname.parent
data/peaty.gemspec CHANGED
@@ -4,13 +4,13 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{peaty}
8
- s.version = "0.5.0"
7
+ s.name = "peaty"
8
+ s.version = "0.6.0.beta1"
9
9
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
10
+ s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Matt Todd", "Andy Lindeman"]
12
- s.date = %q{2011-07-23}
13
- s.description = %q{Just another Pivotal Tracker API Implementation}
12
+ s.date = "2011-10-18"
13
+ s.description = "Just another Pivotal Tracker API Implementation"
14
14
  s.email = ["chiology@gmail.com", "alindeman@gmail.com"]
15
15
  s.files = [
16
16
  "Gemfile",
@@ -24,6 +24,7 @@ Gem::Specification.new do |s|
24
24
  "lib/peaty/project.rb",
25
25
  "lib/peaty/proxy.rb",
26
26
  "lib/peaty/story.rb",
27
+ "lib/peaty/task.rb",
27
28
  "lib/peaty/user.rb",
28
29
  "peaty.gemspec",
29
30
  "test/.gitignore",
@@ -31,6 +32,7 @@ Gem::Specification.new do |s|
31
32
  "test/fixtures/chores.xml",
32
33
  "test/fixtures/create_story.xml",
33
34
  "test/fixtures/create_story_error.xml",
35
+ "test/fixtures/create_task.xml",
34
36
  "test/fixtures/features.xml",
35
37
  "test/fixtures/iterations.xml",
36
38
  "test/fixtures/iterations_done.xml",
@@ -43,14 +45,16 @@ Gem::Specification.new do |s|
43
45
  "test/fixtures/stories.xml",
44
46
  "test/fixtures/stories_with_done.xml",
45
47
  "test/fixtures/story.xml",
48
+ "test/fixtures/task.xml",
49
+ "test/fixtures/tasks.xml",
46
50
  "test/peaty_test.rb",
47
51
  "test/test_helper.rb"
48
52
  ]
49
- s.homepage = %q{http://github.com/mtodd/peaty}
53
+ s.homepage = "http://github.com/mtodd/peaty"
50
54
  s.licenses = ["MIT"]
51
55
  s.require_paths = ["lib"]
52
- s.rubygems_version = %q{1.6.2}
53
- s.summary = %q{Pivotal Tracker API Implementation}
56
+ s.rubygems_version = "1.8.10"
57
+ s.summary = "Pivotal Tracker API Implementation"
54
58
 
55
59
  if s.respond_to? :specification_version then
56
60
  s.specification_version = 3
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <task>
3
+ <id type="integer">1234</id>
4
+ <description>clean shields</description>
5
+ <position>1</position>
6
+ <complete>false</complete>
7
+ <created_at type="datetime">2008/12/10 00:00:00 UTC</created_at>
8
+ </task>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <task>
3
+ <id type="integer">1234</id>
4
+ <description>find shields</description>
5
+ <position>1</position>
6
+ <complete>false</complete>
7
+ <created_at type="datetime">2008/12/10 00:00:00 UTC</created_at>
8
+ </task>
@@ -0,0 +1,10 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <tasks type="array">
3
+ <task>
4
+ <id type="integer">1234</id>
5
+ <description>find shields</description>
6
+ <position>1</position>
7
+ <complete>false</complete>
8
+ <created_at type="datetime">2008/12/10 00:00:00 UTC</created_at>
9
+ </task>
10
+ </tasks>
data/test/peaty_test.rb CHANGED
@@ -3,10 +3,16 @@ require 'test_helper'
3
3
  class PeatyTest < Test::Unit::TestCase
4
4
 
5
5
  def setup
6
+ super
7
+
6
8
  RestClient.log = Logger.new(File.join(File.dirname(__FILE__), 'test.log'))
7
9
  # All test's use TEST_TOKEN which is a valid API key""
8
10
  @user = User.new(TEST_TOKEN)
9
11
  end
12
+
13
+ def teardown
14
+ FakeWeb.clean_registry
15
+ end
10
16
 
11
17
  # Tests for Projects
12
18
  def test_user_can_fetch_a_project
@@ -147,5 +153,43 @@ class PeatyTest < Test::Unit::TestCase
147
153
  assert !iteration.stories.empty?
148
154
  assert_equal project.id, iteration.stories.first.project.id
149
155
  end
150
-
156
+
157
+ # Tests for Tasks
158
+ def test_user_can_fetch_tasks
159
+ FakeWeb.register_uri(:get, Regexp.new(PT_BASE_URI + "/projects/#{PROJECT_ID}/stories/#{STORY_ID}/tasks"),
160
+ :body => File.read(File.join(File.dirname(__FILE__), "fixtures", "tasks.xml")))
161
+
162
+ tasks = @user.pivotal_tracker_projects.find(PROJECT_ID).
163
+ stories.find(STORY_ID).
164
+ tasks
165
+
166
+ assert_equal 1, tasks.all.length
167
+ assert_equal 1234, tasks.first.id
168
+ assert_equal "find shields", tasks.first.description
169
+ end
170
+
171
+ def test_user_can_fetch_task
172
+ FakeWeb.register_uri(:get, Regexp.new(PT_BASE_URI + "/projects/#{PROJECT_ID}/stories/#{STORY_ID}/tasks/#{TASK_ID}"),
173
+ :body => File.read(File.join(File.dirname(__FILE__), "fixtures", "task.xml")))
174
+
175
+ task = @user.pivotal_tracker_projects.find(PROJECT_ID).
176
+ stories.find(STORY_ID).
177
+ tasks.find(TASK_ID)
178
+
179
+ assert_equal 1234, task.id
180
+ assert_equal "find shields", task.description
181
+ end
182
+
183
+ def test_user_can_create_task
184
+ FakeWeb.register_uri(:post, Regexp.new(PT_BASE_URI + "/projects/#{PROJECT_ID}/stories/#{STORY_ID}/tasks"),
185
+ :body => File.read(File.join(File.dirname(__FILE__), "fixtures", "create_task.xml")))
186
+
187
+ task = @user.pivotal_tracker_projects.find(PROJECT_ID).
188
+ stories.find(STORY_ID).
189
+ tasks.build(:description => "clean shields")
190
+
191
+ assert task.save
192
+ assert_equal 1234, task.id
193
+ assert_equal "clean shields", task.description
194
+ end
151
195
  end
data/test/test_helper.rb CHANGED
@@ -15,23 +15,29 @@ TEST_TOKEN = "test"
15
15
  PROJECT_ID = 153937
16
16
  STORY_ID = 6821071
17
17
  RELEASE_ID = 6821121
18
-
19
- PT_BASE_PATH = "/services/v3"
20
- PT_BASE_URI = "https://www.pivotaltracker.com" + PT_BASE_PATH
21
- { "/projects" => "projects",
22
- "/projects/#{PROJECT_ID}" => "project",
23
- "/projects/#{PROJECT_ID}/stories" => "stories",
24
- "/projects/#{PROJECT_ID}/iterations" => "iterations",
25
- "/projects/#{PROJECT_ID}/iterations/done" => "iterations_done",
26
- "/projects/#{PROJECT_ID}/stories/#{STORY_ID}" => "story",
27
- "/projects/#{PROJECT_ID}/stories?filter=type%3Afeature" => "features",
28
- "/projects/#{PROJECT_ID}/stories?filter=type%3Arelease" => "releases",
29
- "/projects/#{PROJECT_ID}/stories/#{RELEASE_ID}" => "release",
30
- "/projects/#{PROJECT_ID}/stories?filter=type%3Achore" => "chores",
31
- "/projects/#{PROJECT_ID}/stories?filter=type%3Abug" => "bugs",
32
- "/projects/#{PROJECT_ID}/stories?filter=includedone%3Atrue" => "stories_with_done",
33
- }.each do |(path, fixture)|
34
- FakeWeb.register_uri(:get, PT_BASE_URI + path, :body => File.read(File.join(File.dirname(__FILE__), "fixtures", "%s.xml" % fixture)))
18
+ TASK_ID = 1234
19
+
20
+ class Test::Unit::TestCase
21
+ PT_BASE_PATH = "/services/v3"
22
+ PT_BASE_URI = "https://www.pivotaltracker.com" + PT_BASE_PATH
23
+
24
+ def setup
25
+ { "/projects" => "projects",
26
+ "/projects/#{PROJECT_ID}" => "project",
27
+ "/projects/#{PROJECT_ID}/stories" => "stories",
28
+ "/projects/#{PROJECT_ID}/iterations" => "iterations",
29
+ "/projects/#{PROJECT_ID}/iterations/done" => "iterations_done",
30
+ "/projects/#{PROJECT_ID}/stories/#{STORY_ID}" => "story",
31
+ "/projects/#{PROJECT_ID}/stories?filter=type%3Afeature" => "features",
32
+ "/projects/#{PROJECT_ID}/stories?filter=type%3Arelease" => "releases",
33
+ "/projects/#{PROJECT_ID}/stories/#{RELEASE_ID}" => "release",
34
+ "/projects/#{PROJECT_ID}/stories?filter=type%3Achore" => "chores",
35
+ "/projects/#{PROJECT_ID}/stories?filter=type%3Abug" => "bugs",
36
+ "/projects/#{PROJECT_ID}/stories?filter=includedone%3Atrue" => "stories_with_done",
37
+ }.each do |(path, fixture)|
38
+ FakeWeb.register_uri(:get, PT_BASE_URI + path, :body => File.read(File.join(File.dirname(__FILE__), "fixtures", "%s.xml" % fixture)))
39
+ end
40
+ end
35
41
  end
36
42
 
37
43
  class User < Struct.new(:pivotal_tracker_api_key)
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: peaty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
5
- prerelease:
4
+ version: 0.6.0.beta1
5
+ prerelease: 6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Matt Todd
@@ -10,12 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2011-07-23 00:00:00.000000000 -04:00
14
- default_executable:
13
+ date: 2011-10-18 00:00:00.000000000Z
15
14
  dependencies:
16
15
  - !ruby/object:Gem::Dependency
17
16
  name: activesupport
18
- requirement: &2157864780 !ruby/object:Gem::Requirement
17
+ requirement: &2152555760 !ruby/object:Gem::Requirement
19
18
  none: false
20
19
  requirements:
21
20
  - - ! '>='
@@ -23,10 +22,10 @@ dependencies:
23
22
  version: 3.0.4
24
23
  type: :runtime
25
24
  prerelease: false
26
- version_requirements: *2157864780
25
+ version_requirements: *2152555760
27
26
  - !ruby/object:Gem::Dependency
28
27
  name: i18n
29
- requirement: &2157864260 !ruby/object:Gem::Requirement
28
+ requirement: &2152555280 !ruby/object:Gem::Requirement
30
29
  none: false
31
30
  requirements:
32
31
  - - ! '>='
@@ -34,10 +33,10 @@ dependencies:
34
33
  version: '0'
35
34
  type: :runtime
36
35
  prerelease: false
37
- version_requirements: *2157864260
36
+ version_requirements: *2152555280
38
37
  - !ruby/object:Gem::Dependency
39
38
  name: nokogiri
40
- requirement: &2157863740 !ruby/object:Gem::Requirement
39
+ requirement: &2152554800 !ruby/object:Gem::Requirement
41
40
  none: false
42
41
  requirements:
43
42
  - - ! '>='
@@ -45,10 +44,10 @@ dependencies:
45
44
  version: '0'
46
45
  type: :runtime
47
46
  prerelease: false
48
- version_requirements: *2157863740
47
+ version_requirements: *2152554800
49
48
  - !ruby/object:Gem::Dependency
50
49
  name: nokogiri-happymapper
51
- requirement: &2157863120 !ruby/object:Gem::Requirement
50
+ requirement: &2152554320 !ruby/object:Gem::Requirement
52
51
  none: false
53
52
  requirements:
54
53
  - - ! '>='
@@ -56,10 +55,10 @@ dependencies:
56
55
  version: '0'
57
56
  type: :runtime
58
57
  prerelease: false
59
- version_requirements: *2157863120
58
+ version_requirements: *2152554320
60
59
  - !ruby/object:Gem::Dependency
61
60
  name: rest-client
62
- requirement: &2157862460 !ruby/object:Gem::Requirement
61
+ requirement: &2152553840 !ruby/object:Gem::Requirement
63
62
  none: false
64
63
  requirements:
65
64
  - - ! '>='
@@ -67,10 +66,10 @@ dependencies:
67
66
  version: '0'
68
67
  type: :runtime
69
68
  prerelease: false
70
- version_requirements: *2157862460
69
+ version_requirements: *2152553840
71
70
  - !ruby/object:Gem::Dependency
72
71
  name: xml_to_json
73
- requirement: &2157861420 !ruby/object:Gem::Requirement
72
+ requirement: &2152553360 !ruby/object:Gem::Requirement
74
73
  none: false
75
74
  requirements:
76
75
  - - ~>
@@ -78,10 +77,10 @@ dependencies:
78
77
  version: 0.0.2
79
78
  type: :runtime
80
79
  prerelease: false
81
- version_requirements: *2157861420
80
+ version_requirements: *2152553360
82
81
  - !ruby/object:Gem::Dependency
83
82
  name: yajl-ruby
84
- requirement: &2157854540 !ruby/object:Gem::Requirement
83
+ requirement: &2152552880 !ruby/object:Gem::Requirement
85
84
  none: false
86
85
  requirements:
87
86
  - - ! '>='
@@ -89,10 +88,10 @@ dependencies:
89
88
  version: '0'
90
89
  type: :runtime
91
90
  prerelease: false
92
- version_requirements: *2157854540
91
+ version_requirements: *2152552880
93
92
  - !ruby/object:Gem::Dependency
94
93
  name: builder
95
- requirement: &2157853660 !ruby/object:Gem::Requirement
94
+ requirement: &2152552400 !ruby/object:Gem::Requirement
96
95
  none: false
97
96
  requirements:
98
97
  - - ! '>='
@@ -100,10 +99,10 @@ dependencies:
100
99
  version: '0'
101
100
  type: :development
102
101
  prerelease: false
103
- version_requirements: *2157853660
102
+ version_requirements: *2152552400
104
103
  - !ruby/object:Gem::Dependency
105
104
  name: jeweler
106
- requirement: &2157852940 !ruby/object:Gem::Requirement
105
+ requirement: &2152551920 !ruby/object:Gem::Requirement
107
106
  none: false
108
107
  requirements:
109
108
  - - ~>
@@ -111,10 +110,10 @@ dependencies:
111
110
  version: 1.6.0
112
111
  type: :development
113
112
  prerelease: false
114
- version_requirements: *2157852940
113
+ version_requirements: *2152551920
115
114
  - !ruby/object:Gem::Dependency
116
115
  name: rails_code_qa
117
- requirement: &2157852220 !ruby/object:Gem::Requirement
116
+ requirement: &2152551440 !ruby/object:Gem::Requirement
118
117
  none: false
119
118
  requirements:
120
119
  - - ! '>='
@@ -122,7 +121,7 @@ dependencies:
122
121
  version: '0'
123
122
  type: :development
124
123
  prerelease: false
125
- version_requirements: *2157852220
124
+ version_requirements: *2152551440
126
125
  description: Just another Pivotal Tracker API Implementation
127
126
  email:
128
127
  - chiology@gmail.com
@@ -142,6 +141,7 @@ files:
142
141
  - lib/peaty/project.rb
143
142
  - lib/peaty/proxy.rb
144
143
  - lib/peaty/story.rb
144
+ - lib/peaty/task.rb
145
145
  - lib/peaty/user.rb
146
146
  - peaty.gemspec
147
147
  - test/.gitignore
@@ -149,6 +149,7 @@ files:
149
149
  - test/fixtures/chores.xml
150
150
  - test/fixtures/create_story.xml
151
151
  - test/fixtures/create_story_error.xml
152
+ - test/fixtures/create_task.xml
152
153
  - test/fixtures/features.xml
153
154
  - test/fixtures/iterations.xml
154
155
  - test/fixtures/iterations_done.xml
@@ -161,9 +162,10 @@ files:
161
162
  - test/fixtures/stories.xml
162
163
  - test/fixtures/stories_with_done.xml
163
164
  - test/fixtures/story.xml
165
+ - test/fixtures/task.xml
166
+ - test/fixtures/tasks.xml
164
167
  - test/peaty_test.rb
165
168
  - test/test_helper.rb
166
- has_rdoc: true
167
169
  homepage: http://github.com/mtodd/peaty
168
170
  licenses:
169
171
  - MIT
@@ -179,16 +181,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
179
181
  version: '0'
180
182
  segments:
181
183
  - 0
182
- hash: -3894549284024583356
184
+ hash: 861207983553646130
183
185
  required_rubygems_version: !ruby/object:Gem::Requirement
184
186
  none: false
185
187
  requirements:
186
- - - ! '>='
188
+ - - ! '>'
187
189
  - !ruby/object:Gem::Version
188
- version: '0'
190
+ version: 1.3.1
189
191
  requirements: []
190
192
  rubyforge_project:
191
- rubygems_version: 1.6.2
193
+ rubygems_version: 1.8.10
192
194
  signing_key:
193
195
  specification_version: 3
194
196
  summary: Pivotal Tracker API Implementation