ticketmaster-jira 0.0.3 → 0.0.4

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/.gitignore ADDED
@@ -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
+
data/Gemfile.lock ADDED
@@ -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
data/Rakefile ADDED
@@ -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.4"
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,69 @@
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
+ []
55
+ end
56
+
57
+ def comment(*options)
58
+ nil
59
+ end
60
+
61
+ private
62
+ def normalize_datetime(datetime)
63
+ Time.mktime(datetime.year, datetime.month, datetime.day, datetime.hour, datetime.min, datetime.sec)
64
+ end
65
+
66
+ end
67
+
68
+ end
69
+ 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,40 @@
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
+ pending
35
+ @ticket.comments.should be_an_instance_of(Array)
36
+ @ticket.comments.first.should be_an_instance_of(@klass)
37
+ end
38
+
39
+ it "should be able to create a comment"
40
+ 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,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ $:.push File.expand_path("../lib", __FILE__)
4
+ require 'lib/jira/version'
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = 'ticketmaster-jira'
8
+ s.version = TicketMaster::Jira::VERSION
9
+ s.platform = Gem::Platform::RUBY
10
+ s.authors = ["Charles Lowell", "Rafael George"]
11
+ s.email = ["cowboyd@thefrontside.net", "rafael@hybridgroup.com"]
12
+ s.homepage = 'http://github.com/hybridgroup/ticketmaster-jira'
13
+ s.summary = %q{TicketMaster binding for JIRA}
14
+ s.description = %q{Interact with Atlassian JIRA ticketing system from Ruby}
15
+ s.add_dependency 'ticketmaster'
16
+ s.add_dependency 'jira4r-jh'
17
+ s.add_development_dependency 'rspec', '>=2.0.0'
18
+ s.files = `git ls-files`.split("\n")
19
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
21
+ s.require_paths = ["lib"]
22
+ end
metadata CHANGED
@@ -1,24 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ticketmaster-jira
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Charles Lowell
14
+ - Rafael George
14
15
  autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2011-05-18 00:00:00 -04:00
19
+ date: 2011-05-20 00:00:00 +00:00
19
20
  default_executable:
20
21
  dependencies:
21
22
  - !ruby/object:Gem::Dependency
23
+ prerelease: false
24
+ name: ticketmaster
22
25
  version_requirements: &id001 !ruby/object:Gem::Requirement
23
26
  none: false
24
27
  requirements:
@@ -28,11 +31,11 @@ dependencies:
28
31
  segments:
29
32
  - 0
30
33
  version: "0"
31
- requirement: *id001
32
- prerelease: false
33
34
  type: :runtime
34
- name: ticketmaster
35
+ requirement: *id001
35
36
  - !ruby/object:Gem::Dependency
37
+ prerelease: false
38
+ name: jira4r-jh
36
39
  version_requirements: &id002 !ruby/object:Gem::Requirement
37
40
  none: false
38
41
  requirements:
@@ -42,11 +45,11 @@ dependencies:
42
45
  segments:
43
46
  - 0
44
47
  version: "0"
45
- requirement: *id002
46
- prerelease: false
47
48
  type: :runtime
48
- name: jira4r-jh
49
+ requirement: *id002
49
50
  - !ruby/object:Gem::Dependency
51
+ prerelease: false
52
+ name: rspec
50
53
  version_requirements: &id003 !ruby/object:Gem::Requirement
51
54
  none: false
52
55
  requirements:
@@ -58,23 +61,38 @@ dependencies:
58
61
  - 0
59
62
  - 0
60
63
  version: 2.0.0
61
- requirement: *id003
62
- prerelease: false
63
64
  type: :development
64
- name: rspec
65
- description: Interact with Atlassian JIRA ticketing system from ruby
65
+ requirement: *id003
66
+ description: Interact with Atlassian JIRA ticketing system from Ruby
66
67
  email:
67
68
  - cowboyd@thefrontside.net
69
+ - rafael@hybridgroup.com
68
70
  executables: []
69
71
 
70
72
  extensions: []
71
73
 
72
74
  extra_rdoc_files: []
73
75
 
74
- files: []
75
-
76
+ files:
77
+ - .gitignore
78
+ - .rvmrc
79
+ - Gemfile
80
+ - Gemfile.lock
81
+ - Rakefile
82
+ - lib/jira/version.rb
83
+ - lib/provider/comment.rb
84
+ - lib/provider/jira.rb
85
+ - lib/provider/project.rb
86
+ - lib/provider/ticket.rb
87
+ - lib/ticketmaster-jira.rb
88
+ - spec/comment_spec.rb
89
+ - spec/project_spec.rb
90
+ - spec/spec_helper.rb
91
+ - spec/ticket_spec.rb
92
+ - spec/ticketmaster-jira_spec.rb
93
+ - ticketmaster-jira.gemspec
76
94
  has_rdoc: true
77
- homepage: http://github.com/cowboyd/ticketmaster-jira
95
+ homepage: http://github.com/hybridgroup/ticketmaster-jira
78
96
  licenses: []
79
97
 
80
98
  post_install_message:
@@ -103,9 +121,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
121
  requirements: []
104
122
 
105
123
  rubyforge_project:
106
- rubygems_version: 1.6.1
124
+ rubygems_version: 1.6.0
107
125
  signing_key:
108
126
  specification_version: 3
109
127
  summary: TicketMaster binding for JIRA
110
- test_files: []
111
-
128
+ test_files:
129
+ - spec/comment_spec.rb
130
+ - spec/project_spec.rb
131
+ - spec/spec_helper.rb
132
+ - spec/ticket_spec.rb
133
+ - spec/ticketmaster-jira_spec.rb