pivotal-tracker 0.3.0 → 0.3.1
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/VERSION +1 -1
- data/lib/pivotal-tracker.rb +11 -12
- data/lib/pivotal-tracker/story.rb +6 -0
- data/lib/pivotal-tracker/task.rb +4 -0
- data/lib/pivotal-tracker/validation.rb +68 -0
- data/pivotal-tracker.gemspec +3 -2
- data/spec/unit/pivotal-tracker/story_spec.rb +21 -0
- metadata +5 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.1
|
data/lib/pivotal-tracker.rb
CHANGED
@@ -4,6 +4,7 @@ require 'happymapper'
|
|
4
4
|
require 'nokogiri'
|
5
5
|
|
6
6
|
|
7
|
+
require File.join(File.dirname(__FILE__), 'pivotal-tracker', 'validation')
|
7
8
|
require File.join(File.dirname(__FILE__), 'pivotal-tracker', 'extensions')
|
8
9
|
require File.join(File.dirname(__FILE__), 'pivotal-tracker', 'proxy')
|
9
10
|
require File.join(File.dirname(__FILE__), 'pivotal-tracker', 'client')
|
@@ -22,18 +23,16 @@ module PivotalTracker
|
|
22
23
|
class ProjectNotSpecified < StandardError; end
|
23
24
|
|
24
25
|
def self.encode_options(options)
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
options_strings << "filter=#{filters_string}" unless filters_string.empty?
|
36
|
-
return "?#{options_strings.join('&')}"
|
26
|
+
options_strings = options.inject({}) do |m, (k,v)|
|
27
|
+
if [:limit, :offset].include?(k.to_sym)
|
28
|
+
m.update k => v
|
29
|
+
else
|
30
|
+
filter_query = %{#{k}:#{[v].flatten.join(",")}}
|
31
|
+
m.update :filter => (m[:filter] ? "#{m[:filter]} #{filter_query}" : filter_query)
|
32
|
+
end
|
33
|
+
end.map {|k,v| "#{k}=#{CGI.escape(v.to_s)}"}
|
34
|
+
|
35
|
+
%{?#{options_strings.join("&")}} unless options_strings.empty?
|
37
36
|
end
|
38
37
|
|
39
38
|
end
|
@@ -41,6 +41,7 @@ module PivotalTracker
|
|
41
41
|
element :jira_url, String
|
42
42
|
element :other_id, Integer
|
43
43
|
element :integration_id, Integer
|
44
|
+
element :deadline, DateTime # Only available for Release stories
|
44
45
|
|
45
46
|
has_many :attachments, Attachment, :tag => 'attachments'
|
46
47
|
|
@@ -128,6 +129,7 @@ module PivotalTracker
|
|
128
129
|
xml.integration_id "#{integration_id}"
|
129
130
|
xml.created_at DateTime.parse(created_at.to_s).to_s if created_at
|
130
131
|
xml.accepted_at DateTime.parse(accepted_at.to_s).to_s if accepted_at
|
132
|
+
xml.deadline DateTime.parse(deadline.to_s).to_s if deadline
|
131
133
|
}
|
132
134
|
end
|
133
135
|
return builder.to_xml
|
@@ -139,4 +141,8 @@ module PivotalTracker
|
|
139
141
|
end
|
140
142
|
end
|
141
143
|
end
|
144
|
+
|
145
|
+
class Story
|
146
|
+
include Validation
|
147
|
+
end
|
142
148
|
end
|
data/lib/pivotal-tracker/task.rb
CHANGED
@@ -0,0 +1,68 @@
|
|
1
|
+
module PivotalTracker
|
2
|
+
|
3
|
+
class Errors
|
4
|
+
include Enumerable
|
5
|
+
attr_reader :errors
|
6
|
+
|
7
|
+
alias :messages :errors
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@errors = []
|
11
|
+
end
|
12
|
+
|
13
|
+
def each
|
14
|
+
@errors.each do |error|
|
15
|
+
yield error
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def empty?
|
20
|
+
@errors.empty?
|
21
|
+
end
|
22
|
+
|
23
|
+
def add_from_xml(xml)
|
24
|
+
Nokogiri::XML(xml).xpath("/errors/error").each do |error|
|
25
|
+
@errors << error.text
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
module Validation
|
31
|
+
|
32
|
+
def self.included(klass)
|
33
|
+
klass.class_eval do
|
34
|
+
if klass.instance_methods.include?(:create)
|
35
|
+
alias_method :create_without_validations, :create
|
36
|
+
alias_method :create, :create_with_validations
|
37
|
+
end
|
38
|
+
|
39
|
+
if klass.instance_methods.include?(:update)
|
40
|
+
alias_method :update_without_validations, :update
|
41
|
+
alias_method :update, :update_with_validations
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def create_with_validations
|
47
|
+
begin
|
48
|
+
create_without_validations
|
49
|
+
rescue RestClient::UnprocessableEntity => e
|
50
|
+
errors.add_from_xml e.response
|
51
|
+
self
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def update_with_validations(attrs={})
|
56
|
+
begin
|
57
|
+
update_without_validations attrs
|
58
|
+
rescue RestClient::UnprocessableEntity => e
|
59
|
+
errors.add_from_xml e.response
|
60
|
+
self
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def errors
|
65
|
+
@errors ||= Errors.new
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
data/pivotal-tracker.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{pivotal-tracker}
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.1"
|
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-
|
12
|
+
s.date = %q{2010-12-15}
|
13
13
|
s.email = %q{justin.smestad@gmail.com}
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"LICENSE",
|
@@ -35,6 +35,7 @@ Gem::Specification.new do |s|
|
|
35
35
|
"lib/pivotal-tracker/proxy.rb",
|
36
36
|
"lib/pivotal-tracker/story.rb",
|
37
37
|
"lib/pivotal-tracker/task.rb",
|
38
|
+
"lib/pivotal-tracker/validation.rb",
|
38
39
|
"lib/pivotal_tracker.rb",
|
39
40
|
"pivotal-tracker.gemspec",
|
40
41
|
"spec/fixtures/activity.xml",
|
@@ -22,6 +22,27 @@ describe PivotalTracker::Story do
|
|
22
22
|
it "should return the created story" do
|
23
23
|
@project.stories.create(:name => 'Create Stuff').should be_a(PivotalTracker::Story)
|
24
24
|
end
|
25
|
+
|
26
|
+
context "on failure" do
|
27
|
+
before do
|
28
|
+
FakeWeb.register_uri(:post, "http://www.pivotaltracker.com/services/v3/projects/#{@project.id}/stories",
|
29
|
+
:body => %{<?xml version="1.0" encoding="UTF-8"?>
|
30
|
+
<errors>
|
31
|
+
<error>error#1 message</error>
|
32
|
+
<error>error#2 message</error>
|
33
|
+
</errors>%},
|
34
|
+
:status => "422")
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should not raise an exception" do
|
38
|
+
expect { @project.stories.create }.to_not raise_error(Exception)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should report errors encountered" do
|
42
|
+
story = @project.stories.create :name => "Invalid story"
|
43
|
+
story.errors.messages.should =~ ["error#1 message", "error#2 message"]
|
44
|
+
end
|
45
|
+
end
|
25
46
|
end
|
26
47
|
|
27
48
|
context ".attachments" do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pivotal-tracker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 1
|
10
|
+
version: 0.3.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Justin Smestad
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2010-
|
20
|
+
date: 2010-12-15 00:00:00 -07:00
|
21
21
|
default_executable:
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|
@@ -172,6 +172,7 @@ files:
|
|
172
172
|
- lib/pivotal-tracker/proxy.rb
|
173
173
|
- lib/pivotal-tracker/story.rb
|
174
174
|
- lib/pivotal-tracker/task.rb
|
175
|
+
- lib/pivotal-tracker/validation.rb
|
175
176
|
- lib/pivotal_tracker.rb
|
176
177
|
- pivotal-tracker.gemspec
|
177
178
|
- spec/fixtures/activity.xml
|