pivotal-tracker 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
3
  group :runtime do
4
- gem 'rest-client', '~> 1.4.1'
4
+ gem 'rest-client', '~> 1.5.1'
5
5
  gem 'happymapper', '>= 0.2.4'
6
6
  gem 'builder'
7
7
  gem 'nokogiri', '~> 1.4.1'
data/README.rdoc CHANGED
@@ -26,6 +26,11 @@ Version 0.0.8 and above are incompatible with previous versions.
26
26
 
27
27
  @a_project.stories.create(:name => 'My Story', :story_type => 'feature') # create a story for this project
28
28
 
29
+ @story = @a_project.stories.find(847762630)
30
+ @story.notes.all # return all notes (comments) for a story
31
+ @story.notes.create(:text => 'A new coment', :noted_at => '06/29/2010 05:00 EST') # add a new story
32
+
33
+
29
34
  # all tracker defined filters are allowed, as well as :limit & :offset for pagination
30
35
 
31
36
  # The below are planned to be added to the final release:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.2.0
@@ -3,15 +3,56 @@ module PivotalTracker
3
3
  include HappyMapper
4
4
 
5
5
  class << self
6
- # def all(story, options={})
7
- # parse(Client.connection["/projects/#{project_id}/stories/#{story_id}/notes"].get)
8
- # end
6
+ def all(story, options={})
7
+ notes = parse(Client.connection["/projects/#{story.project_id}/stories/#{story.id}/notes"].get)
8
+ notes.each { |n| n.project_id, n.story_id = story.project_id, story.id }
9
+ return notes
10
+ end
9
11
  end
10
12
 
13
+ attr_accessor :project_id, :story_id
14
+
11
15
  element :id, Integer
12
16
  element :text, String
13
17
  element :author, String
14
18
  element :noted_at, DateTime
15
- # has_one :story, Story
19
+ has_one :story, Story
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
+
31
+ def create
32
+ response = Client.connection["/projects/#{project_id}/stories/#{story_id}/notes"].post(self.to_xml, :content_type => 'application/xml')
33
+ return Note.parse(response)
34
+ end
35
+
36
+ # Pivotal Tracker API doesn't seem to support updating or deleting notes at this time.
37
+
38
+ protected
39
+
40
+ def to_xml
41
+ builder = Nokogiri::XML::Builder.new do |xml|
42
+ xml.note {
43
+ #xml.author "#{author}"
44
+ xml.text_ "#{text}"
45
+ xml.noted_at "#{noted_at}"
46
+ }
47
+ end
48
+ return builder.to_xml
49
+ end
50
+
51
+ def update_attributes(attrs)
52
+ attrs.each do |key, value|
53
+ self.send("#{key}=", value.is_a?(Array) ? value.join(',') : value )
54
+ end
55
+ end
56
+
16
57
  end
17
58
  end
@@ -39,7 +39,9 @@ module PivotalTracker
39
39
  def create
40
40
  return self if project_id.nil?
41
41
  response = Client.connection["/projects/#{project_id}/stories"].post(self.to_xml, :content_type => 'application/xml')
42
- return Story.parse(response)
42
+ new_story = Story.parse(response)
43
+ new_story.project_id = project_id
44
+ return new_story
43
45
  end
44
46
 
45
47
  def update(attrs={})
@@ -52,6 +54,10 @@ module PivotalTracker
52
54
  Client.connection["/projects/#{project_id}/stories/#{id}"].delete
53
55
  end
54
56
 
57
+ def notes
58
+ @notes ||= Proxy.new(self, Note)
59
+ end
60
+
55
61
  def tasks
56
62
  @tasks ||= Proxy.new(self, Task)
57
63
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{pivotal-tracker}
8
- s.version = "0.1.3"
8
+ s.version = "0.2.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{2010-05-09}
12
+ s.date = %q{2010-07-05}
13
13
  s.email = %q{justin.smestad@gmail.com}
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE",
@@ -36,12 +36,14 @@ Gem::Specification.new do |s|
36
36
  "lib/pivotal_tracker.rb",
37
37
  "pivotal-tracker.gemspec",
38
38
  "spec/fixtures/activity.xml",
39
+ "spec/fixtures/created_note.xml",
39
40
  "spec/fixtures/created_story.xml",
40
41
  "spec/fixtures/iterations_all.xml",
41
42
  "spec/fixtures/iterations_backlog.xml",
42
43
  "spec/fixtures/iterations_current.xml",
43
44
  "spec/fixtures/iterations_done.xml",
44
45
  "spec/fixtures/memberships.xml",
46
+ "spec/fixtures/notes.xml",
45
47
  "spec/fixtures/project.xml",
46
48
  "spec/fixtures/project_activity.xml",
47
49
  "spec/fixtures/projects.xml",
@@ -54,6 +56,7 @@ Gem::Specification.new do |s|
54
56
  "spec/unit/pivotal-tracker/activity_spec.rb",
55
57
  "spec/unit/pivotal-tracker/iteration_spec.rb",
56
58
  "spec/unit/pivotal-tracker/membership_spec.rb",
59
+ "spec/unit/pivotal-tracker/note_spec.rb",
57
60
  "spec/unit/pivotal-tracker/project_spec.rb",
58
61
  "spec/unit/pivotal-tracker/story_spec.rb",
59
62
  "spec/unit/pivotal-tracker/task_spec.rb"
@@ -69,6 +72,7 @@ Gem::Specification.new do |s|
69
72
  "spec/unit/pivotal-tracker/activity_spec.rb",
70
73
  "spec/unit/pivotal-tracker/iteration_spec.rb",
71
74
  "spec/unit/pivotal-tracker/membership_spec.rb",
75
+ "spec/unit/pivotal-tracker/note_spec.rb",
72
76
  "spec/unit/pivotal-tracker/project_spec.rb",
73
77
  "spec/unit/pivotal-tracker/story_spec.rb",
74
78
  "spec/unit/pivotal-tracker/task_spec.rb"
@@ -79,18 +83,18 @@ Gem::Specification.new do |s|
79
83
  s.specification_version = 3
80
84
 
81
85
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
82
- s.add_runtime_dependency(%q<rest-client>, ["~> 1.4.1"])
86
+ s.add_runtime_dependency(%q<rest-client>, ["~> 1.5.1"])
83
87
  s.add_runtime_dependency(%q<happymapper>, [">= 0.2.4"])
84
88
  s.add_runtime_dependency(%q<builder>, [">= 0"])
85
89
  s.add_runtime_dependency(%q<nokogiri>, ["~> 1.4.1"])
86
90
  else
87
- s.add_dependency(%q<rest-client>, ["~> 1.4.1"])
91
+ s.add_dependency(%q<rest-client>, ["~> 1.5.1"])
88
92
  s.add_dependency(%q<happymapper>, [">= 0.2.4"])
89
93
  s.add_dependency(%q<builder>, [">= 0"])
90
94
  s.add_dependency(%q<nokogiri>, ["~> 1.4.1"])
91
95
  end
92
96
  else
93
- s.add_dependency(%q<rest-client>, ["~> 1.4.1"])
97
+ s.add_dependency(%q<rest-client>, ["~> 1.5.1"])
94
98
  s.add_dependency(%q<happymapper>, [">= 0.2.4"])
95
99
  s.add_dependency(%q<builder>, [">= 0"])
96
100
  s.add_dependency(%q<nokogiri>, ["~> 1.4.1"])
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <story>
3
+ <id type="integer">4097942</id>
4
+ <project_id type="integer">59022</project_id>
5
+ <story_type>feature</story_type>
6
+ <url>http://www.pivotaltracker.com/story/show/4097942</url>
7
+ <estimate type="integer">-1</estimate>
8
+ <current_state>unscheduled</current_state>
9
+ <description></description>
10
+ <name>Create stuff</name>
11
+ <requested_by>Leon Miller-Out</requested_by>
12
+ <created_at type="datetime">2010/06/30 03:02:32 UTC</created_at>
13
+ <updated_at type="datetime">2010/06/30 03:02:33 UTC</updated_at>
14
+ </story>
@@ -0,0 +1,17 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <notes type="array">
3
+ <note>
4
+ <id type="integer">1922689</id>
5
+ <text>This is comment 1</text>
6
+ <author>Leon Miller-Out</author>
7
+ <noted_at type="datetime">2010/06/30 03:01:59 UTC</noted_at>
8
+ </note>
9
+ <note>
10
+ <id type="integer">1922690</id>
11
+ <text>This is comment 2.
12
+
13
+ It has some line breaks in it.</text>
14
+ <author>Leon Miller-Out</author>
15
+ <noted_at type="datetime">2010/06/30 03:02:03 UTC</noted_at>
16
+ </note>
17
+ </notes>
@@ -6,81 +6,95 @@
6
6
  check_against: http://www.pivotaltracker.com/services/v3/projects/59022/memberships
7
7
  request_type: GET
8
8
  update_method: StaleFishFixtures.update_memberships_fixture
9
- last_updated_at: 2010-04-28T16:08:18-06:00
9
+ last_updated_at: 2010-06-29T23:02:18-04:00
10
10
  - projects:
11
11
  file: 'projects.xml'
12
12
  update_interval: 2.weeks
13
13
  check_against: http://www.pivotaltracker.com/services/v3/projects
14
14
  request_type: GET
15
15
  update_method: StaleFishFixtures.update_projects_fixture
16
- last_updated_at: 2010-04-28T16:08:19-06:00
16
+ last_updated_at: 2010-06-29T23:02:20-04:00
17
17
  - tasks:
18
18
  file: 'tasks.xml'
19
19
  update_interval: 2.weeks
20
20
  check_against: http://www.pivotaltracker.com/services/v3/projects/59022/stories/2606200/tasks
21
21
  request_type: GET
22
22
  update_method: StaleFishFixtures.update_tasks_fixture
23
- last_updated_at: 2010-04-28T16:08:19-06:00
23
+ last_updated_at: 2010-06-29T23:02:25-04:00
24
24
  - project:
25
25
  file: 'project.xml'
26
26
  update_interval: 2.weeks
27
27
  check_against: http://www.pivotaltracker.com/services/v3/projects/59022
28
28
  request_type: GET
29
29
  update_method: StaleFishFixtures.update_project_fixture
30
- last_updated_at: 2010-04-28T16:08:19-06:00
30
+ last_updated_at: 2010-06-29T23:02:26-04:00
31
31
  - activity:
32
32
  file: 'activity.xml'
33
33
  update_interval: 2.weeks
34
34
  check_against: http://www.pivotaltracker.com/services/v3/activities
35
35
  request_type: GET
36
36
  update_method: StaleFishFixtures.update_activity_fixture
37
- last_updated_at: 2010-04-28T16:09:01-06:00
37
+ last_updated_at: 2010-06-29T23:02:26-04:00
38
38
  - stories:
39
39
  file: 'stories.xml'
40
40
  update_interval: 2.weeks
41
41
  check_against: http://www.pivotaltracker.com/services/v3/projects/59022/stories
42
42
  request_type: GET
43
43
  update_method: StaleFishFixtures.update_stories_fixture
44
- last_updated_at: 2010-04-28T16:09:02-06:00
44
+ last_updated_at: 2010-06-29T23:02:28-04:00
45
45
  - project_activity:
46
46
  file: 'project_activity.xml'
47
47
  update_interval: 2.weeks
48
48
  check_against: http://www.pivotaltracker.com/services/v3/projects/59022/activities
49
49
  request_type: GET
50
50
  update_method: StaleFishFixtures.update_project_activity_fixture
51
- last_updated_at: 2010-04-28T16:09:02-06:00
51
+ last_updated_at: 2010-06-29T23:02:29-04:00
52
52
  - create_story:
53
53
  file: 'created_story.xml'
54
54
  update_interval: 2.weeks
55
55
  check_against: http://www.pivotaltracker.com/services/v3/projects/59022/stories
56
56
  request_type: POST
57
57
  update_method: StaleFishFixtures.create_new_story
58
- last_updated_at: 2010-04-28T16:09:03-06:00
58
+ last_updated_at: 2010-06-29T23:02:29-04:00
59
59
  - iterations_current:
60
60
  file: 'iterations_current.xml'
61
61
  update_interval: 2.weeks
62
62
  check_against: http://www.pivotaltracker.com/services/v3/projects/59022/iterations/current
63
63
  request_type: GET
64
64
  update_method: StaleFishFixtures.update_iterations_current_fixture
65
- last_updated_at: 2010-04-28T16:09:06-06:00
65
+ last_updated_at: 2010-06-29T23:02:30-04:00
66
66
  - iterations_done:
67
67
  file: 'iterations_done.xml'
68
68
  update_interval: 2.weeks
69
69
  check_against: http://www.pivotaltracker.com/services/v3/projects/59022/iterations/done
70
70
  request_type: GET
71
71
  update_method: StaleFishFixtures.update_iterations_done_fixture
72
- last_updated_at: 2010-04-28T16:17:45-06:00
72
+ last_updated_at: 2010-06-29T23:02:30-04:00
73
73
  - iterations_backlog:
74
74
  file: 'iterations_backlog.xml'
75
75
  update_interval: 2.weeks
76
76
  check_against: http://www.pivotaltracker.com/services/v3/projects/59022/iterations/backlog
77
77
  request_type: GET
78
78
  update_method: StaleFishFixtures.update_iterations_backlog_fixture
79
- last_updated_at: 2010-04-28T16:17:45-06:00
79
+ last_updated_at: 2010-06-29T23:02:31-04:00
80
80
  - iterations_all:
81
81
  file: 'iterations_all.xml'
82
82
  update_interval: 2.weeks
83
83
  check_against: http://www.pivotaltracker.com/services/v3/projects/59022/iterations
84
84
  request_type: GET
85
85
  update_method: StaleFishFixtures.update_iterations_all_fixture
86
- last_updated_at: 2010-04-28T16:15:31-06:00
86
+ last_updated_at: 2010-06-29T23:02:31-04:00
87
+ - notes:
88
+ file: 'notes.xml'
89
+ update_interval: 2.weeks
90
+ check_against: http://www.pivotaltracker.com/services/v3/projects/59022/stories/2524689/notes
91
+ request_type: GET
92
+ update_method: StaleFishFixtures.update_notes_fixture
93
+ last_updated_at: 2010-06-29T23:02:31-04:00
94
+ - create_note:
95
+ file: 'created_note.xml'
96
+ update_interval: 2.weeks
97
+ check_against: http://www.pivotaltracker.com/services/v3/projects/59022/stories/2524689/notes
98
+ request_type: POST
99
+ update_method: StaleFishFixtures.create_new_story
100
+ last_updated_at: 2010-06-29T23:02:32-04:00
@@ -48,6 +48,10 @@ module StaleFishFixtures
48
48
  def create_new_story
49
49
  connection["/projects/59022/stories"].post("<story><name>Create stuff</name></story>", :content_type => 'application/xml')
50
50
  end
51
+
52
+ def update_notes_fixture
53
+ connection["/projects/59022/stories/2524689/notes"].get
54
+ end
51
55
 
52
56
  protected
53
57
 
@@ -0,0 +1,61 @@
1
+ require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
2
+
3
+ describe PivotalTracker::Note do
4
+ before do
5
+ @project = PivotalTracker::Project.find(59022)
6
+ @story = @project.stories.find(2524689)
7
+ end
8
+
9
+ context ".all" do
10
+ it "should return an array of notes" do
11
+ @story.notes.all.should be_a(Array)
12
+ @story.notes.all.first.should be_a(PivotalTracker::Note)
13
+ end
14
+ end
15
+
16
+ #context ".find" do
17
+ # it "should return a given task" do
18
+ # @story.tasks.find(179025).should be_a(PivotalTracker::Task)
19
+ # end
20
+ #end
21
+
22
+ context ".create" do
23
+ it "should return the created note" do
24
+ @story.notes.create(:text => 'Test note')
25
+ end
26
+ end
27
+
28
+ context ".new" do
29
+
30
+ def note_for(attrs)
31
+ note = @story.notes.new(attrs)
32
+ @note = Hash.from_xml(note.send(:to_xml))['note']
33
+ end
34
+
35
+ describe "attributes that are not sent to the tracker" do
36
+
37
+ it "should include id" do
38
+ note_for(:id => 10)["id"].should be_nil
39
+ end
40
+
41
+ it "should include author" do
42
+ note_for(:author => "somebody")["author"].should be_nil
43
+ end
44
+
45
+ end
46
+
47
+ describe "attributes that are sent to the tracker" do
48
+
49
+ it "should include text" do
50
+ note_for(:text => "A comment...")["text"].should == "A comment..."
51
+ end
52
+
53
+ it "should include noted_at" do
54
+ note_for(:noted_at => "timestamp")["noted_at"].should == "timestamp"
55
+ end
56
+
57
+ end
58
+
59
+ end
60
+
61
+ end
@@ -3,7 +3,7 @@ require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
3
3
  describe PivotalTracker::Task do
4
4
  before do
5
5
  @project = PivotalTracker::Project.find(59022)
6
- @story = @project.stories.all.first
6
+ @story = @project.stories.find(2606200)
7
7
  end
8
8
 
9
9
  context ".all" do
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
8
- - 3
9
- version: 0.1.3
7
+ - 2
8
+ - 0
9
+ version: 0.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Justin Smestad
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-05-09 00:00:00 -06:00
19
+ date: 2010-07-05 00:00:00 -06:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -28,9 +28,9 @@ dependencies:
28
28
  - !ruby/object:Gem::Version
29
29
  segments:
30
30
  - 1
31
- - 4
31
+ - 5
32
32
  - 1
33
- version: 1.4.1
33
+ version: 1.5.1
34
34
  requirement: *id001
35
35
  prerelease: false
36
36
  - !ruby/object:Gem::Dependency
@@ -103,12 +103,14 @@ files:
103
103
  - lib/pivotal_tracker.rb
104
104
  - pivotal-tracker.gemspec
105
105
  - spec/fixtures/activity.xml
106
+ - spec/fixtures/created_note.xml
106
107
  - spec/fixtures/created_story.xml
107
108
  - spec/fixtures/iterations_all.xml
108
109
  - spec/fixtures/iterations_backlog.xml
109
110
  - spec/fixtures/iterations_current.xml
110
111
  - spec/fixtures/iterations_done.xml
111
112
  - spec/fixtures/memberships.xml
113
+ - spec/fixtures/notes.xml
112
114
  - spec/fixtures/project.xml
113
115
  - spec/fixtures/project_activity.xml
114
116
  - spec/fixtures/projects.xml
@@ -121,6 +123,7 @@ files:
121
123
  - spec/unit/pivotal-tracker/activity_spec.rb
122
124
  - spec/unit/pivotal-tracker/iteration_spec.rb
123
125
  - spec/unit/pivotal-tracker/membership_spec.rb
126
+ - spec/unit/pivotal-tracker/note_spec.rb
124
127
  - spec/unit/pivotal-tracker/project_spec.rb
125
128
  - spec/unit/pivotal-tracker/story_spec.rb
126
129
  - spec/unit/pivotal-tracker/task_spec.rb
@@ -160,6 +163,7 @@ test_files:
160
163
  - spec/unit/pivotal-tracker/activity_spec.rb
161
164
  - spec/unit/pivotal-tracker/iteration_spec.rb
162
165
  - spec/unit/pivotal-tracker/membership_spec.rb
166
+ - spec/unit/pivotal-tracker/note_spec.rb
163
167
  - spec/unit/pivotal-tracker/project_spec.rb
164
168
  - spec/unit/pivotal-tracker/story_spec.rb
165
169
  - spec/unit/pivotal-tracker/task_spec.rb