rt-client 0.3.9 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/rt/client.rb +15 -5
- data/rt/rtxmlsrv.rb +13 -0
- metadata +5 -5
data/rt/client.rb
CHANGED
@@ -26,7 +26,7 @@ require 'pp'
|
|
26
26
|
|
27
27
|
class RT_Client
|
28
28
|
|
29
|
-
UA = "Mozilla/5.0 ruby RT Client Interface 0.
|
29
|
+
UA = "Mozilla/5.0 ruby RT Client Interface 0.4.0"
|
30
30
|
attr_reader :status, :site, :version, :cookies, :server, :user, :cookie
|
31
31
|
|
32
32
|
# Create a new RT_Client object. Load up our stored cookie and check it.
|
@@ -59,7 +59,7 @@ class RT_Client
|
|
59
59
|
# cookies=<directory>
|
60
60
|
def initialize(*params)
|
61
61
|
@boundary = "----xYzZY#{rand(1000000).to_s}xYzZY"
|
62
|
-
@version = "0.
|
62
|
+
@version = "0.4.0"
|
63
63
|
@status = "Not connected"
|
64
64
|
@server = "http://localhost/"
|
65
65
|
@user = "rt_user"
|
@@ -320,15 +320,25 @@ class RT_Client
|
|
320
320
|
@site["ticket/#{id}/comment"].post payload
|
321
321
|
end
|
322
322
|
|
323
|
+
# Find RT user details from an email address
|
324
|
+
#
|
325
|
+
# rt.usersearch(:EmailAddress => 'some@email.com')
|
326
|
+
# => {"name"=>"rtlogin", "realname"=>"John Smith", "address1"=>"123 Main", etc }
|
323
327
|
def usersearch(field_hash)
|
324
328
|
if field_hash.has_key? :EmailAddress
|
325
329
|
email = field_hash[:EmailAddress]
|
326
330
|
else
|
327
331
|
raise "RT_Client.usersearch requires a user email in the 'EmailAddress' key."
|
328
332
|
end
|
329
|
-
|
330
|
-
resp
|
331
|
-
|
333
|
+
resp = @site["user/#{email}"].get
|
334
|
+
resp.gsub!(/RT\/\d+\.\d+\.\d+\s\d{3}\s.*\n\n/,"") # toss the HTTP response
|
335
|
+
reply = {}
|
336
|
+
return reply if resp =~ /No user named/
|
337
|
+
th = TMail::Mail.parse(resp)
|
338
|
+
th.each_header do |k,v|
|
339
|
+
reply["#{k}"] = v.to_s
|
340
|
+
end
|
341
|
+
reply
|
332
342
|
end
|
333
343
|
|
334
344
|
# correspond on a ticket. Requires a hash, which must have an :id key
|
data/rt/rtxmlsrv.rb
CHANGED
@@ -131,6 +131,19 @@ class TicketSrv
|
|
131
131
|
val
|
132
132
|
end
|
133
133
|
|
134
|
+
# Find RT user details from email address via RT_Cleint::usersearch
|
135
|
+
def usersearch(struct)
|
136
|
+
struct.remapkeys!
|
137
|
+
if struct.has_key? :user and struct.has_key? :pass
|
138
|
+
rt = RT_Client.new(:user => struct[:user], :pass => struct[:pass])
|
139
|
+
else
|
140
|
+
rt = RT_Client.new
|
141
|
+
end
|
142
|
+
val = rt.usersearch(struct)
|
143
|
+
rt = nil
|
144
|
+
val
|
145
|
+
end
|
146
|
+
|
134
147
|
# Allows new users to be edited or created if they don't exist
|
135
148
|
def edit_or_create_user(struct)
|
136
149
|
struct.remapkeys!
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rt-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 4
|
9
|
+
- 0
|
10
|
+
version: 0.4.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Tom Lahti
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-08-
|
18
|
+
date: 2011-08-23 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|