roust 1.6.1 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/roust/ticket.rb +50 -36
- data/lib/roust/version.rb +1 -1
- data/spec/mocks/ticket-search-1-or-2-long.txt +57 -0
- data/spec/roust/ticket_spec.rb +23 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b227d0780f4901c6964f0dbabc8249a14eb36ca
|
4
|
+
data.tar.gz: 74852906c70295672ef84e94f545236948bc71ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f5f32014af95ef2afed1b8bd21574532a8eadee97293ee135e80a67d152ccd58dc2731e30a35afd053996636ca7826157758e9c5b88951a0739a30d3e54b1d4
|
7
|
+
data.tar.gz: 2f126f6276a5fd87467ae0d7a804cf458f52089d4825b4df4dcad5b7a76185136cf9f2259482489a3d9b65957c192c353ab7ca5c0e1d0b0ab920c8b061fb4e62
|
data/Gemfile.lock
CHANGED
data/lib/roust/ticket.rb
CHANGED
@@ -7,39 +7,7 @@ class Roust
|
|
7
7
|
|
8
8
|
return nil if body =~ /^# (Ticket (\d+) does not exist\.)/
|
9
9
|
|
10
|
-
|
11
|
-
while body.match(/CF\.\{[\w_ ]*[ ]+[\w ]*\}/)
|
12
|
-
body.gsub!(/CF\.\{([\w_ ]*)([ ]+)([\w ]*)\}/, 'CF.{\1_\3}')
|
13
|
-
end
|
14
|
-
|
15
|
-
# Sometimes the API returns requestors formatted like this:
|
16
|
-
#
|
17
|
-
# Requestors: foo@example.org,
|
18
|
-
# bar@example.org, baz@example.org
|
19
|
-
# qux@example.org, quux@example.org,
|
20
|
-
# corge@example.org
|
21
|
-
#
|
22
|
-
# Turn it into this:
|
23
|
-
#
|
24
|
-
# Requestors: foo@example.org, bar@example.org, baz@example.org, ...
|
25
|
-
#
|
26
|
-
body.gsub!(/\n\n/, "\n")
|
27
|
-
|
28
|
-
%w(Requestors Cc AdminCc).each do |field|
|
29
|
-
body.gsub!(/^#{field}:(.+)^\n/m) do |m|
|
30
|
-
m.strip.split(/,\s+/).join(', ').strip
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
hash = body_to_hash(body)
|
35
|
-
|
36
|
-
%w(Requestors Cc AdminCc).each do |field|
|
37
|
-
hash[field] = hash[field].split(', ') if hash[field]
|
38
|
-
end
|
39
|
-
|
40
|
-
hash['id'] = hash['id'].split('/').last
|
41
|
-
|
42
|
-
hash
|
10
|
+
parse_ticket_attributes(body)
|
43
11
|
end
|
44
12
|
|
45
13
|
def ticket_create(attrs)
|
@@ -119,15 +87,25 @@ class Roust
|
|
119
87
|
:orderby => '+id'
|
120
88
|
}.merge(attrs)
|
121
89
|
|
90
|
+
params[:format] = 'l' if verbose = params.delete(:verbose)
|
91
|
+
|
122
92
|
# FIXME(auxesis): query should be an actual method argument
|
123
93
|
raise ArgumentError, ":query not specified" unless params[:query]
|
124
94
|
|
125
95
|
response = self.class.get('/search/ticket', :query => params)
|
126
96
|
|
127
97
|
body, _ = explode_response(response)
|
128
|
-
|
129
|
-
|
130
|
-
|
98
|
+
|
99
|
+
if verbose
|
100
|
+
results = body.split("\n--\n\n")
|
101
|
+
results.map do |result_body|
|
102
|
+
parse_ticket_attributes(result_body)
|
103
|
+
end
|
104
|
+
else
|
105
|
+
body.split("\n").map do |t|
|
106
|
+
id, subject = t.split(': ', 2)
|
107
|
+
{'id' => id, 'Subject' => subject}
|
108
|
+
end
|
131
109
|
end
|
132
110
|
end
|
133
111
|
|
@@ -195,6 +173,42 @@ class Roust
|
|
195
173
|
end
|
196
174
|
end
|
197
175
|
|
176
|
+
def parse_ticket_attributes(body)
|
177
|
+
# Replace CF spaces with underscores
|
178
|
+
while body.match(/CF\.\{[\w_ ]*[ ]+[\w ]*\}/)
|
179
|
+
body.gsub!(/CF\.\{([\w_ ]*)([ ]+)([\w ]*)\}/, 'CF.{\1_\3}')
|
180
|
+
end
|
181
|
+
|
182
|
+
# Sometimes the API returns requestors formatted like this:
|
183
|
+
#
|
184
|
+
# Requestors: foo@example.org,
|
185
|
+
# bar@example.org, baz@example.org
|
186
|
+
# qux@example.org, quux@example.org,
|
187
|
+
# corge@example.org
|
188
|
+
#
|
189
|
+
# Turn it into this:
|
190
|
+
#
|
191
|
+
# Requestors: foo@example.org, bar@example.org, baz@example.org, ...
|
192
|
+
#
|
193
|
+
body.gsub!(/\n\n/, "\n")
|
194
|
+
|
195
|
+
%w(Requestors Cc AdminCc).each do |field|
|
196
|
+
body.gsub!(/^#{field}:(.+)^\n/m) do |m|
|
197
|
+
m.strip.split(/,\s+/).join(', ').strip
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
hash = body_to_hash(body)
|
202
|
+
|
203
|
+
%w(Requestors Cc AdminCc).each do |field|
|
204
|
+
hash[field] = hash[field].split(', ') if hash[field]
|
205
|
+
end
|
206
|
+
|
207
|
+
hash['id'] = hash['id'].split('/').last
|
208
|
+
|
209
|
+
hash
|
210
|
+
end
|
211
|
+
|
198
212
|
def parse_short_history(body, opts = {})
|
199
213
|
comments = opts[:comments]
|
200
214
|
regex = comments ? '^\d+:' : '^\d+: [^Comments]'
|
data/lib/roust/version.rb
CHANGED
@@ -0,0 +1,57 @@
|
|
1
|
+
RT/3.4.6 200 Ok
|
2
|
+
|
3
|
+
id: ticket/1
|
4
|
+
Queue: support
|
5
|
+
Owner: bob
|
6
|
+
Creator: alice
|
7
|
+
Subject: Heavy packet loss
|
8
|
+
Status: open
|
9
|
+
Priority: 101
|
10
|
+
InitialPriority: 101
|
11
|
+
FinalPriority: 100
|
12
|
+
|
13
|
+
Requestors: carol@them.example, chuck@them.example,
|
14
|
+
craig@them.example
|
15
|
+
|
16
|
+
Cc: dan@us.example, dave@them.example
|
17
|
+
|
18
|
+
AdminCc: erin@us.example, eve@us.example,
|
19
|
+
frank@us.example, oscar@us.example,
|
20
|
+
peggy@us.example, trent@us.example
|
21
|
+
|
22
|
+
Created: Tue Dec 11 07:59:31 2012
|
23
|
+
Starts: Not set
|
24
|
+
Started: Not set
|
25
|
+
Due: Wed Dec 12 20:58:48 2012
|
26
|
+
Resolved: Wed Jan 16 16:33:15 2013
|
27
|
+
Told: Mon Jan 07 15:27:09 2013
|
28
|
+
LastUpdated: Wed Nov 06 09:33:43 2013
|
29
|
+
TimeEstimated: 0
|
30
|
+
TimeWorked: 12 hours
|
31
|
+
TimeLeft: 0
|
32
|
+
|
33
|
+
--
|
34
|
+
|
35
|
+
id: ticket/2
|
36
|
+
Queue: sales
|
37
|
+
Owner: bob
|
38
|
+
Creator: RT_System
|
39
|
+
Subject: Bloom
|
40
|
+
Status: resolved
|
41
|
+
Priority: 20
|
42
|
+
InitialPriority: 20
|
43
|
+
FinalPriority: 1
|
44
|
+
Requestors: carol@them.example, chuck@them.example,
|
45
|
+
Cc:
|
46
|
+
AdminCc:
|
47
|
+
Created: Tue May 29 16:19:22 2001
|
48
|
+
Starts: Not set
|
49
|
+
Started: Not set
|
50
|
+
Due: Not set
|
51
|
+
Resolved: Mon Mar 15 11:54:58 2004
|
52
|
+
Told: Not set
|
53
|
+
LastUpdated: Mon Oct 14 11:41:10 2013
|
54
|
+
TimeEstimated: 0
|
55
|
+
TimeWorked: 0
|
56
|
+
TimeLeft: 0
|
57
|
+
|
data/spec/roust/ticket_spec.rb
CHANGED
@@ -12,6 +12,11 @@ describe Roust do
|
|
12
12
|
:body => mocks_path.join('ticket-search-1-or-2.txt').read,
|
13
13
|
:headers => {})
|
14
14
|
|
15
|
+
stub_request(:get, "http://rt.example.org/REST/1.0/search/ticket?format=l&orderby=%2Bid&query=id%20=%201%20or%20id%20=%202")
|
16
|
+
.to_return(:status => 200,
|
17
|
+
:body => mocks_path.join('ticket-search-1-or-2-long.txt').read,
|
18
|
+
:headers => {})
|
19
|
+
|
15
20
|
stub_request(:get, 'http://rt.example.org/REST/1.0/ticket/1/history?format=s')
|
16
21
|
.to_return(:status => 200,
|
17
22
|
:body => mocks_path.join('ticket-1-history-short.txt').read,
|
@@ -40,6 +45,24 @@ describe Roust do
|
|
40
45
|
end
|
41
46
|
end
|
42
47
|
|
48
|
+
it 'can verbosely list tickets matching a query' do
|
49
|
+
results = @rt.search(:query => 'id = 1 or id = 2', :verbose => true)
|
50
|
+
expect(results.size).to eq(2)
|
51
|
+
|
52
|
+
attrs = %w(id Subject Queue) +
|
53
|
+
%w(Requestors Cc AdminCc Owner Creator) +
|
54
|
+
%w(Resolved Status) +
|
55
|
+
%w(Starts Started TimeLeft Due TimeWorked TimeEstimated) +
|
56
|
+
%w(LastUpdated Created Told) +
|
57
|
+
%w(Priority FinalPriority InitialPriority)
|
58
|
+
|
59
|
+
results.each do |result|
|
60
|
+
attrs.each do |attr|
|
61
|
+
expect(result[attr]).to_not eq(nil), "#{attr} key doesn't exist"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
43
66
|
it 'can fetch metadata on individual tickets' do
|
44
67
|
ticket = @rt.show('1')
|
45
68
|
expect(ticket).to_not eq(nil)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roust
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lindsay Holmwood
|
@@ -85,6 +85,7 @@ files:
|
|
85
85
|
- spec/mocks/ticket-1-show-unauthenticated.txt
|
86
86
|
- spec/mocks/ticket-1-show.txt
|
87
87
|
- spec/mocks/ticket-3-links.txt
|
88
|
+
- spec/mocks/ticket-search-1-or-2-long.txt
|
88
89
|
- spec/mocks/ticket-search-1-or-2.txt
|
89
90
|
- spec/mocks/user-dan@us.example-after-edit.txt
|
90
91
|
- spec/mocks/user-dan@us.example-edit.txt
|
@@ -129,6 +130,7 @@ test_files:
|
|
129
130
|
- spec/mocks/ticket-1-show-unauthenticated.txt
|
130
131
|
- spec/mocks/ticket-1-show.txt
|
131
132
|
- spec/mocks/ticket-3-links.txt
|
133
|
+
- spec/mocks/ticket-search-1-or-2-long.txt
|
132
134
|
- spec/mocks/ticket-search-1-or-2.txt
|
133
135
|
- spec/mocks/user-dan@us.example-after-edit.txt
|
134
136
|
- spec/mocks/user-dan@us.example-edit.txt
|