roust 1.0.1 → 1.1.0

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/roust.gemspec CHANGED
@@ -21,9 +21,7 @@ Gem::Specification.new do |s|
21
21
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
22
22
  s.require_paths = ["lib"]
23
23
 
24
- s.add_runtime_dependency 'rest-client', ">= 0.9"
25
- s.add_runtime_dependency 'mail', ">= 2.5.4"
26
- s.add_runtime_dependency 'mime-types', ">= 1.16"
27
- s.add_runtime_dependency 'archive-tar-minitar', ">= 0.5"
28
- s.add_runtime_dependency 'nokogiri', ">= 1.2"
24
+ s.add_runtime_dependency 'mail', '>= 2.5.4'
25
+ s.add_runtime_dependency 'httparty', '>= 0.13.1'
26
+ s.add_runtime_dependency 'activesupport', '>= 4.1.0'
29
27
  end
data/spec/ticket_spec.rb CHANGED
@@ -10,20 +10,19 @@ describe "Roust" do
10
10
  }
11
11
  mocks_path = Pathname.new(__FILE__).parent.join('mocks')
12
12
 
13
- stub_request(:post, "http://rt.example.org/REST/1.0/").
13
+ stub_request(:post, "http://rt.example.org/index.html").
14
14
  with(:body => {
15
15
  "user"=>"admin",
16
16
  "pass"=>"password",
17
17
  }).
18
18
  to_return(:status => 200, :body => "", :headers => {})
19
19
 
20
-
21
20
  stub_request(:get, "http://rt.example.org/REST/1.0/ticket/1/show").
22
21
  to_return(:status => 200,
23
22
  :body => mocks_path.join('ticket-1-show.txt').read,
24
23
  :headers => {})
25
24
 
26
- stub_request(:get, "http://rt.example.org/REST/1.0/search/ticket/?format=s&orderby=&query=id%20=%201%20or%20id%20=%202").
25
+ stub_request(:get, "http://rt.example.org/REST/1.0/search/ticket?format=s&orderby=%2Bid&query%5Bquery%5D=id%20=%201%20or%20id%20=%202").
27
26
  to_return(:status => 200,
28
27
  :body => mocks_path.join('ticket-search-1-or-2.txt').read,
29
28
  :headers => {})
@@ -53,7 +52,7 @@ describe "Roust" do
53
52
  rt = Roust.new(@credentials)
54
53
  rt.authenticated?.should be_true
55
54
 
56
- results = rt.list(:query => "id = 1 or id = 2")
55
+ results = rt.search(:query => "id = 1 or id = 2")
57
56
  results.size.should == 2
58
57
  results.each do |result|
59
58
  result.size.should == 2
@@ -67,18 +66,18 @@ describe "Roust" do
67
66
  ticket = rt.show("1")
68
67
  ticket.should_not be_nil
69
68
 
70
- attrs = %w(id subject queue) +
71
- %w(requestors cc admincc owner creator) +
72
- %w(resolved status) +
73
- %w(starts started timeleft due timeworked timeestimated) +
74
- %w(lastupdated created told) +
75
- %w(priority finalpriority initialpriority)
69
+ attrs = %w(id Subject Queue) +
70
+ %w(Requestors Cc AdminCc Owner Creator) +
71
+ %w(Resolved Status) +
72
+ %w(Starts Started TimeLeft Due TimeWorked TimeEstimated) +
73
+ %w(LastUpdated Created Told) +
74
+ %w(Priority FinalPriority InitialPriority)
76
75
 
77
76
  attrs.each do |attr|
78
77
  ticket[attr].should_not be_nil, "#{attr} key doesn't exist"
79
78
  end
80
79
 
81
- %w(requestors cc admincc).each do |field|
80
+ %w(Requestors Cc AdminCc).each do |field|
82
81
  ticket[field].size.should > 1
83
82
  end
84
83
  end
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.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lindsay Holmwood
@@ -10,20 +10,6 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2014-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: rest-client
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - '>='
18
- - !ruby/object:Gem::Version
19
- version: '0.9'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - '>='
25
- - !ruby/object:Gem::Version
26
- version: '0.9'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: mail
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -39,47 +25,33 @@ dependencies:
39
25
  - !ruby/object:Gem::Version
40
26
  version: 2.5.4
41
27
  - !ruby/object:Gem::Dependency
42
- name: mime-types
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - '>='
46
- - !ruby/object:Gem::Version
47
- version: '1.16'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - '>='
53
- - !ruby/object:Gem::Version
54
- version: '1.16'
55
- - !ruby/object:Gem::Dependency
56
- name: archive-tar-minitar
28
+ name: httparty
57
29
  requirement: !ruby/object:Gem::Requirement
58
30
  requirements:
59
31
  - - '>='
60
32
  - !ruby/object:Gem::Version
61
- version: '0.5'
33
+ version: 0.13.1
62
34
  type: :runtime
63
35
  prerelease: false
64
36
  version_requirements: !ruby/object:Gem::Requirement
65
37
  requirements:
66
38
  - - '>='
67
39
  - !ruby/object:Gem::Version
68
- version: '0.5'
40
+ version: 0.13.1
69
41
  - !ruby/object:Gem::Dependency
70
- name: nokogiri
42
+ name: activesupport
71
43
  requirement: !ruby/object:Gem::Requirement
72
44
  requirements:
73
45
  - - '>='
74
46
  - !ruby/object:Gem::Version
75
- version: '1.2'
47
+ version: 4.1.0
76
48
  type: :runtime
77
49
  prerelease: false
78
50
  version_requirements: !ruby/object:Gem::Requirement
79
51
  requirements:
80
52
  - - '>='
81
53
  - !ruby/object:Gem::Version
82
- version: '1.2'
54
+ version: 4.1.0
83
55
  description: Roust is a Ruby API client that accesses the REST interface version 1.0
84
56
  of a Request Tracker instance. See http://www.bestpractical.com/ for Request Tracker.
85
57
  email:
@@ -97,7 +69,6 @@ files:
97
69
  - Rakefile
98
70
  - examples/example.rb
99
71
  - lib/roust.rb
100
- - lib/roust/rtxmlsrv.rb
101
72
  - lib/roust/version.rb
102
73
  - roust.gemspec
103
74
  - spec/mocks/ticket-1-history-long.txt
@@ -1,271 +0,0 @@
1
- #!/opt/ruby-enterprise-1.8.7-2010.02/bin/ruby
2
-
3
- ## XML RPC service to provide a cross-platform API for
4
- ## RT ticket creation/maintenance. Essentially just a wrapper
5
- ## around the rt/client library.
6
-
7
- require "rubygems" # so we can load gems
8
- require "rt/client" # rt-client REST library
9
- require "xmlrpc/server" # that's what we're doing
10
- require "date" # for parsing arbitrary date formats
11
- require "pp"
12
-
13
- PORT=8080
14
- MAX_CONN=50
15
-
16
- # extend the Hash class to
17
- # translate string keys into symbol keys
18
- class Hash # :nodoc:
19
- def remapkeys!
20
- n = Hash.new
21
- self.each_key do |key|
22
- n[key.to_sym] = self[key]
23
- end
24
- self.replace(n)
25
- n = nil
26
- $stderr.puts self.map { |k,v| "#{k} => #{v}" }
27
- self
28
- end
29
- end
30
-
31
- class TicketSrv
32
-
33
- def initialize
34
- end
35
-
36
- INTERFACE = XMLRPC::interface("rt") {
37
- meth 'string add_watcher(struct)','Calls RT_Client::add_watcher'
38
- meth 'array attachments(struct)','Calls RT_Client::attachments'
39
- meth 'string comment(struct)','Calls RT_Client::comment'
40
- meth 'string correspond(struct)','Calls RT_Client::correspond'
41
- meth 'string create(struct)','Calls RT_Client::create'
42
- meth 'string create_user(struct)','Calls RT_Client::create_user'
43
- meth 'string edit(struct)','Calls RT_Client::edit'
44
- meth 'string edit_or_create_user(struct)','Calls RT_Client::edit_or_create_user'
45
- meth 'struct get_attachment(struct)','Calls RT_Client::get_attachment'
46
- meth 'struct history(struct)','Calls RT_Client::history (long form)'
47
- meth 'struct history_item(struct)','Calls RT_Client::history_item'
48
- meth 'array list(struct)','Calls RT_Client::list'
49
- meth 'array query(struct)','Calls RT_Client::query (long form)'
50
- meth 'struct show(struct)','Calls RT_Client::show'
51
- }
52
-
53
- # Allows watchers to be added via RT_Client::add_watcher
54
- # You need to pass :id, :addr, and optionally :type
55
- def add_watcher(struct)
56
- struct.remapkeys!
57
- if struct.has_key? :user and struct.has_key? :pass
58
- rt = RT_Client.new(:user => struct[:user], :pass => struct[:pass])
59
- else
60
- rt = RT_Client.new
61
- end
62
- val = rt.add_watcher(struct)
63
- rt = nil
64
- val
65
- end
66
-
67
- # Gets a list of attachments via RT_Client::attachments
68
- # You need to pass :id, and optionally :unnamed
69
- def attachments(struct)
70
- struct.remapkeys!
71
- if struct.has_key? :user and struct.has_key? :pass
72
- rt = RT_Client.new(:user => struct[:user], :pass => struct[:pass])
73
- else
74
- rt = RT_Client.new
75
- end
76
- rt = RT_Client.new
77
- val = rt.attachments(struct)
78
- rt = nil
79
- val
80
- end
81
-
82
- # Adds comments to tickets via RT_Client::comment
83
- def comment(struct)
84
- struct.remapkeys!
85
- if struct.has_key? :user and struct.has_key? :pass
86
- rt = RT_Client.new(:user => struct[:user], :pass => struct[:pass])
87
- else
88
- rt = RT_Client.new
89
- end
90
- val = rt.comment(struct)
91
- rt = nil
92
- val
93
- end
94
-
95
- # Allows new tickets to be created via RT_Client::correspond
96
- def correspond(struct)
97
- struct.remapkeys!
98
- if struct.has_key? :user and struct.has_key? :pass
99
- rt = RT_Client.new(:user => struct[:user], :pass => struct[:pass])
100
- else
101
- rt = RT_Client.new
102
- end
103
- val = rt.correspond(struct)
104
- rt = nil
105
- val
106
- end
107
-
108
- # Allows new tickets to be created via RT_Client::create
109
- def create(struct)
110
- struct.remapkeys!
111
- if struct.has_key? :user and struct.has_key? :pass
112
- rt = RT_Client.new(:user => struct[:user], :pass => struct[:pass])
113
- else
114
- rt = RT_Client.new
115
- end
116
- val = rt.create(struct)
117
- rt = nil
118
- val
119
- end
120
-
121
- # Allows new users to be created via RT_Client::create_user
122
- def create_user(struct)
123
- struct.remapkeys!
124
- if struct.has_key? :user and struct.has_key? :pass
125
- rt = RT_Client.new(:user => struct[:user], :pass => struct[:pass])
126
- else
127
- rt = RT_Client.new
128
- end
129
- val = rt.create_user(struct)
130
- rt = nil
131
- val
132
- end
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
-
147
- # Allows new users to be edited or created if they don't exist
148
- def edit_or_create_user(struct)
149
- struct.remapkeys!
150
- if struct.has_key? :user and struct.has_key? :pass
151
- rt = RT_Client.new(:user => struct[:user], :pass => struct[:pass])
152
- else
153
- rt = RT_Client.new
154
- end
155
- val = rt.edit_or_create_user(struct)
156
- rt = nil
157
- val
158
- end
159
-
160
- # Allows existing ticket to be modified via RT_Client::edit
161
- def edit(struct)
162
- struct.remapkeys!
163
- if struct.has_key? :user and struct.has_key? :pass
164
- rt = RT_Client.new(:user => struct[:user], :pass => struct[:pass])
165
- else
166
- rt = RT_Client.new
167
- end
168
- val = rt.edit(struct)
169
- rt = nil
170
- val
171
- end
172
-
173
- # Retrieves attachments via RT_Client::get_attachment
174
- def get_attachment(struct)
175
- struct.remapkeys!
176
- if struct.has_key? :user and struct.has_key? :pass
177
- rt = RT_Client.new(:user => struct[:user], :pass => struct[:pass])
178
- else
179
- rt = RT_Client.new
180
- end
181
- val = rt.get_attachment(struct)
182
- rt = nil
183
- val
184
- end
185
-
186
- # Gets the history of a ticket via RT_Client::history
187
- def history(struct)
188
- struct.remapkeys!
189
- if struct.has_key? :user and struct.has_key? :pass
190
- rt = RT_Client.new(:user => struct[:user], :pass => struct[:pass])
191
- else
192
- rt = RT_Client.new
193
- end
194
- val = rt.history(struct)
195
- rt = nil
196
- val
197
- end
198
-
199
- # Gets a single history item via RT_Client::history_item
200
- def history_item(struct)
201
- struct.remapkeys!
202
- if struct.has_key? :user and struct.has_key? :pass
203
- rt = RT_Client.new(:user => struct[:user], :pass => struct[:pass])
204
- else
205
- rt = RT_Client.new
206
- end
207
- val = rt.history_item(struct)
208
- rt = nil
209
- val
210
- end
211
-
212
- # Gets a list of tickets via RT_Client::list
213
- def list(struct)
214
- struct.remapkeys!
215
- if struct.has_key? :user and struct.has_key? :pass
216
- rt = RT_Client.new(:user => struct[:user], :pass => struct[:pass])
217
- else
218
- rt = RT_Client.new
219
- end
220
- val = rt.list(struct)
221
- rt = nil
222
- val
223
- end
224
-
225
- # Gets a list of tickets via RT_Client::query
226
- def query(struct)
227
- struct.remapkeys!
228
- if struct.has_key? :user and struct.has_key? :pass
229
- rt = RT_Client.new(:user => struct[:user], :pass => struct[:pass])
230
- else
231
- rt = RT_Client.new
232
- end
233
- val = rt.query(struct)
234
- rt = nil
235
- val
236
- end
237
-
238
- # Gets detail (minus history/attachments) via RT_Client::show
239
- def show(struct)
240
- struct.remapkeys!
241
- if struct.has_key? :user and struct.has_key? :pass
242
- rt = RT_Client.new(:user => struct[:user], :pass => struct[:pass])
243
- else
244
- rt = RT_Client.new
245
- end
246
- val = rt.show(struct)
247
- rt = nil
248
- val
249
- end
250
-
251
- end # class TicketSrv
252
-
253
- pid = fork do
254
- Signal.trap('HUP','IGNORE')
255
- # set up a log file
256
- logfile = File.dirname(__FILE__) + "/ticketsrv.log"
257
- accfile = File.dirname(__FILE__) + "/access.log"
258
- acc = File.open(accfile,"a+")
259
- $stderr.reopen acc # redirect $stderr to the log as well
260
- # determine the IP address to listen on and create the server
261
- sock = Socket.getaddrinfo(Socket.gethostname,PORT,Socket::AF_INET,Socket::SOCK_STREAM)
262
- $s = XMLRPC::Server.new(sock[0][1], sock[0][3], MAX_CONN, logfile)
263
- $s.set_parser(XMLRPC::XMLParser::XMLStreamParser.new)
264
- $s.add_handler(TicketSrv::INTERFACE, TicketSrv.new)
265
- $s.add_introspection
266
- $s.serve # start serving
267
- $stderr.reopen STDERR
268
- acc.close
269
- end
270
- Process.detach(pid)
271
-