ticketmaster-trac 0.2.9 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.9
1
+ 0.3.0
@@ -46,6 +46,35 @@ module TicketMaster::Provider
46
46
  self[:id]
47
47
  end
48
48
 
49
+ def self.find_by_attributes(project_id, ticket_id, attributes = {})
50
+ comments = self.find_all(ticket_id)
51
+ search_by_attribute(comments, attributes)
52
+ end
53
+
54
+ def self.find(project_id, ticket_id, *options)
55
+ if options[0].first.is_a? Array
56
+ self.find_all(ticket_id).select do |comment|
57
+ comment if options[0].first.any? { |id| id == comment.id }
58
+ end
59
+ elsif options[0].first.is_a? Hash
60
+ self.find_by_attributes(project_id, ticket_id, options[0].first)
61
+ else
62
+ self.find_all(ticket_id)
63
+ end
64
+ end
65
+
66
+ def self.find_by_id(project_id, ticket_id, id)
67
+ self.find_all(ticket_id).select { |comment| comment[:id] == id }.first
68
+ end
69
+
70
+ def self.find_all(ticket_id)
71
+ comments = CommentUtil.new(ticket_id,TicketMaster::Provider::Trac.api).comments
72
+ unless comments.empty?
73
+ comments = comments.collect { |comment| TicketMaster::Provider::Trac::Comment.new comment }
74
+ end
75
+ comments
76
+ end
77
+
49
78
  end
50
79
  end
51
80
  end
@@ -75,39 +75,16 @@ module TicketMaster::Provider
75
75
  end
76
76
 
77
77
  def comments(*options)
78
- comments = CommentUtil.new(self.id,TicketMaster::Provider::Trac.api).comments.collect { |comment| TicketMaster::Provider::Trac::Comment.new comment }
79
- if options.first.is_a? Array
80
- comments.select do |comment|
81
- comment if options.first.any? { |id| id == comment.id }
82
- end
83
- elsif options.first.is_a? Hash
84
- hash = options.first
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
95
- end
96
- else
97
- comments
98
- end
78
+ Comment.find(self.project_id, self.id, options)
99
79
  end
100
80
 
101
81
  def comment(*options)
102
- comments = CommentUtil.new(self.id,TicketMaster::Provider::Trac.api).comments.collect { |comment| TicketMaster::Provider::Trac::Comment.new comment }
103
82
  if options.empty?
104
83
  TicketMaster::Provider::Trac::Comment.new
105
84
  elsif options.first.is_a? Fixnum
106
- comments.select { |comment| comment[:id] == options.first }.first
85
+ Comment.find_by_id(self.project_id, self.id, options.first)
107
86
  elsif options.first.is_a? Hash
108
- comments.select do |key, value|
109
- options.first[key] == value
110
- end.first
87
+ Comment.find_by_attributes(self.project_id, self.id, options.first).first
111
88
  end
112
89
  end
113
90
 
@@ -123,7 +100,7 @@ module TicketMaster::Provider
123
100
 
124
101
  # Extracted this code from facet http://api.mackframework.com/mack-facets/classes/Kernel.html
125
102
  def self.retryable(options = {}, &block)
126
- opts = { :tries => 1, :on => Exception }.merge(options)
103
+ opts = { :tries => 5, :on => Exception }.merge(options)
127
104
 
128
105
  retry_exception, retries = opts[:on], opts[:tries]
129
106
 
data/lib/trac/trac.rb CHANGED
@@ -14,7 +14,7 @@ class CommentUtil
14
14
  authors = @doc.css('h3.change')
15
15
  comment_id += 1
16
16
  unless body[comment_id-1].nil? || authors[comment_id-1].nil?
17
- Hashie::Mash.new build_comment_hash(value, comment_id, body[comment_id-1].text, authors[comment_id-1].content)
17
+ build_comment_hash(value, comment_id, body[comment_id-1].text, authors[comment_id-1].content)
18
18
  end
19
19
  end
20
20
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ticketmaster-trac}
8
- s.version = "0.2.9"
8
+ s.version = "0.3.0"
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-04-12}
12
+ s.date = %q{2011-04-14}
13
13
  s.description = %q{Allows ticketmaster to interact with Your System.}
14
14
  s.email = %q{rafael@hybridgroup.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: 5
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 2
9
- - 9
10
- version: 0.2.9
8
+ - 3
9
+ - 0
10
+ version: 0.3.0
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-04-12 00:00:00 -04:00
18
+ date: 2011-04-14 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency