ticketmaster-jira 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.
@@ -0,0 +1,2 @@
1
+ .bundle
2
+ pkg/
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm 1.8.7@ticketmaster-jira --create
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source :rubygems
2
+
3
+ gem 'ticketmaster'
4
+ gem 'jira4r-jh'
5
+
6
+ group :development do
7
+ gem "rspec"
8
+ end
9
+
@@ -0,0 +1,51 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ activemodel (3.0.7)
5
+ activesupport (= 3.0.7)
6
+ builder (~> 2.1.2)
7
+ i18n (~> 0.5.0)
8
+ activeresource (3.0.7)
9
+ activemodel (= 3.0.7)
10
+ activesupport (= 3.0.7)
11
+ activesupport (3.0.7)
12
+ builder (2.1.2)
13
+ diff-lcs (1.1.2)
14
+ git (1.2.5)
15
+ hashie (1.0.0)
16
+ httpclient (2.2.0.2)
17
+ i18n (0.5.0)
18
+ jeweler (1.6.0)
19
+ bundler (~> 1.0.0)
20
+ git (>= 1.2.5)
21
+ rake
22
+ jira4r-jh (0.4.0)
23
+ soap4r
24
+ soap4r
25
+ rake (0.8.7)
26
+ rspec (2.6.0)
27
+ rspec-core (~> 2.6.0)
28
+ rspec-expectations (~> 2.6.0)
29
+ rspec-mocks (~> 2.6.0)
30
+ rspec-core (2.6.0)
31
+ rspec-expectations (2.6.0)
32
+ diff-lcs (~> 1.1.2)
33
+ rspec-mocks (2.6.0)
34
+ soap4r (1.5.8)
35
+ httpclient (>= 2.1.1)
36
+ ticketmaster (0.5.6)
37
+ activeresource
38
+ activeresource (>= 2.3.2)
39
+ activesupport
40
+ activesupport (>= 2.3.2)
41
+ hashie (= 1.0.0)
42
+ hashie
43
+ jeweler
44
+
45
+ PLATFORMS
46
+ ruby
47
+
48
+ DEPENDENCIES
49
+ jira4r-jh
50
+ rspec
51
+ ticketmaster
@@ -0,0 +1,10 @@
1
+ require 'bundler/setup'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ task :default => :spec
5
+
6
+ desc "run specs"
7
+ task :spec do
8
+ sh "bundle exec rspec --color spec/"
9
+ end
10
+
@@ -0,0 +1,5 @@
1
+ class TicketMaster
2
+ module Jira
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,46 @@
1
+ module TicketMaster::Provider
2
+ module Jira
3
+ # The comment class for ticketmaster-jira
4
+ #
5
+ # Do any mapping between Ticketmaster and your system's comment model here
6
+ # versions of the ticket.
7
+ #
8
+ class Comment < TicketMaster::Provider::Base::Comment
9
+ #API = Jira::Comment # The class to access the api's comments
10
+ # declare needed overloaded methods here
11
+
12
+ def initialize(*object)
13
+ if object.first
14
+ object = object.first
15
+ unless object.is_a? Hash
16
+ @system_data = {:client => object}
17
+ hash = {:id => object.id,
18
+ :author => object.author,
19
+ :body => object.body,
20
+ :created_at => object.created,
21
+ :updated_at => object.updated,
22
+ :ticket_id => object.ticket_id,
23
+ :project_id => object.project_id}
24
+ else
25
+ hash = object
26
+ end
27
+ super(hash)
28
+ end
29
+ end
30
+
31
+ def self.find(project_id, ticket_id, *options)
32
+ if options.first.empty?
33
+ self.find_all(project_id, ticket_id)
34
+ end
35
+ end
36
+
37
+ def self.find_all(project_id, ticket_id)
38
+ begin
39
+ $jira.getComments(ticket_id).map { |comment| self.new comment }
40
+ rescue
41
+ [TicketMaster::Provider::Jira::Comment]
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,34 @@
1
+ module TicketMaster::Provider
2
+ # This is the Jira Provider for ticketmaster
3
+ module Jira
4
+ include TicketMaster::Provider::Base
5
+ #TICKET_API = Jira::Ticket # The class to access the api's tickets
6
+ #PROJECT_API = Jira::Project # The class to access the api's projects
7
+
8
+ # This is for cases when you want to instantiate using TicketMaster::Provider::Jira.new(auth)
9
+ def self.new(auth = {})
10
+ TicketMaster.new(:jira, auth)
11
+ end
12
+
13
+ # Providers must define an authorize method. This is used to initialize and set authentication
14
+ # parameters to access the API
15
+ def authorize(auth = {})
16
+ @authentication ||= TicketMaster::Authenticator.new(auth)
17
+ $jira = Jira4R::JiraTool.new(2,@authentication.url)
18
+ $jira.login(@authentication.username, @authentication.password)
19
+ # Set authentication parameters for whatever you're using to access the API
20
+ end
21
+
22
+ # declare needed overloaded methods here
23
+
24
+ def project(*options)
25
+ if options.first.is_a? Fixnum
26
+ Project.find_by_id(options.first)
27
+ elsif options.first.is_a? Hash
28
+ Project.find_by_attributes(options.first).first
29
+ end
30
+ end
31
+ end
32
+ end
33
+
34
+
@@ -0,0 +1,66 @@
1
+ module TicketMaster::Provider
2
+ module Jira
3
+ # Project class for ticketmaster-jira
4
+ #
5
+ #
6
+ class Project < TicketMaster::Provider::Base::Project
7
+ #API = Jira::Project # The class to access the api's projects
8
+ # declare needed overloaded methods here
9
+ # copy from this.copy(that) copies that into this
10
+ def initialize(*object)
11
+ if object.first
12
+ object = object.first
13
+ unless object.is_a? Hash
14
+ @system_data = {:client => object}
15
+ hash = {:id => object.id.to_i,
16
+ :name => object.name,
17
+ :description => object.description}
18
+ else
19
+ hash = object
20
+ end
21
+ super(hash)
22
+ end
23
+ end
24
+
25
+ def copy(project)
26
+ project.tickets.each do |ticket|
27
+ copy_ticket = self.ticket!(:title => ticket.title, :description => ticket.description)
28
+ ticket.comments.each do |comment|
29
+ copy_ticket.comment!(:body => comment.body)
30
+ sleep 1
31
+ end
32
+ end
33
+ end
34
+
35
+ def self.find(*options)
36
+ jira_projects = self.find_all
37
+ if options.first.is_a? Array
38
+ jira_projects.select do |project|
39
+ project if options.first.any? { |id| project.id == id }
40
+ end
41
+ elsif options.first.is_a? Hash
42
+ find_by_attributes(options.first)
43
+ else
44
+ jira_projects
45
+ end
46
+ end
47
+
48
+ def self.find_by_attributes(attributes = {})
49
+ search_by_attribute(self.find_all, attributes)
50
+ end
51
+
52
+ def self.find_all
53
+ $jira.getProjectsNoSchemes().map do |project|
54
+ Project.new project
55
+ end
56
+ end
57
+
58
+ def self.find_by_id(id)
59
+ self.find_all.select { |project| project.id == id }.first
60
+ end
61
+
62
+ end
63
+ end
64
+ end
65
+
66
+
@@ -0,0 +1,65 @@
1
+ module TicketMaster::Provider
2
+ module Jira
3
+ # Ticket class for ticketmaster-jira
4
+ #
5
+
6
+ class Ticket < TicketMaster::Provider::Base::Ticket
7
+ #API = Jira::Ticket # The class to access the api's tickets
8
+ # declare needed overloaded methods here
9
+ def initialize(*object)
10
+ if object.first
11
+ object = object.first
12
+ unless object.is_a? Hash
13
+ @system_data = {:client => object}
14
+ hash = {:id => object.id.to_i,
15
+ :status => object.status,
16
+ :priority => object.priority,
17
+ :title => object.summary,
18
+ :resolution => object.resolution,
19
+ :created_at => object.created,
20
+ :updated_at => object.updated,
21
+ :description => object.description,
22
+ :assignee => object.assignee,
23
+ :requestor => object.reporter}
24
+ else
25
+ hash = object
26
+ end
27
+ super(hash)
28
+ end
29
+ end
30
+
31
+ def updated_at
32
+ normalize_datetime(self[:updated_at])
33
+ end
34
+
35
+ def created_at
36
+ normalize_datetime(self[:created_at])
37
+ end
38
+
39
+ def self.find_by_attributes(project_id, attributes = {})
40
+ search_by_attribute(self.find_all(project_id), attributes)
41
+ end
42
+
43
+ def self.find_by_id(project_id, id)
44
+ self.find_all(project_id).select { |ticket| ticket.id == id }.first
45
+ end
46
+
47
+ def self.find_all(project_id)
48
+ $jira.getIssuesFromJqlSearch("project = #{project_id}", 200).map do |ticket|
49
+ self.new ticket
50
+ end
51
+ end
52
+
53
+ def comments(*options)
54
+ Comment.find(self.project_id, self.ticket_id, options)
55
+ end
56
+
57
+ private
58
+ def normalize_datetime(datetime)
59
+ Time.mktime(datetime.year, datetime.month, datetime.day, datetime.hour, datetime.min, datetime.sec)
60
+ end
61
+
62
+ end
63
+
64
+ end
65
+ end
@@ -0,0 +1,6 @@
1
+ require 'ticketmaster'
2
+ require 'jira4r/jira_tool'
3
+
4
+ %w{ jira ticket project comment }.each do |f|
5
+ require File.dirname(__FILE__) + '/provider/' + f + '.rb';
6
+ end
@@ -0,0 +1,39 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "TicketMaster::Provider::Jira::Comment" do
4
+ before(:each) do
5
+ @url = "some_url"
6
+ @fj = FakeJiraTool.new
7
+ @project_jira = Struct.new(:id, :name, :description).new(1, 'project', 'project description')
8
+ @ticket = Struct.new(:id,
9
+ :status,
10
+ :priority,
11
+ :summary,
12
+ :resolution,
13
+ :created,
14
+ :updated,
15
+ :description, :assignee, :reporter).new(1,'open','high', 'ticket 1', 'none', Time.now, Time.now, 'description', 'myself', 'yourself')
16
+ @comment = Struct.new(:id, :author, :body, :created, :updated, :ticket_id, :project_id).new(1,
17
+ 'myself',
18
+ 'body',
19
+ Time.now,
20
+ Time.now,
21
+ 1,
22
+ 1)
23
+ Jira4R::JiraTool.stub!(:new).with(2, @url).and_return(@fj)
24
+ @fj.stub!(:getProjectsNoSchemes).and_return([@project_jira, @project_jira])
25
+ @fj.stub!(:getProjectById).and_return(@project_jira)
26
+ @fj.stub!(:getIssuesFromJqlSearch).and_return([@ticket])
27
+ @fj.stub!(:getComments).and_return([@comment])
28
+ @tm = TicketMaster.new(:jira, :username => 'testuser', :password => 'testuser', :url => @url)
29
+ @ticket = @tm.projects.first.tickets.first
30
+ @klass = TicketMaster::Provider::Jira::Comment
31
+ end
32
+
33
+ it "should be able to load all comments" do
34
+ @ticket.comments.should be_an_instance_of(Array)
35
+ @ticket.comments.first.should be_an_instance_of(@klass)
36
+ end
37
+
38
+ it "should be able to create a comment"
39
+ end
@@ -0,0 +1,39 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "TicketMaster::Provider::Jira::Project" do
4
+ before(:each) do
5
+ @url = "some_url"
6
+ @fj = FakeJiraTool.new
7
+ @project = Struct.new(:id, :name, :description).new(1,
8
+ 'project',
9
+ 'project description')
10
+ Jira4R::JiraTool.stub!(:new).with(2, @url).and_return(@fj)
11
+ @fj.stub!(:getProjectsNoSchemes).and_return([@project, @project])
12
+ @fj.stub!(:getProjectByKey).and_return(@project)
13
+ @tm = TicketMaster.new(:jira, :username => 'testuser', :password => 'testuser', :url => @url)
14
+ @klass = TicketMaster::Provider::Jira::Project
15
+ end
16
+
17
+ it "should be able to load all projects" do
18
+ @tm.projects.should be_an_instance_of(Array)
19
+ @tm.projects.first.should be_an_instance_of(@klass)
20
+ end
21
+
22
+ it "should be able to load all projects based on an array of id's" do
23
+ @tm.projects([1]).should be_an_instance_of(Array)
24
+ @tm.projects.first.should be_an_instance_of(@klass)
25
+ @tm.projects.first.id.should == 1
26
+ end
27
+
28
+ it "should be able to load a single project based on id" do
29
+ project = @tm.project(1)
30
+ project.should be_an_instance_of(@klass)
31
+ project.name.should == 'project'
32
+ end
33
+
34
+ it "should be able to load a single project by attributes" do
35
+ project = @tm.project(:id => 1)
36
+ project.should be_an_instance_of(@klass)
37
+ project.name.should == 'project'
38
+ end
39
+ end
@@ -0,0 +1,22 @@
1
+ $:.unshift(File.expand_path(File.dirname(__FILE__) + '/../lib'))
2
+ require 'ticketmaster-jira'
3
+ require 'rspec/expectations'
4
+
5
+ class FakeJiraTool
6
+ attr_accessor :call_stack, :returns
7
+
8
+ def initialize
9
+ @call_stack = []
10
+ @returns = {}
11
+ end
12
+
13
+ def method_missing *args
14
+ @call_stack << args
15
+ @returns.delete(args.first) if @returns.key?(args.first)
16
+ end
17
+ end
18
+
19
+ RSpec.configure do |config|
20
+ config.mock_framework = :rspec
21
+ end
22
+
@@ -0,0 +1,49 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "TicketMaster::Provider::Jira::Ticket" do
4
+ before(:each) do
5
+ @url = "some_url"
6
+ @fj = FakeJiraTool.new
7
+ @project_jira = Struct.new(:id, :name, :description).new(1, 'project', 'project description')
8
+ @ticket = Struct.new(:id,
9
+ :status,
10
+ :priority,
11
+ :summary,
12
+ :resolution,
13
+ :created,
14
+ :updated,
15
+ :description, :assignee, :reporter).new(1,'open','high', 'ticket 1', 'none', Time.now, Time.now, 'description', 'myself', 'yourself')
16
+ Jira4R::JiraTool.stub!(:new).with(2, @url).and_return(@fj)
17
+ @fj.stub!(:getProjectsNoSchemes).and_return([@project_jira, @project_jira])
18
+ @fj.stub!(:getProjectById).and_return(@project_jira)
19
+ @fj.stub!(:getIssuesFromJqlSearch).and_return([@ticket])
20
+ @tm = TicketMaster.new(:jira, :username => 'testuser', :password => 'testuser', :url => @url)
21
+ @project_tm = @tm.projects.first
22
+ @klass = TicketMaster::Provider::Jira::Ticket
23
+ end
24
+
25
+ it "should be able to load all tickets" do
26
+ @project_tm.tickets.should be_an_instance_of(Array)
27
+ @project_tm.tickets.first.should be_an_instance_of(@klass)
28
+ end
29
+
30
+ it "should be able to load all tickets based on array of id's" do
31
+ tickets = @project_tm.tickets([1])
32
+ tickets.should be_an_instance_of(Array)
33
+ tickets.first.should be_an_instance_of(@klass)
34
+ tickets.first.id.should == 1
35
+ end
36
+
37
+ it "should be able to load a single ticket based on id" do
38
+ ticket = @project_tm.ticket(1)
39
+ ticket.should be_an_instance_of(@klass)
40
+ ticket.id.should == 1
41
+ end
42
+
43
+ it "should be able to load a single ticket based on attributes" do
44
+ ticket = @project_tm.ticket(:id => 1)
45
+ ticket.should be_an_instance_of(@klass)
46
+ ticket.id.should == 1
47
+ end
48
+
49
+ end
@@ -0,0 +1,15 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "TicketMaster::Provider::Jira" do
4
+ before(:each) do
5
+ @url = "some_url"
6
+ @fj = FakeJiraTool.new
7
+ Jira4R::JiraTool.stub!(:new).with(2, @url).and_return(@fj)
8
+ end
9
+
10
+ it "should be able to instantiate a new ticketmaster instance" do
11
+ @tm = TicketMaster.new(:jira, :username => 'testing', :password => 'testing', :url => @url)
12
+ @tm.should be_an_instance_of(TicketMaster)
13
+ @tm.should be_a_kind_of(TicketMaster::Provider::Jira)
14
+ end
15
+ end
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "lib/jira/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "ticketmaster-jira"
7
+ s.version = TicketMaster::Jira::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Charles Lowell"]
10
+ s.email = ["cowboyd@thefrontside.net"]
11
+ s.homepage = "http://github.com/cowboyd/ticketmaster-jira"
12
+ s.summary = %q{TicketMaster binding for JIRA}
13
+ s.description = %q{Interact with Atlassian JIRA ticketing system from ruby}
14
+ s.add_dependency "ticketmaster"
15
+ s.add_dependency "jira4r"
16
+ s.add_development_dependency "rspec", ">= 2.0.0"
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+ end
metadata ADDED
@@ -0,0 +1,131 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ticketmaster-jira
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Charles Lowell
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-05-17 00:00:00 -04:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ version_requirements: &id001 !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ hash: 3
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ requirement: *id001
32
+ prerelease: false
33
+ type: :runtime
34
+ name: ticketmaster
35
+ - !ruby/object:Gem::Dependency
36
+ version_requirements: &id002 !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ hash: 3
42
+ segments:
43
+ - 0
44
+ version: "0"
45
+ requirement: *id002
46
+ prerelease: false
47
+ type: :runtime
48
+ name: jira4r
49
+ - !ruby/object:Gem::Dependency
50
+ version_requirements: &id003 !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ hash: 15
56
+ segments:
57
+ - 2
58
+ - 0
59
+ - 0
60
+ version: 2.0.0
61
+ requirement: *id003
62
+ prerelease: false
63
+ type: :development
64
+ name: rspec
65
+ description: Interact with Atlassian JIRA ticketing system from ruby
66
+ email:
67
+ - cowboyd@thefrontside.net
68
+ executables: []
69
+
70
+ extensions: []
71
+
72
+ extra_rdoc_files: []
73
+
74
+ files:
75
+ - .gitignore
76
+ - .rvmrc
77
+ - Gemfile
78
+ - Gemfile.lock
79
+ - Rakefile
80
+ - lib/jira/version.rb
81
+ - lib/provider/comment.rb
82
+ - lib/provider/jira.rb
83
+ - lib/provider/project.rb
84
+ - lib/provider/ticket.rb
85
+ - lib/ticketmaster-jira.rb
86
+ - spec/comment_spec.rb
87
+ - spec/project_spec.rb
88
+ - spec/spec_helper.rb
89
+ - spec/ticket_spec.rb
90
+ - spec/ticketmaster-jira_spec.rb
91
+ - ticketmaster-jira.gemspec
92
+ has_rdoc: true
93
+ homepage: http://github.com/cowboyd/ticketmaster-jira
94
+ licenses: []
95
+
96
+ post_install_message:
97
+ rdoc_options: []
98
+
99
+ require_paths:
100
+ - lib
101
+ required_ruby_version: !ruby/object:Gem::Requirement
102
+ none: false
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ hash: 3
107
+ segments:
108
+ - 0
109
+ version: "0"
110
+ required_rubygems_version: !ruby/object:Gem::Requirement
111
+ none: false
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ hash: 3
116
+ segments:
117
+ - 0
118
+ version: "0"
119
+ requirements: []
120
+
121
+ rubyforge_project:
122
+ rubygems_version: 1.6.1
123
+ signing_key:
124
+ specification_version: 3
125
+ summary: TicketMaster binding for JIRA
126
+ test_files:
127
+ - spec/comment_spec.rb
128
+ - spec/project_spec.rb
129
+ - spec/spec_helper.rb
130
+ - spec/ticket_spec.rb
131
+ - spec/ticketmaster-jira_spec.rb