taskmapper-rally 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. data/.document +5 -0
  2. data/.rbenv-gemsets +1 -0
  3. data/.rspec +1 -0
  4. data/.rvmrc +1 -0
  5. data/.travis.yml +4 -0
  6. data/Gemfile +20 -0
  7. data/Gemfile.lock +80 -0
  8. data/LICENSE.txt +20 -0
  9. data/README.md +65 -0
  10. data/Rakefile +43 -0
  11. data/VERSION +1 -0
  12. data/lib/provider/comment.rb +118 -0
  13. data/lib/provider/project.rb +86 -0
  14. data/lib/provider/rally.rb +47 -0
  15. data/lib/provider/ticket.rb +170 -0
  16. data/lib/taskmapper-rally.rb +15 -0
  17. data/log/.keep +0 -0
  18. data/spec/comments_spec.rb +50 -0
  19. data/spec/fixtures/tickets.xml +0 -0
  20. data/spec/fixtures/vcr_cassettes/all_tickets.yml +4396 -0
  21. data/spec/fixtures/vcr_cassettes/create_comment.yml +360 -0
  22. data/spec/fixtures/vcr_cassettes/create_ticket.yml +4546 -0
  23. data/spec/fixtures/vcr_cassettes/load_all_rally_comments.yml +1429 -0
  24. data/spec/fixtures/vcr_cassettes/load_comments_by_attributes.yml +715 -0
  25. data/spec/fixtures/vcr_cassettes/load_comments_by_ids.yml +193 -0
  26. data/spec/fixtures/vcr_cassettes/rally.yml +64 -0
  27. data/spec/fixtures/vcr_cassettes/rally_bi_id.yml +75 -0
  28. data/spec/fixtures/vcr_cassettes/rally_by_id.yml +79 -0
  29. data/spec/fixtures/vcr_cassettes/rally_project_return_class.yml +79 -0
  30. data/spec/fixtures/vcr_cassettes/rally_projects.yml +253 -0
  31. data/spec/fixtures/vcr_cassettes/rally_projects_by_attributes.yml +127 -0
  32. data/spec/fixtures/vcr_cassettes/rally_projects_by_ids.yml +79 -0
  33. data/spec/fixtures/vcr_cassettes/rally_tickets.yml +142 -0
  34. data/spec/fixtures/vcr_cassettes/retrieve_ticket.yml +4546 -0
  35. data/spec/fixtures/vcr_cassettes/save_task_ticket.yml +3097 -0
  36. data/spec/fixtures/vcr_cassettes/save_ticket.yml +209 -0
  37. data/spec/fixtures/vcr_cassettes/taskmapper_call.yml +75 -0
  38. data/spec/fixtures/vcr_cassettes/taskmapper_setting.yml +75 -0
  39. data/spec/fixtures/vcr_cassettes/ticket_by_attributes.yml +4396 -0
  40. data/spec/fixtures/vcr_cassettes/ticket_save.yml +199 -0
  41. data/spec/fixtures/vcr_cassettes/ticket_update.yml +184 -0
  42. data/spec/fixtures/vcr_cassettes/ticketmaster_call.yml +64 -0
  43. data/spec/fixtures/vcr_cassettes/ticketmaster_setting.yml +4687 -0
  44. data/spec/fixtures/vcr_cassettes/tickets_by_attributes.yml +4396 -0
  45. data/spec/fixtures/vcr_cassettes/tickets_by_defect.yml +2816 -0
  46. data/spec/fixtures/vcr_cassettes/tickets_by_hierachial.yml +762 -0
  47. data/spec/fixtures/vcr_cassettes/tickets_by_ids.yml +184 -0
  48. data/spec/fixtures/vcr_cassettes/tickets_by_task.yml +1032 -0
  49. data/spec/projects_spec.rb +60 -0
  50. data/spec/spec_helper.rb +17 -0
  51. data/spec/taskmapper-rally_spec.rb +24 -0
  52. data/spec/tickets_spec.rb +117 -0
  53. data/spec/vcr_setup.rb +7 -0
  54. data/taskmapper-rally.gemspec +117 -0
  55. metadata +214 -0
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
@@ -0,0 +1 @@
1
+ ticketmaster-rally
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm 1.9.2@taskmapper-rally --create
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.8.7
4
+ - 1.9.2
data/Gemfile ADDED
@@ -0,0 +1,20 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+
9
+ gem "taskmapper", "~> 0.8"
10
+ gem "rally_rest_api", "~> 1.0"
11
+
12
+ group :development do
13
+ gem "rspec", "~> 2.3"
14
+ gem "yard", "~> 0.7"
15
+ gem "jeweler", "~> 1.5"
16
+ gem "fakeweb", "~> 1.3"
17
+ gem "vcr", "~> 1.11"
18
+ gem 'ruby-debug', :platform => [:ruby_18]
19
+ gem 'ruby-debug19', :platform => [:ruby_19]
20
+ end
@@ -0,0 +1,80 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ activemodel (3.2.3)
5
+ activesupport (= 3.2.3)
6
+ builder (~> 3.0.0)
7
+ activeresource (3.2.3)
8
+ activemodel (= 3.2.3)
9
+ activesupport (= 3.2.3)
10
+ activesupport (3.2.3)
11
+ i18n (~> 0.6)
12
+ multi_json (~> 1.0)
13
+ archive-tar-minitar (0.5.2)
14
+ builder (3.0.0)
15
+ columnize (0.3.6)
16
+ diff-lcs (1.1.3)
17
+ fakeweb (1.3.0)
18
+ git (1.2.5)
19
+ hashie (1.2.0)
20
+ i18n (0.6.0)
21
+ jeweler (1.8.3)
22
+ bundler (~> 1.0)
23
+ git (>= 1.2.5)
24
+ rake
25
+ rdoc
26
+ json (1.6.5)
27
+ linecache (0.46)
28
+ rbx-require-relative (> 0.0.4)
29
+ linecache19 (0.5.12)
30
+ ruby_core_source (>= 0.1.4)
31
+ multi_json (1.3.5)
32
+ rake (0.9.2.2)
33
+ rally_rest_api (1.0.3)
34
+ rbx-require-relative (0.0.9)
35
+ rdoc (3.12)
36
+ json (~> 1.4)
37
+ rspec (2.8.0)
38
+ rspec-core (~> 2.8.0)
39
+ rspec-expectations (~> 2.8.0)
40
+ rspec-mocks (~> 2.8.0)
41
+ rspec-core (2.8.0)
42
+ rspec-expectations (2.8.0)
43
+ diff-lcs (~> 1.1.2)
44
+ rspec-mocks (2.8.0)
45
+ ruby-debug (0.10.4)
46
+ columnize (>= 0.1)
47
+ ruby-debug-base (~> 0.10.4.0)
48
+ ruby-debug-base (0.10.4)
49
+ linecache (>= 0.3)
50
+ ruby-debug-base19 (0.11.25)
51
+ columnize (>= 0.3.1)
52
+ linecache19 (>= 0.5.11)
53
+ ruby_core_source (>= 0.1.4)
54
+ ruby-debug19 (0.11.6)
55
+ columnize (>= 0.3.1)
56
+ linecache19 (>= 0.5.11)
57
+ ruby-debug-base19 (>= 0.11.19)
58
+ ruby_core_source (0.1.5)
59
+ archive-tar-minitar (>= 0.5.2)
60
+ taskmapper (0.8.0)
61
+ activeresource (~> 3.0)
62
+ activesupport (~> 3.0)
63
+ hashie (~> 1.2)
64
+ vcr (1.11.3)
65
+ yard (0.7.5)
66
+
67
+ PLATFORMS
68
+ ruby
69
+ x86-mingw32
70
+
71
+ DEPENDENCIES
72
+ fakeweb (~> 1.3)
73
+ jeweler (~> 1.5)
74
+ rally_rest_api (~> 1.0)
75
+ rspec (~> 2.3)
76
+ ruby-debug
77
+ ruby-debug19
78
+ taskmapper (~> 0.8)
79
+ vcr (~> 1.11)
80
+ yard (~> 0.7)
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Simeon F. Willbanks, Rob Kaufman
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.
@@ -0,0 +1,65 @@
1
+ # taskmapper-rally
2
+
3
+ This is a provider for [taskmapper](http://ticketrb.com). It provides interoperability with [Rally](http://www.rallydev.com/) and it's project planning system through the taskmapper gem.
4
+
5
+ # Usage and Examples
6
+
7
+ First we have to instantiate a new taskmapper instance, your Rally installation should have api access enable:
8
+
9
+ rally = taskmapper.new(:rally, {:username=> 'foo',
10
+ :password => "bar",
11
+ :url => "https://community.rallydev.com/slm"})
12
+
13
+ If you do not pass in the url, username and password, you won't get any information.
14
+
15
+ ## Finding Projects(Projects)
16
+
17
+ rally = taskmapper.new(:rally, {:url => 'https://community.rallydev.com/slm',
18
+ :username => 'foo',
19
+ :password => 'bar'})
20
+ # Project with ID of 1
21
+ project = rally.project(1)
22
+ # Projects with IDs of 1 and 2
23
+ projects = rally.project([1,2])
24
+
25
+ ## Finding Tickets(Defects,Tasks)
26
+
27
+ # Ticket with ID of 1
28
+ ticket = project.ticket(1)
29
+ # Tickets with ID's of 1 and 2
30
+ tickets = project.tickets([1,2])
31
+ # All tickets
32
+ tickets = project.tickets
33
+
34
+ ## Open Tickets
35
+
36
+ # Create a new ticket
37
+ ticket = project.ticket!(:title => 'New Ticket',
38
+ :description => 'Description')
39
+
40
+ ## Finding comments
41
+
42
+ # Finding all comments
43
+ comments = ticket.comments
44
+ # Finding a comment with ID 1
45
+ comment = ticket.comment(1)
46
+
47
+ ## Requirements
48
+
49
+ * rubygems (obviously)
50
+ * taskmapper gem (latest version preferred)
51
+ * rally_rest_api
52
+ * logger (only if you want Rally REST API to log activity)
53
+
54
+ ## Other Notes
55
+
56
+ Since this and the taskmapper gem is still primarily a work-in-progress, minor changes may be incompatible with previous versions. Please be careful about using and updating this gem in production.
57
+
58
+ If you see or find any issues, feel free to open up an issue report.
59
+
60
+ ## Copyright
61
+
62
+ Copyright (c) 2011 Simeon F. Willbanks. See LICENSE.txt for
63
+ further details.
64
+
65
+
@@ -0,0 +1,43 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'rake'
11
+
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |gem|
14
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
+ gem.name = "taskmapper-rally"
16
+ gem.homepage = "http://github.com/simeonwillbanks/taskmapper-rally"
17
+ gem.license = "MIT"
18
+ gem.summary = %Q{taskmapper provider for Rally's Ruby REST API}
19
+ gem.description = %Q{This is a provider for taskmapper. It provides interoperability with Rally and it's project planning system through the taskmapper gem}
20
+ gem.email = ["sfw@simeonfosterwillbanks.com", "rob@notch8.com", "george.rafael@gmail.com"]
21
+ gem.authors = ["Simeon F. Willbanks", "Rob Kaufman", "Rafael George"]
22
+ # Include your dependencies below. Runtime dependencies are required when using your gem,
23
+ # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
24
+ # gem.add_runtime_dependency 'jabber4r', '> 0.1'
25
+ # gem.add_development_dependency 'rspec', '> 1.2.3'
26
+ end
27
+ Jeweler::RubygemsDotOrgTasks.new
28
+
29
+ require 'rspec/core'
30
+ require 'rspec/core/rake_task'
31
+ RSpec::Core::RakeTask.new(:spec) do |spec|
32
+ spec.pattern = FileList['spec/**/*_spec.rb']
33
+ end
34
+
35
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
36
+ spec.pattern = 'spec/**/*_spec.rb'
37
+ spec.rcov = true
38
+ end
39
+
40
+ task :default => :spec
41
+
42
+ require 'yard'
43
+ YARD::Rake::YardocTask.new
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.3.0
@@ -0,0 +1,118 @@
1
+ module TaskMapper::Provider
2
+ module Rally
3
+ # The comment class for taskmapper-rally
4
+ #
5
+ # Remaps
6
+ #
7
+ # id => oid
8
+ # author => user_name
9
+ # body => text
10
+ # created_at => creation_date
11
+ # updated_at => creation_date
12
+ class Comment < TaskMapper::Provider::Base::Comment
13
+
14
+ def initialize(*object)
15
+ if object.first
16
+ args = object
17
+ comment = args.shift
18
+ project_id = args.shift
19
+ ticket_id = args.shift
20
+ @system_data = {:client => comment}
21
+ hash = {
22
+ :oid => comment.oid,
23
+ :project_id => project_id,
24
+ :ticket_id => ticket_id,
25
+ :author => comment.user_name,
26
+ :body => comment.text,
27
+ :created_at => comment.creation_date,
28
+ :updated_at => comment.creation_date,
29
+ :post_number => comment.post_number,
30
+ }
31
+ super(hash)
32
+ end
33
+ end
34
+
35
+ def created_at
36
+ Time.parse(self[:created_at])
37
+ end
38
+
39
+ def updated_at
40
+ Time.parse(self[:updated_at])
41
+ end
42
+
43
+ # Rally REST API aliases String and Fixnum :to_q :to_s
44
+ # However, it does not alias Bignum
45
+ # If a ID is a Bignum, the API will throw undefined method
46
+ # Because of this, we pass all IDs to API as strings
47
+ # taskmapper specs set IDs as integers, so coerce type on get
48
+ def id
49
+ self[:oid].to_i
50
+ end
51
+
52
+ def id=(id)
53
+ self[:oid] = id.to_s
54
+ end
55
+
56
+ def self.find_by_id(project_id, ticket_id, id)
57
+ project = self.rally_project(project_id)
58
+ # Rally Ruby REST API expects IDs as strings
59
+ # For id.to_s see note on Project::id
60
+ query_result = TaskMapper::Provider::Rally.rally.find(:conversation_post, :fetch => false, :project => project) { equal :object_i_d, id.to_s }
61
+ self.new query_result.first, project_id
62
+ end
63
+
64
+ # Accepts a project id, ticket id and attributes hash and returns all
65
+ # comments matching the project, ticket and those attributes in an array
66
+ # Should return all ticket comments if the attributes hash is empty
67
+ def self.find_by_attributes(project_id, ticket_id, attributes = {})
68
+ self.search(project_id, ticket_id, attributes)
69
+ end
70
+
71
+ # This is a helper method to find
72
+ def self.search(project_id, ticket_id, options = {}, limit = 1000)
73
+ project = self.rally_project(project_id)
74
+ artifact = project.ticket(:id => ticket_id.to_s)
75
+ query_result = TaskMapper::Provider::Rally.rally.find_all(:conversation_post, :project => project) { equal :artifact, artifact }
76
+ comments = query_result.collect do |comment|
77
+ self.new comment, project_id, ticket_id
78
+ end
79
+ search_by_attribute(comments, options, limit)
80
+ end
81
+
82
+ def self.create(*options)
83
+ options = options.shift
84
+ project = provider_parent(self)::Project.find_by_id(options[:project_id])
85
+ ticket = provider_parent(self)::Ticket.find_by_id(options[:project_id], options[:ticket_id])
86
+ comment = {
87
+ :project => project.system_data[:client],
88
+ :artifact => ticket.system_data[:client],
89
+ :text => options[:body]
90
+ }
91
+ new_comment = TaskMapper::Provider::Rally.rally.create(:conversation_post, comment)
92
+ self.new new_comment
93
+ end
94
+
95
+ private
96
+
97
+ def self.rally_project(project_id)
98
+ taskmapper_project = provider_parent(self)::Project.find_by_id(project_id)
99
+ taskmapper_project.system_data[:client]
100
+ end
101
+
102
+ def self.to_rally_object(hash)
103
+ ticket = {
104
+ :name => hash[:title],
105
+ :description => hash[:description],
106
+ :schedule_state => hash[:resolution] ||= "Defined",
107
+ :state => hash[:status] ||= "Submitted"
108
+ }
109
+ # Rally optional attributes
110
+ ticket[:submitted_by] = hash[:requestor] if hash[:requestor]
111
+ ticket[:owner] = hash[:assignee] if hash[:assignee]
112
+ ticket[:priority] = hash[:priority] if hash[:priority]
113
+ ticket[:work_product] = hash[:work_product] if hash[:work_product]
114
+ ticket
115
+ end
116
+ end
117
+ end
118
+ end
@@ -0,0 +1,86 @@
1
+ module TaskMapper::Provider
2
+ module Rally
3
+ # Project class for taskmapper-rally
4
+ #
5
+ # Remaps
6
+ #
7
+ # id => oid
8
+ # created_at => creation_date
9
+ # updated_at => creation_date
10
+ class Project < TaskMapper::Provider::Base::Project
11
+
12
+ def initialize(*object)
13
+ if object.first
14
+ project = object.first
15
+ # Store Rally Project object in taskmapper Project object
16
+ # This allows taskmapper to perform updates on Rally Project
17
+ @system_data = {:client => project}
18
+ hash = {:oid => project.oid,
19
+ :name => project.name,
20
+ :description => project.description,
21
+ :created_at => project.creation_date,
22
+ # Rally Project object does not have a modified time
23
+ :updated_at => project.creation_date}
24
+ super hash
25
+ end
26
+ end
27
+
28
+ def created_at
29
+ Time.parse(self[:created_at])
30
+ end
31
+
32
+ def updated_at
33
+ Time.parse(self[:updated_at])
34
+ end
35
+
36
+ # Rally REST API aliases String and Fixnum :to_q :to_s
37
+ # However, it does not alias Bignum
38
+ # If a ID is a Bignum, the API will throw undefined method
39
+ # Because of this, we pass all IDs to API as strings
40
+ # taskmapper specs set IDs as integers, so coerce type on get
41
+ def id
42
+ self[:oid].to_i
43
+ end
44
+
45
+ def id=(id)
46
+ self[:oid] = id.to_s
47
+ end
48
+
49
+ # Accepts an integer id and returns the single project instance
50
+ def self.find_by_id(id)
51
+ # Rally Ruby REST API expects IDs as strings
52
+ # For id.to_s see note on Project::id
53
+ query_result = TaskMapper::Provider::Rally.rally.find(:project, :fetch => true) { equal :object_i_d, id.to_s }
54
+ self.new query_result.first
55
+ end
56
+
57
+ # Accepts an attributes hash and returns all projects matching those attributes in an array
58
+ # Should return all projects if the attributes hash is empty
59
+ def self.find_by_attributes(attributes = {})
60
+ self.search(attributes)
61
+ end
62
+
63
+ # This is a helper method to find
64
+ def self.search(options = {}, limit = 1000)
65
+ projects = TaskMapper::Provider::Rally.rally.find_all(:project).collect do |project|
66
+ self.new project
67
+ end
68
+ search_by_attribute(projects, options, limit)
69
+ end
70
+
71
+ # copy from this.copy(that) copies that into this
72
+ def copy(project)
73
+ project.tickets.each do |ticket|
74
+ copy_ticket = self.ticket!(:title => ticket.title, :description => ticket.description)
75
+ ticket.comments.each do |comment|
76
+ copy_ticket.comment!(:body => comment.body)
77
+ sleep 1
78
+ end
79
+ end
80
+ end
81
+
82
+ end
83
+ end
84
+ end
85
+
86
+