jsmestad-pivotal-tracker 0.0.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/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Josh Nichols
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,13 @@
1
+ Ruby Pivotal Tracker
2
+ http://www.evalcode.com
3
+
4
+ =========================
5
+ Notes
6
+ =========================
7
+ There are a few areas that need to be modified in order for this code to work correctly.
8
+ You must set the Token key in the initialize method as well as project_id.
9
+
10
+ =========================
11
+ Contributers
12
+ =========================
13
+ Justin Smestad
data/Rakefile ADDED
@@ -0,0 +1,58 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "pivotal-tracker"
8
+ gem.summary = %Q{Ruby wrapper for the Pivotal Tracker API}
9
+ gem.email = "justin.smestad@gmail.com"
10
+ gem.homepage = "http://github.com/jsmestad/pivotal-tracker"
11
+ gem.authors = ["Justin Smestad", "Josh Nichols"]
12
+ gem.add_dependency "restclient"
13
+ gem.add_dependency "happymapper", ">= 0.2.4"
14
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
+ end
16
+
17
+ rescue LoadError
18
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
19
+ end
20
+
21
+ require 'rake/testtask'
22
+ Rake::TestTask.new(:test) do |test|
23
+ test.libs << 'lib' << 'test'
24
+ test.pattern = 'test/**/*_test.rb'
25
+ test.verbose = true
26
+ end
27
+
28
+ begin
29
+ require 'rcov/rcovtask'
30
+ Rcov::RcovTask.new do |test|
31
+ test.libs << 'test'
32
+ test.pattern = 'test/**/*_test.rb'
33
+ test.verbose = true
34
+ end
35
+ rescue LoadError
36
+ task :rcov do
37
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
38
+ end
39
+ end
40
+
41
+
42
+ task :default => :test
43
+
44
+ require 'rake/rdoctask'
45
+ Rake::RDocTask.new do |rdoc|
46
+ if File.exist?('VERSION.yml')
47
+ config = YAML.load(File.read('VERSION.yml'))
48
+ version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
49
+ else
50
+ version = ""
51
+ end
52
+
53
+ rdoc.rdoc_dir = 'rdoc'
54
+ rdoc.title = "ruby-pivotal-tracker #{version}"
55
+ rdoc.rdoc_files.include('README*')
56
+ rdoc.rdoc_files.include('lib/**/*.rb')
57
+ end
58
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,12 @@
1
+ # TODO make these conditional on to_param not existing...
2
+ class String
3
+ def to_param
4
+ self
5
+ end
6
+ end
7
+
8
+ class Integer
9
+ def to_param
10
+ to_s
11
+ end
12
+ end
@@ -0,0 +1,7 @@
1
+ class Project
2
+ include HappyMapper
3
+ element :name, String
4
+ element :iteration_length, String
5
+ element :week_start_day, String
6
+ element :point_scale, String
7
+ end
@@ -0,0 +1,25 @@
1
+ class Story
2
+ include HappyMapper
3
+ element :id, Integer
4
+ element :type, String
5
+ element :name, String
6
+
7
+ def initialize(attributes = {})
8
+ attributes.each do |key, value|
9
+ send("#{key}=", value)
10
+ end
11
+ end
12
+
13
+ def to_xml(options = {})
14
+ builder = Builder::XmlMarkup.new(options)
15
+ builder.story do |story|
16
+ story.id id.to_s if id
17
+ story.type type.to_s if type
18
+ story.name name.to_s if name
19
+ end
20
+ end
21
+
22
+ def to_param
23
+ id.to_s
24
+ end
25
+ end
@@ -0,0 +1,76 @@
1
+ require 'restclient'
2
+ require 'happymapper'
3
+ require 'builder'
4
+
5
+
6
+ require 'pivotal-tracker/extensions'
7
+ require 'pivotal-tracker/project'
8
+ require 'pivotal-tracker/story'
9
+
10
+ class PivotalTracker
11
+ def initialize(project_id, token)
12
+ @project_id, @token = project_id, token
13
+ end
14
+
15
+ def project
16
+ response = project_resource.get 'Token' => @token
17
+ Project.parse(response).first
18
+ end
19
+
20
+ def stories
21
+ response = project_resource['stories'].get 'Token' => @token
22
+ Story.parse(response)
23
+ end
24
+
25
+ # would ideally like to pass a size, aka :all to limit search
26
+ def find(filters = {})
27
+ unless filters.empty?
28
+ filter_string = "?filter="
29
+ filters.each do |key, value|
30
+ filter_string << CGI::escape("#{key}:\"#{value}\"")
31
+ end
32
+ else
33
+ filter_string = ""
34
+ end
35
+
36
+ response = stories_resource[filter_string].get
37
+
38
+ Story.parse(response)
39
+ end
40
+
41
+ def find_story(id)
42
+ story_resource(id).get 'Token' => @token, 'Content-Type' => 'application/xml'
43
+
44
+ Story.parse(response).first
45
+ end
46
+
47
+ def create_story(story)
48
+ stories_resource.post story.to_xml, 'Token' => @token, 'Content-Type' => 'application/xml'
49
+ end
50
+
51
+ def update_story(story)
52
+ story_resource(story).put story.to_xml, 'Token' => @token, 'Content-Type' => 'application/xml'
53
+ end
54
+
55
+ def delete_story(story)
56
+ story_resource(story).delete 'Token' => @token
57
+ end
58
+
59
+ protected
60
+
61
+ def projects_resource
62
+ RestClient::Resource.new "http://www.pivotaltracker.com/services/v1/projects"
63
+ end
64
+
65
+ def project_resource(project = @project_id)
66
+ projects_resource["/#{@project_id}"]
67
+ end
68
+
69
+ def stories_resource
70
+ project_resource['/stories']
71
+ end
72
+
73
+ def story_resource(story)
74
+ stories_resource["/#{story.to_param}"]
75
+ end
76
+ end
@@ -0,0 +1,56 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{pivotal-tracker}
5
+ s.version = "0.0.1"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Justin Smestad", "Josh Nichols"]
9
+ s.date = %q{2009-05-27}
10
+ s.email = %q{justin.smestad@gmail.com}
11
+ s.extra_rdoc_files = [
12
+ "LICENSE",
13
+ "README"
14
+ ]
15
+ s.files = [
16
+ ".document",
17
+ ".gitignore",
18
+ "LICENSE",
19
+ "README",
20
+ "Rakefile",
21
+ "VERSION",
22
+ "lib/pivotal-tracker.rb",
23
+ "lib/pivotal-tracker/extensions.rb",
24
+ "lib/pivotal-tracker/project.rb",
25
+ "lib/pivotal-tracker/story.rb",
26
+ "pivotal-tracker.gemspec",
27
+ "test/pivotal_tracker_test.rb",
28
+ "test/test_helper.rb"
29
+ ]
30
+ s.has_rdoc = true
31
+ s.homepage = %q{http://github.com/jsmestad/pivotal-tracker}
32
+ s.rdoc_options = ["--charset=UTF-8"]
33
+ s.require_paths = ["lib"]
34
+ s.rubygems_version = %q{1.3.1}
35
+ s.summary = %q{Ruby wrapper for the Pivotal Tracker API}
36
+ s.test_files = [
37
+ "test/pivotal_tracker_test.rb",
38
+ "test/test_helper.rb"
39
+ ]
40
+
41
+ if s.respond_to? :specification_version then
42
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
43
+ s.specification_version = 2
44
+
45
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
46
+ s.add_runtime_dependency(%q<restclient>, [">= 0"])
47
+ s.add_runtime_dependency(%q<happymapper>, [">= 0.2.4"])
48
+ else
49
+ s.add_dependency(%q<restclient>, [">= 0"])
50
+ s.add_dependency(%q<happymapper>, [">= 0.2.4"])
51
+ end
52
+ else
53
+ s.add_dependency(%q<restclient>, [">= 0"])
54
+ s.add_dependency(%q<happymapper>, [">= 0.2.4"])
55
+ end
56
+ end
@@ -0,0 +1,56 @@
1
+ require 'test_helper'
2
+
3
+ class PivotalTrackerTest < Test::Unit::TestCase
4
+
5
+ def setup
6
+ @tracker = Tracker.new
7
+ end
8
+
9
+ def test_assert_stories_return
10
+ assert_equal 3, @tracker.stories.size
11
+ end
12
+
13
+ def test_assert_project_response
14
+ project = @tracker.project
15
+ assert_equal "Factory Test", project[:name]
16
+ assert_equal "1", project[:iteration_length]
17
+ end
18
+
19
+ def test_find_without_filters
20
+ result = @tracker.find
21
+ assert_equal @tracker.stories.size, result.size
22
+ end
23
+
24
+ def test_find_with_filters
25
+ result = @tracker.find :name => 'Create another one'
26
+ assert_equal result[0][:name], 'Create another one'
27
+ end
28
+
29
+ def test_assert_story_creation
30
+ current_size = @tracker.stories.size
31
+ story = {
32
+ :name => 'Create another one',
33
+ :story_type => "feature",
34
+ :requested_by => "Justin Smestad"
35
+ }
36
+ @tracker.create_story(story)
37
+ assert_equal (current_size + 1), @tracker.stories.size
38
+ end
39
+
40
+ def test_story_updates
41
+ story = {
42
+ :id => 272626,
43
+ :name => 'This has changed'
44
+ }
45
+ @tracker.update_story(story)
46
+ assert_equal @tracker.find_story(story[:id])[:name], story[:name]
47
+ end
48
+
49
+ def test_story_deletion
50
+ current_size = @tracker.stories.size
51
+ id = @tracker.stories[0][:id]
52
+ @tracker.delete_story(id)
53
+ assert_equal (current_size - 1), @tracker.stories.size
54
+ end
55
+
56
+ end
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+
4
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
5
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
6
+
7
+ require 'pivotal-tracker'
8
+
9
+ class Test::Unit::TestCase
10
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jsmestad-pivotal-tracker
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Justin Smestad
8
+ - Josh Nichols
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2009-05-27 00:00:00 -07:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: restclient
18
+ type: :runtime
19
+ version_requirement:
20
+ version_requirements: !ruby/object:Gem::Requirement
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: "0"
25
+ version:
26
+ - !ruby/object:Gem::Dependency
27
+ name: happymapper
28
+ type: :runtime
29
+ version_requirement:
30
+ version_requirements: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: 0.2.4
35
+ version:
36
+ description:
37
+ email: justin.smestad@gmail.com
38
+ executables: []
39
+
40
+ extensions: []
41
+
42
+ extra_rdoc_files:
43
+ - LICENSE
44
+ - README
45
+ files:
46
+ - .document
47
+ - .gitignore
48
+ - LICENSE
49
+ - README
50
+ - Rakefile
51
+ - VERSION
52
+ - lib/pivotal-tracker.rb
53
+ - lib/pivotal-tracker/extensions.rb
54
+ - lib/pivotal-tracker/project.rb
55
+ - lib/pivotal-tracker/story.rb
56
+ - pivotal-tracker.gemspec
57
+ - test/pivotal_tracker_test.rb
58
+ - test/test_helper.rb
59
+ has_rdoc: true
60
+ homepage: http://github.com/jsmestad/pivotal-tracker
61
+ post_install_message:
62
+ rdoc_options:
63
+ - --charset=UTF-8
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: "0"
71
+ version:
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: "0"
77
+ version:
78
+ requirements: []
79
+
80
+ rubyforge_project:
81
+ rubygems_version: 1.2.0
82
+ signing_key:
83
+ specification_version: 2
84
+ summary: Ruby wrapper for the Pivotal Tracker API
85
+ test_files:
86
+ - test/pivotal_tracker_test.rb
87
+ - test/test_helper.rb