ticketmaster-trac 0.1.3 → 0.2.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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.2.4
@@ -7,18 +7,18 @@ module TicketMaster::Provider
7
7
  #
8
8
  class Comment < TicketMaster::Provider::Base::Comment
9
9
  # declare needed overloaded methods here
10
-
10
+
11
11
  def initialize(*object)
12
12
  if object.first
13
13
  object = object.first
14
14
  unless object.is_a? Hash
15
15
  @system_data = {:client => object}
16
16
  hash = {:id => object.id,
17
- :author => object.author,
18
- :body => object.body,
19
- :ticket_id => object.ticket_id,
20
- :created_at => object.created_at,
21
- :updated_at => object.updated_at}
17
+ :author => object.author,
18
+ :body => object.body,
19
+ :ticket_id => object.ticket_id,
20
+ :created_at => object.created_at,
21
+ :updated_at => object.updated_at}
22
22
  else
23
23
  hash = object
24
24
  end
@@ -41,6 +41,7 @@ module TicketMaster::Provider
41
41
  self[:updated_at]
42
42
  end
43
43
  end
44
+
44
45
  end
45
46
  end
46
47
  end
@@ -5,7 +5,6 @@ module TicketMaster::Provider
5
5
  #
6
6
  class Project < TicketMaster::Provider::Base::Project
7
7
  # declare needed overloaded methods here
8
- API = TracAPI
9
8
 
10
9
  def initialize(*object)
11
10
  if object.first
@@ -36,16 +35,18 @@ module TicketMaster::Provider
36
35
 
37
36
  def self.find(*options)
38
37
  mode = options.first
38
+ trac = TicketMaster::Provider::Trac.api
39
39
  if mode.is_a? String
40
- self.new({:url => API.url, :username => API.username, :name=> "#{API.username}-project"})
40
+ self.new({:url => trac[:url], :username => trac[:username], :name=> "#{trac[:username]}-project"})
41
41
  end
42
42
  end
43
43
 
44
44
  def ticket(*options)
45
45
  unless options.empty?
46
46
  options = options.first
47
+ trac = TicketMaster::Provider::Trac.api
47
48
  if options.is_a? Hash
48
- TicketMaster::Provider::Trac::Ticket.find_by_id(API.api.tickets.query(options).first, self[:name])
49
+ TicketMaster::Provider::Trac::Ticket.find_by_id(trac[:trac].tickets.query(options).first, self[:name])
49
50
  end
50
51
  else
51
52
  TicketMaster::Provider::Trac::Ticket
@@ -59,12 +60,13 @@ module TicketMaster::Provider
59
60
 
60
61
  def tickets(*options)
61
62
  mode = options.first
63
+ trac = TicketMaster::Provider::Trac.api
62
64
  if options.empty?
63
- collect_tickets(API.api.tickets.list)
65
+ collect_tickets(trac[:trac].tickets.list)
64
66
  elsif mode.is_a? Array
65
67
  collect_tickets(mode)
66
68
  elsif mode.is_a? Hash
67
- collect_tickets(API.api.tickets.query(mode))
69
+ collect_tickets(trac[:trac].tickets.query(mode))
68
70
  end
69
71
  end
70
72
 
@@ -6,7 +6,6 @@ module TicketMaster::Provider
6
6
  class Ticket < TicketMaster::Provider::Base::Ticket
7
7
  # declare needed overloaded methods here
8
8
 
9
- API = TracAPI
10
9
  def initialize(*object)
11
10
  if object.first
12
11
  args = object
@@ -57,8 +56,9 @@ module TicketMaster::Provider
57
56
  end
58
57
 
59
58
  def self.find_by_id(id, project_id)
59
+ trac = TicketMaster::Provider::Trac.api
60
60
  retryable(:tries => 5) do
61
- self.new API.api.tickets.get(id), project_id
61
+ self.new trac[:trac].tickets.get(id), project_id
62
62
  end
63
63
  end
64
64
 
@@ -66,8 +66,9 @@ module TicketMaster::Provider
66
66
  mandatory = options.shift
67
67
  attributes = {}
68
68
  attributes ||= options.shift
69
+ trac = TicketMaster::Provider::Trac.api
69
70
  begin
70
- self.find_by_id API.api.tickets.create(mandatory[:summary], mandatory[:description], attributes)
71
+ self.find_by_id trac[:trac].tickets.create(mandatory[:summary], mandatory[:description], attributes)
71
72
  rescue
72
73
  self
73
74
  end
@@ -81,8 +82,16 @@ module TicketMaster::Provider
81
82
  end
82
83
  elsif options.first.is_a? Hash
83
84
  hash = options.first
84
- comments.select do |key, value|
85
- hash[key] == value
85
+ comments.select do |comment|
86
+ hash.inject(true) do |memo, kv|
87
+ key, value = kv
88
+ begin
89
+ memo &= comment.send(key) == value
90
+ rescue
91
+ memo = false
92
+ end
93
+ memo
94
+ end
86
95
  end
87
96
  else
88
97
  comments
data/lib/provider/trac.rb CHANGED
@@ -12,7 +12,7 @@ module TicketMaster::Provider
12
12
  @authentication ||= TicketMaster::Authenticator.new(auth)
13
13
  auth = @authentication
14
14
  @trac = ::Trac.new(auth.url, auth.username, auth.password)
15
- TracAPI.new @trac, auth.url, auth.username, auth.password
15
+ TicketMaster::Provider::Trac.api = {:trac => @trac, :url => auth.url, :username => auth.username, :password => auth.password}
16
16
  end
17
17
 
18
18
  # declare needed overloaded methods here
@@ -28,5 +28,13 @@ module TicketMaster::Provider
28
28
  end
29
29
  end
30
30
 
31
+ def self.api=(trac_instance)
32
+ @api = trac_instance
33
+ end
34
+
35
+ def self.api
36
+ @api
37
+ end
38
+
31
39
  end
32
40
  end
data/lib/trac/trac.rb CHANGED
@@ -1,34 +1,10 @@
1
1
  # code to communicate with your backend goes here...
2
2
 
3
- class TracAPI
4
- def initialize(trac, url, username, password)
5
- @@api = trac
6
- @@username = username
7
- @@url = url
8
- @@password = password
9
- end
10
-
11
- def self.api
12
- @@api
13
- end
14
-
15
- def self.url
16
- @@url
17
- end
18
-
19
- def self.username
20
- @@username
21
- end
22
-
23
- def self.password
24
- @@password
25
- end
26
- end
27
-
28
3
  class CommentUtil
29
4
 
30
5
  def initialize(ticket_id)
31
- @doc = Nokogiri::HTML(open("#{TracAPI.url}/ticket/#{ticket_id}", :http_basic_authentication=>[TracAPI.username, TracAPI.password]))
6
+ trac = TicketMaster::Provider::Trac.api
7
+ @doc = Nokogiri::HTML(open("#{trac[:url]}/ticket/#{ticket_id}", :http_basic_authentication=>[trac[:username], trac[:password]]))
32
8
  @ticket_id = ticket_id
33
9
  end
34
10
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ticketmaster-trac}
8
- s.version = "0.1.3"
8
+ s.version = "0.2.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Rafael George"]
12
- s.date = %q{2011-01-07}
12
+ s.date = %q{2011-01-12}
13
13
  s.description = %q{Allows ticketmaster to interact with Your System.}
14
14
  s.email = %q{george.rafael@gmail.com}
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ticketmaster-trac
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 1
9
- - 3
10
- version: 0.1.3
8
+ - 2
9
+ - 4
10
+ version: 0.2.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Rafael George
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-07 00:00:00 -04:00
18
+ date: 2011-01-12 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency