ticketmaster-unfuddle 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -11,7 +11,9 @@ begin
11
11
  gem.homepage = "http://ticketrb.com"
12
12
  gem.authors = ["Sirupsen"]
13
13
  gem.add_dependency "unfuddler", ">= 0"
14
- gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
14
+ gem.add_dependency "ticketmaster", ">= 0"
15
+
16
+ gem.add_development_dependency "shoulda", ">= 0"
15
17
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
16
18
  end
17
19
  Jeweler::GemcutterTasks.new
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.1.0
@@ -0,0 +1,55 @@
1
+ module TicketMasterMod
2
+ module Unfuddle
3
+ class Project
4
+ class << self
5
+ def find(query, options = {})
6
+ Unfuddler.authenticate(options[:authentication].to_hash)
7
+ projects = Unfuddler::Project.find
8
+ formatted_projects = []
9
+
10
+ unless projects.empty?
11
+ projects.each do |project|
12
+ formatted_projects << TicketMasterMod::Project.new({
13
+ :name => project.short_name,
14
+ :description => project.description,
15
+ :system => "unfuddle",
16
+ :authentication => options[:authentication],
17
+ :id => project.id,
18
+ })
19
+ end
20
+ end
21
+
22
+ formatted_projects
23
+ end
24
+
25
+ def tickets(project_instance)
26
+ Unfuddler.authenticate(project_instance.authentication.to_hash)
27
+ project = Unfuddler::Project.find(project_instance.name)
28
+ formatted_tickets = []
29
+
30
+ unless project.tickets.empty?
31
+ project.tickets.each do |ticket|
32
+ formatted_tickets << TicketMasterMod::Ticket.new({
33
+ :summary => ticket.summary,
34
+ :id => ticket.number,
35
+ :status => ticket.status,
36
+ :description => ticket.description,
37
+
38
+ :resolution => ticket.resolution,
39
+ :resolution_description => ticket.resolution_description,
40
+
41
+ :created_at => ticket.created_at,
42
+
43
+ :system => "unfuddle",
44
+ :ticket => ticket,
45
+ :project => project_instance
46
+ })
47
+ end
48
+ end
49
+
50
+ formatted_tickets
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,55 @@
1
+ module TicketMasterMod
2
+ module Unfuddle
3
+ class Ticket
4
+ class << self
5
+ def create(ticket)
6
+ Unfuddler.authenticate(ticket.project.authentication.to_hash)
7
+ project = Unfuddler::Project.find(ticket.project.name)
8
+
9
+ new_ticket = {}
10
+ ticket.to_hash.each_pair do |key, value|
11
+ new_ticket[key] = value if [:summary, :priority, :description].include?(key.to_sym)
12
+ new_ticket[key] = value.to_s if value.is_a?(Integer)
13
+ end
14
+
15
+ project.ticket.create(new_ticket)
16
+ end
17
+
18
+ def save(ticket)
19
+ Unfuddler.authenticate(ticket.project.authentication.to_hash)
20
+ project = Unfuddler::Project.find(ticket.project.name)
21
+ unfuddle_ticket = project.tickets(:number => ticket.id).first # First because it always returns an array
22
+
23
+ # DRY this up!
24
+ status = right_status(ticket.status)
25
+ unfuddle_ticket.status = status if status
26
+ unfuddle_ticket.description = ticket.description
27
+ unfuddle_ticket.summary = ticket.summary
28
+
29
+ unfuddle_ticket.save
30
+ end
31
+
32
+ def close(ticket, resolution)
33
+ Unfuddler.authenticate(ticket.project.authentication.to_hash)
34
+ project = Unfuddler::Project.find(ticket.project.name)
35
+
36
+ ticket = project.tickets(:number => ticket.id).first # First because it always returns an array
37
+ ticket.close!(resolution)
38
+ end
39
+
40
+ def right_status(status)
41
+ case status
42
+ when :in_progress
43
+ "accepted"
44
+ when :resolved
45
+ "resolved"
46
+ when :reopen
47
+ "reopen"
48
+ else
49
+ nil
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -1,106 +1,2 @@
1
1
  require 'unfuddler'
2
-
3
- module TicketMasterMod
4
- module Unfuddle
5
- class Ticket
6
- def self.create(ticket)
7
- Unfuddler.authenticate(ticket.project.authentication.to_hash)
8
- project = Unfuddler::Project.find(ticket.project.name)
9
-
10
- new_ticket = {}
11
- ticket.to_hash.each_pair do |key, value|
12
- new_ticket[key] = value if [:summary, :priority, :description].include?(key.to_sym)
13
- new_ticket[key] = value.to_s if value.is_a?(Integer)
14
- end
15
-
16
- project.ticket.create(new_ticket)
17
- end
18
-
19
- def self.save(ticket)
20
- Unfuddler.authenticate(ticket.project.authentication.to_hash)
21
- project = Unfuddler::Project.find(ticket.project.name)
22
- unfuddle_ticket = project.tickets(:number => ticket.id).first # First because it always returns an array
23
-
24
- # DRY this up!
25
- status = right_status(ticket.status)
26
- unfuddle_ticket.status = status if status
27
- unfuddle_ticket.description = ticket.description
28
- unfuddle_ticket.summary = ticket.summary
29
-
30
- unfuddle_ticket.save
31
- end
32
-
33
- def self.close(ticket, resolution)
34
- Unfuddler.authenticate(ticket.project.authentication.to_hash)
35
- project = Unfuddler::Project.find(ticket.project.name)
36
-
37
- ticket = project.tickets(:number => ticket.id).first # First because it always returns an array
38
- ticket.close!(resolution)
39
- end
40
-
41
- private
42
- def self.right_status(status)
43
- case status
44
- when :in_progress
45
- "accepted"
46
- when :resolved
47
- "resolved"
48
- when :reopen
49
- "reopen"
50
- else
51
- nil
52
- end
53
- end
54
- end
55
-
56
- class Project
57
- def self.find(query, options = {})
58
- Unfuddler.authenticate(options[:authentication].to_hash)
59
- projects = Unfuddler::Project.find
60
- formatted_projects = []
61
-
62
- unless projects.empty?
63
- projects.each do |project|
64
- formatted_projects << TicketMasterMod::Project.new({
65
- :name => project.short_name,
66
- :description => project.description,
67
- :system => "unfuddle",
68
- :authentication => options[:authentication],
69
- :id => project.id,
70
- })
71
- end
72
- end
73
-
74
- formatted_projects
75
- end
76
-
77
- def self.tickets(project_instance)
78
- Unfuddler.authenticate(project_instance.authentication.to_hash)
79
- project = Unfuddler::Project.find("testproject")
80
- formatted_tickets = []
81
-
82
- unless project.tickets.empty?
83
- project.tickets.each do |ticket|
84
- formatted_tickets << TicketMasterMod::Ticket.new({
85
- :summary => ticket.summary,
86
- :id => ticket.number,
87
- :status => ticket.status,
88
- :description => ticket.description,
89
-
90
- :resolution => ticket.resolution,
91
- :resolution_description => ticket.resolution_description,
92
-
93
- :created_at => ticket.created_at,
94
-
95
- :system => "unfuddle",
96
- :ticket => ticket,
97
- :project => project_instance
98
- })
99
- end
100
- end
101
-
102
- formatted_tickets
103
- end
104
- end
105
- end
106
- end
2
+ %w{project ticket}.each {|lib| require "provider/#{lib}"}
@@ -1,4 +1,75 @@
1
1
  require 'helper'
2
+ require 'ticketmaster'
2
3
 
3
4
  class TestTicketmasterUnfuddle < Test::Unit::TestCase
5
+ context "Unfuddle" do
6
+ setup do
7
+ @unfuddle = TicketMaster.new(:unfuddle, {:username => "", :password => "", :subdomain => "ticketmaster"})
8
+ @project = @unfuddle.project.find.first
9
+ end
10
+
11
+ should "find testproject" do
12
+ project = @unfuddle.project.find(:name => "testproject")
13
+
14
+ assert_instance_of TicketMasterMod::Project, project
15
+ assert_equal "testproject", project.name
16
+
17
+ #method 2
18
+ project = @unfuddle.project.find("testproject")
19
+
20
+ assert_instance_of TicketMasterMod::Project, project
21
+ assert_equal "testproject", project.name
22
+
23
+ #method 3
24
+ project = @unfuddle.project["testproject"]
25
+
26
+ assert_instance_of TicketMasterMod::Project, project
27
+ assert_equal "testproject", project.name
28
+ end
29
+
30
+ context "project instance" do
31
+ should "find a project" do
32
+ assert_instance_of TicketMasterMod::Project, @project
33
+ end
34
+
35
+ should "find a bunch of tickets" do
36
+ @project.tickets
37
+ end
38
+
39
+ should "find new tickets" do
40
+ tickets = @project.tickets(:status => "new")
41
+
42
+ tickets.each do |ticket|
43
+ assert_equal "new", ticket.status
44
+ end
45
+ end
46
+
47
+ should "find ticket with id 1" do
48
+ ticket = @project.tickets(:id => 1)
49
+
50
+ assert_equal 1, ticket.id
51
+ end
52
+
53
+ should "create a ticket" do
54
+ assert @project.ticket.create(:priority => 3, :summary => "Test", :description => "Hello World from TicketMaster::Unfuddle").empty?
55
+ end
56
+
57
+ should "change ticket property" do
58
+ ticket = @project.tickets.last
59
+ ticket.description = "Edited description"
60
+ assert ticket.save.empty?
61
+
62
+ ticket = @project.tickets.last
63
+ assert_equal "Edited description", ticket.description
64
+ end
65
+
66
+ should "close the last ticket with a resolution" do
67
+ ticket = @project.tickets.last
68
+ assert ticket.close(:resolution => "fixed", :description => "Fixed issue").empty?
69
+
70
+ ticket = @project.tickets.last
71
+ assert_equal "fixed", ticket.resolution
72
+ end
73
+ end
74
+ end
4
75
  end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ticketmaster-unfuddle
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 27
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
- - 0
8
8
  - 1
9
- version: 0.0.1
9
+ - 0
10
+ version: 0.1.0
10
11
  platform: ruby
11
12
  authors:
12
13
  - Sirupsen
@@ -14,33 +15,51 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-06-12 00:00:00 +02:00
18
+ date: 2010-06-15 00:00:00 +02:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: unfuddler
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - ">="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 3
27
30
  segments:
28
31
  - 0
29
32
  version: "0"
30
33
  type: :runtime
31
34
  version_requirements: *id001
32
35
  - !ruby/object:Gem::Dependency
33
- name: thoughtbot-shoulda
36
+ name: ticketmaster
34
37
  prerelease: false
35
38
  requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
36
40
  requirements:
37
41
  - - ">="
38
42
  - !ruby/object:Gem::Version
43
+ hash: 3
39
44
  segments:
40
45
  - 0
41
46
  version: "0"
42
- type: :development
47
+ type: :runtime
43
48
  version_requirements: *id002
49
+ - !ruby/object:Gem::Dependency
50
+ name: shoulda
51
+ prerelease: false
52
+ requirement: &id003 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ hash: 3
58
+ segments:
59
+ - 0
60
+ version: "0"
61
+ type: :development
62
+ version_requirements: *id003
44
63
  description: Ticketmaster provider for Unfuddle
45
64
  email: simon@hybridgroup.com
46
65
  executables: []
@@ -57,6 +76,8 @@ files:
57
76
  - README.md
58
77
  - Rakefile
59
78
  - VERSION
79
+ - lib/provider/project.rb
80
+ - lib/provider/ticket.rb
60
81
  - lib/ticketmaster-unfuddle.rb
61
82
  - test/helper.rb
62
83
  - test/test_ticketmaster-unfuddle.rb
@@ -70,23 +91,27 @@ rdoc_options:
70
91
  require_paths:
71
92
  - lib
72
93
  required_ruby_version: !ruby/object:Gem::Requirement
94
+ none: false
73
95
  requirements:
74
96
  - - ">="
75
97
  - !ruby/object:Gem::Version
98
+ hash: 3
76
99
  segments:
77
100
  - 0
78
101
  version: "0"
79
102
  required_rubygems_version: !ruby/object:Gem::Requirement
103
+ none: false
80
104
  requirements:
81
105
  - - ">="
82
106
  - !ruby/object:Gem::Version
107
+ hash: 3
83
108
  segments:
84
109
  - 0
85
110
  version: "0"
86
111
  requirements: []
87
112
 
88
113
  rubyforge_project:
89
- rubygems_version: 1.3.6
114
+ rubygems_version: 1.3.7
90
115
  signing_key:
91
116
  specification_version: 3
92
117
  summary: Ticketmaster provider for Unfuddle