trans-api 0.0.4 → 0.0.5
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.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.travis.yml +12 -0
- data/.vagrant/bootstrap/settings.json +70 -0
- data/.vagrant/bootstrap/testing.sh +34 -0
- data/Gemfile.lock +34 -8
- data/README.md +121 -38
- data/Rakefile +14 -0
- data/Vagrantfile +18 -0
- data/lib/trans-api/client.rb +8 -2
- data/lib/trans-api/connect.rb +59 -133
- data/lib/trans-api/session.rb +8 -0
- data/lib/trans-api/torrent.rb +39 -9
- data/lib/trans-api/version.rb +1 -1
- data/lib/trans-api.rb +3 -1
- data/test/test_helper.rb +6 -0
- data/test/unit/trans_connect.rb +14 -150
- data/test/unit/trans_session_object.rb +15 -9
- data/test/unit/trans_torrent_object.rb +129 -26
- data/trans-api.gemspec +3 -1
- metadata +48 -13
data/test/unit/trans_connect.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
require '
|
2
|
-
require 'test/unit'
|
3
|
-
require File.expand_path(File.dirname(__FILE__) + "/../../lib/trans-api")
|
1
|
+
require 'test_helper'
|
4
2
|
|
5
3
|
# run with config options
|
6
4
|
#CONFIG="{\"host\":\"localhost\",\"port\":9091,\"user\":\"admin\",\"pass\":\"admin\",\"path\":\"/transmission/rpc\"}" ruby -I test test/unit/trans_connect.rb
|
@@ -21,14 +19,14 @@ class TransConnect < Test::Unit::TestCase
|
|
21
19
|
|
22
20
|
# add a testing torrent
|
23
21
|
file = File.expand_path(File.dirname(__FILE__) + "/torrents/debian-6.0.6-amd64-CD-1.iso.torrent")
|
24
|
-
@torrent =
|
22
|
+
@torrent = add_torrent_base64(file)
|
25
23
|
sleep 1
|
26
24
|
end
|
27
25
|
|
28
26
|
def teardown
|
29
27
|
Trans::Api::Client.config = @CONFIG
|
30
28
|
|
31
|
-
# remove the testing torrent
|
29
|
+
# # remove the testing torrent
|
32
30
|
id = @torrent.id
|
33
31
|
@torrent.delete! delete_local_data: true
|
34
32
|
self.signal_wait_until(lambda{|t| t.nil?}) do
|
@@ -235,37 +233,11 @@ class TransConnect < Test::Unit::TestCase
|
|
235
233
|
stopped_torrents = tc.torrent_get([:id, :name, :status], start_ids)
|
236
234
|
end
|
237
235
|
assert stopped_torrents.reject{|t| Trans::Api::Torrent::STATUS[t[:status]] == :stopped }.size == 0, "still some running torrents"
|
238
|
-
|
239
|
-
|
240
236
|
else
|
241
237
|
assert false, "no torrent files found!"
|
242
238
|
end
|
243
239
|
end
|
244
240
|
|
245
|
-
def test_torrent_add_remove_single
|
246
|
-
tc = Trans::Api::Connect.new @CONFIG
|
247
|
-
|
248
|
-
# add test file
|
249
|
-
file = File.expand_path(File.dirname(__FILE__) + "/torrents/debian-6.0.6-amd64-CD-2.iso.torrent")
|
250
|
-
torrent = tc.torrent_add filename: file, paused: true
|
251
|
-
|
252
|
-
# get submitted torrent
|
253
|
-
torrent_get = tc.torrent_get([:id, :name, :status], [torrent[:id]]).first
|
254
|
-
assert torrent_get[:id] == torrent[:id]
|
255
|
-
|
256
|
-
# remove torrent and cleanup
|
257
|
-
torrent_remove = tc.torrent_remove({delete_local_data: true}, [torrent[:id]])
|
258
|
-
|
259
|
-
|
260
|
-
torrent_get = nil
|
261
|
-
self.signal_wait_until(lambda{|t| t.nil?}) do
|
262
|
-
torrent_get = tc.torrent_get([:id, :name, :status], [torrent[:id]]).first
|
263
|
-
end
|
264
|
-
|
265
|
-
assert torrent_get.nil?
|
266
|
-
|
267
|
-
end
|
268
|
-
|
269
241
|
|
270
242
|
def test_torrent_files_unwatched
|
271
243
|
tc = Trans::Api::Connect.new @CONFIG
|
@@ -275,10 +247,8 @@ class TransConnect < Test::Unit::TestCase
|
|
275
247
|
end
|
276
248
|
|
277
249
|
#TODO: add test here!
|
278
|
-
|
279
250
|
end
|
280
251
|
|
281
|
-
|
282
252
|
def test_torrent_start_now
|
283
253
|
tc = Trans::Api::Connect.new @CONFIG
|
284
254
|
# get first torrent
|
@@ -291,18 +261,6 @@ class TransConnect < Test::Unit::TestCase
|
|
291
261
|
assert Trans::Api::Torrent::STATUS[torrent[:status]] != :stopped
|
292
262
|
end
|
293
263
|
|
294
|
-
def test_torrent_verify
|
295
|
-
tc = Trans::Api::Connect.new @CONFIG
|
296
|
-
torrents = tc.torrent_get([:id, :name, :status])
|
297
|
-
|
298
|
-
torrents.each do |torrent|
|
299
|
-
tc.torrent_verify([torrent[:id]])
|
300
|
-
t = tc.torrent_get([:recheckProgress], [torrent[:id]]).first
|
301
|
-
assert t[:recheckProgress] > 0
|
302
|
-
end
|
303
|
-
|
304
|
-
end
|
305
|
-
|
306
264
|
def test_torrent_reannounce
|
307
265
|
tc = Trans::Api::Connect.new @CONFIG
|
308
266
|
torrents = tc.torrent_get([:id, :name, :status])
|
@@ -323,128 +281,34 @@ class TransConnect < Test::Unit::TestCase
|
|
323
281
|
|
324
282
|
# load torrent
|
325
283
|
torrents = tc.torrent_get([:id, :name, :status, :downloadDir])
|
326
|
-
assert torrents.size >0
|
284
|
+
assert torrents.size >0, "should have a torrent"
|
327
285
|
torrents.each do |torrent|
|
328
286
|
tc.torrent_set_location({move: true, location: file} ,[torrent[:id]])
|
329
287
|
end
|
330
|
-
|
331
288
|
# reload torrent
|
332
289
|
torrents = tc.torrent_get([:id, :name, :status, :downloadDir])
|
333
|
-
assert torrents.size >0
|
290
|
+
assert torrents.size >0, "should have a torrent"
|
334
291
|
torrents.each do |torrent|
|
335
|
-
assert torrent[:downloadDir] == file
|
292
|
+
assert torrent[:downloadDir] == file, "files don't match"
|
336
293
|
end
|
337
294
|
|
338
295
|
end
|
339
296
|
|
340
297
|
|
341
298
|
|
299
|
+
protected
|
342
300
|
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
assert response[:blocklist_size].class == Fixnum
|
350
|
-
end
|
351
|
-
|
352
|
-
def test_port_test
|
353
|
-
tc = Trans::Api::Connect.new @CONFIG
|
354
|
-
response = tc.port_test
|
355
|
-
assert response.include? :port_is_open
|
356
|
-
assert response[:port_is_open].class == FalseClass || response[:port_is_open].class == TrueClass
|
357
|
-
end
|
358
|
-
|
359
|
-
|
360
|
-
# QUEUE
|
361
|
-
|
362
|
-
def test_queue_movement
|
363
|
-
tc = Trans::Api::Connect.new @CONFIG
|
364
|
-
|
365
|
-
torrents = []
|
366
|
-
|
367
|
-
# add a bunch of files
|
368
|
-
file = File.expand_path(File.dirname(__FILE__) + "/torrents/debian-6.0.6-amd64-CD-2.iso.torrent")
|
369
|
-
torrents << tc.torrent_add(filename: file, paused: true)
|
370
|
-
file = File.expand_path(File.dirname(__FILE__) + "/torrents/debian-6.0.6-amd64-CD-3.iso.torrent")
|
371
|
-
torrents << tc.torrent_add(filename: file, paused: true)
|
372
|
-
file = File.expand_path(File.dirname(__FILE__) + "/torrents/debian-6.0.6-amd64-CD-4.iso.torrent")
|
373
|
-
torrents << tc.torrent_add(filename: file, paused: true)
|
374
|
-
file = File.expand_path(File.dirname(__FILE__) + "/torrents/debian-6.0.6-amd64-CD-5.iso.torrent")
|
375
|
-
torrents << tc.torrent_add(filename: file, paused: true)
|
376
|
-
file = File.expand_path(File.dirname(__FILE__) + "/torrents/debian-6.0.6-amd64-CD-6.iso.torrent")
|
377
|
-
torrents << tc.torrent_add(filename: file, paused: true)
|
378
|
-
file = File.expand_path(File.dirname(__FILE__) + "/torrents/debian-6.0.6-amd64-CD-7.iso.torrent")
|
379
|
-
torrents << tc.torrent_add(filename: file, paused: true)
|
380
|
-
|
381
|
-
# move bottom
|
382
|
-
tc.queue_move_bottom [torrents.first[:id]]
|
383
|
-
|
384
|
-
|
385
|
-
# collect all torrents
|
386
|
-
all = tc.torrent_get([:id, :name, :status, :queuePosition])
|
387
|
-
|
388
|
-
# isolate first and last
|
389
|
-
torrent_first = all.first
|
390
|
-
torrent_last = all.last
|
391
|
-
|
392
|
-
# reverse queue order
|
393
|
-
tc.queue_move_bottom [torrent_first[:id]]
|
394
|
-
tc.queue_move_top [torrent_last[:id]]
|
395
|
-
|
396
|
-
# check if order is reversed
|
397
|
-
assert tc.torrent_get([:id, :name, :status, :queuePosition], [torrent_first[:id]]).first[:queuePosition] == all.size - 1
|
398
|
-
assert tc.torrent_get([:id, :name, :status, :queuePosition], [torrent_last[:id]]).first[:queuePosition] == 0
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
# get reference torrent (queueposition == 0)
|
403
|
-
ref = nil
|
404
|
-
all = tc.torrent_get([:id, :name, :status, :queuePosition])
|
405
|
-
all.each do |t|
|
406
|
-
if t[:queuePosition] == 0
|
407
|
-
ref = t
|
408
|
-
break
|
409
|
-
end
|
410
|
-
end
|
411
|
-
|
412
|
-
# move down the queue list
|
413
|
-
i = 0
|
414
|
-
while i < all.size
|
415
|
-
all = tc.torrent_get([:id, :name, :status, :queuePosition])
|
416
|
-
all.each do |t|
|
417
|
-
if t[:queuePosition] == i
|
418
|
-
assert ref[:name] == t[:name]
|
419
|
-
tc.queue_move_down [t[:id]]
|
420
|
-
end
|
421
|
-
end
|
422
|
-
i += 1
|
423
|
-
end
|
424
|
-
|
425
|
-
# move up the queue list (use the last reference)
|
426
|
-
while i >= 0
|
427
|
-
all = tc.torrent_get([:id, :name, :status, :queuePosition])
|
428
|
-
all.each do |t|
|
429
|
-
if t[:queuePosition] == i
|
430
|
-
assert ref[:name] == t[:name]
|
431
|
-
tc.queue_move_up [t[:id]]
|
432
|
-
end
|
433
|
-
end
|
434
|
-
i -= 1
|
435
|
-
end
|
436
|
-
|
437
|
-
|
438
|
-
# cleanup added torrents
|
439
|
-
torrents.each do |torrent|
|
440
|
-
tc.torrent_remove [torrent[:id]]
|
441
|
-
sleep 0.5 # don't crash the rpc daemon!
|
301
|
+
def add_torrent_base64(file)
|
302
|
+
filename = File.basename(file, ".*")
|
303
|
+
metainfo = ""
|
304
|
+
File.open(file, 'r') do |file|
|
305
|
+
tmp = file.read
|
306
|
+
metainfo += Base64.encode64 tmp
|
442
307
|
end
|
308
|
+
Trans::Api::Torrent.add_metainfo(metainfo, filename, paused: true)
|
443
309
|
end
|
444
310
|
|
445
311
|
|
446
|
-
|
447
|
-
|
448
312
|
# UTILS, probe block as long as pr callback returns false
|
449
313
|
|
450
314
|
def signal_wait_until(pr, &block)
|
@@ -1,8 +1,4 @@
|
|
1
|
-
|
2
|
-
require 'rubygems'
|
3
|
-
require 'test/unit'
|
4
|
-
require File.expand_path(File.dirname(__FILE__) + "/../../lib/trans-api")
|
5
|
-
|
1
|
+
require 'test_helper'
|
6
2
|
|
7
3
|
# run with config options
|
8
4
|
#CONFIG="{\"host\":\"localhost\",\"port\":9091,\"user\":\"admin\",\"pass\":\"admin\",\"path\":\"/transmission/rpc\"}" ruby -I test test/unit/trans_session_object.rb
|
@@ -15,8 +11,8 @@ require File.expand_path(File.dirname(__FILE__) + "/../../lib/trans-api")
|
|
15
11
|
|
16
12
|
class TransSessionObject < Test::Unit::TestCase
|
17
13
|
|
18
|
-
BLOCKLIST = "http://list.iblocklist.com/?list=bt_level3&fileformat=p2p&archiveformat=gz"
|
19
|
-
|
14
|
+
# BLOCKLIST = "http://list.iblocklist.com/?list=bt_level3&fileformat=p2p&archiveformat=gz"
|
15
|
+
BLOCKLIST = "http://list.iblocklist.com/?list=bt_level1&fileformat=p2p&archiveformat=gz"
|
20
16
|
|
21
17
|
def setup
|
22
18
|
@CONFIG = { host: "localhost", port: 9091, user: "admin", pass: "admin", path: "/transmission/rpc" }
|
@@ -93,8 +89,18 @@ class TransSessionObject < Test::Unit::TestCase
|
|
93
89
|
# insert a broken config
|
94
90
|
broken_config = { host: "localhost", port: 9091, user: "akdljflkasjdlfk", pass: "alskdfjlkajsdfl", path: "/transmission/rpc" }
|
95
91
|
Trans::Api::Client.config = broken_config
|
96
|
-
|
97
|
-
|
92
|
+
begin
|
93
|
+
session.reload!
|
94
|
+
assert false, "should have raised an exception"
|
95
|
+
rescue
|
96
|
+
assert true
|
97
|
+
end
|
98
|
+
begin
|
99
|
+
session.stats!.nil?
|
100
|
+
assert false, "stat should be broken!"
|
101
|
+
rescue
|
102
|
+
assert true
|
103
|
+
end
|
98
104
|
end
|
99
105
|
|
100
106
|
|
@@ -1,7 +1,4 @@
|
|
1
|
-
|
2
|
-
require 'rubygems'
|
3
|
-
require 'test/unit'
|
4
|
-
require File.expand_path(File.dirname(__FILE__) + "/../../lib/trans-api")
|
1
|
+
require 'test_helper'
|
5
2
|
|
6
3
|
# run with config options
|
7
4
|
#CONFIG="{\"host\":\"localhost\",\"port\":9091,\"user\":\"admin\",\"pass\":\"admin\",\"path\":\"/transmission/rpc\"}" ruby -I test test/unit/trans_torrent_object.rb
|
@@ -22,9 +19,9 @@ class TransTorrentObject < Test::Unit::TestCase
|
|
22
19
|
Trans::Api::Client.config = @CONFIG
|
23
20
|
Trans::Api::Torrent.default_fields = [ :id, :status, :name ]
|
24
21
|
|
25
|
-
# add a testing torrent
|
22
|
+
# # add a testing torrent
|
26
23
|
file = File.expand_path(File.dirname(__FILE__) + "/torrents/debian-6.0.6-amd64-CD-1.iso.torrent")
|
27
|
-
@torrent =
|
24
|
+
@torrent = add_torrent_base64 file
|
28
25
|
sleep 1
|
29
26
|
end
|
30
27
|
|
@@ -184,7 +181,7 @@ class TransTorrentObject < Test::Unit::TestCase
|
|
184
181
|
def test_torrent_add_remove_single
|
185
182
|
# add file
|
186
183
|
file = File.expand_path(File.dirname(__FILE__) + "/torrents/debian-6.0.6-amd64-CD-2.iso.torrent")
|
187
|
-
torrent =
|
184
|
+
torrent = add_torrent_base64 file
|
188
185
|
assert torrent.id
|
189
186
|
|
190
187
|
# remove the testing torrent
|
@@ -195,18 +192,114 @@ class TransTorrentObject < Test::Unit::TestCase
|
|
195
192
|
end
|
196
193
|
end
|
197
194
|
|
195
|
+
def test_torrent_add_links
|
196
|
+
torrents_size = Trans::Api::Torrent.all.size
|
197
|
+
# add torrent
|
198
|
+
file = File.expand_path(File.dirname(__FILE__) + "/torrents/debian-6.0.6-amd64-CD-2.iso.torrent")
|
199
|
+
torrent = add_torrent_base64 file
|
200
|
+
# get magnet link
|
201
|
+
magnet_link = torrent.magnetLink.dup
|
202
|
+
torrent.waitfor(lambda{|t| t.last_error[:error] == "reset_exception"}).delete!(delete_local_data: true)
|
203
|
+
# check if it is removed
|
204
|
+
torrents = Trans::Api::Torrent.all
|
205
|
+
assert torrents.size == torrents_size, "torrent not removed"
|
206
|
+
# add via magnet
|
207
|
+
torrent = Trans::Api::Torrent.add_magnet(magnet_link, paused: true)
|
208
|
+
torrents = Trans::Api::Torrent.all
|
209
|
+
assert torrents.size == (torrents_size + 1), "torrent not added"
|
210
|
+
torrent.waitfor(lambda{|t| t.last_error[:error] == "reset_exception"}).delete!(delete_local_data: true)
|
211
|
+
end
|
212
|
+
|
198
213
|
|
199
214
|
def test_torrent_add_remove_multiple
|
200
215
|
file = File.expand_path(File.dirname(__FILE__) + "/torrents/debian-6.0.6-amd64-CD-2.iso.torrent")
|
201
|
-
torrent =
|
202
|
-
|
216
|
+
torrent = add_torrent_base64 file
|
203
217
|
torrents = Trans::Api::Torrent.all
|
204
218
|
|
205
219
|
assert torrents.size > 0, "no loaded torrents found"
|
206
220
|
torrent = Trans::Api::Torrent.delete_all torrents, delete_local_data: true
|
207
221
|
|
208
222
|
#TODO: add assert here!!
|
223
|
+
end
|
209
224
|
|
225
|
+
# def test_torrent_rapid_delete
|
226
|
+
# # add a sample torrent
|
227
|
+
# 20.times.each do |t|
|
228
|
+
# ts = []
|
229
|
+
# file = File.expand_path(File.dirname(__FILE__) + "/torrents/debian-6.0.6-amd64-CD-2.iso.torrent")
|
230
|
+
# ts << add_torrent_base64(file)
|
231
|
+
# file = File.expand_path(File.dirname(__FILE__) + "/torrents/debian-6.0.6-amd64-CD-3.iso.torrent")
|
232
|
+
# ts << add_torrent_base64(file)
|
233
|
+
# file = File.expand_path(File.dirname(__FILE__) + "/torrents/debian-6.0.6-amd64-CD-4.iso.torrent")
|
234
|
+
# ts << add_torrent_base64(file)
|
235
|
+
# file = File.expand_path(File.dirname(__FILE__) + "/torrents/debian-6.0.6-amd64-CD-5.iso.torrent")
|
236
|
+
# ts << add_torrent_base64(file)
|
237
|
+
# file = File.expand_path(File.dirname(__FILE__) + "/torrents/debian-6.0.6-amd64-CD-6.iso.torrent")
|
238
|
+
# ts << add_torrent_base64(file)
|
239
|
+
# file = File.expand_path(File.dirname(__FILE__) + "/torrents/debian-6.0.6-amd64-CD-7.iso.torrent")
|
240
|
+
# ts << add_torrent_base64(file)
|
241
|
+
# # verify push
|
242
|
+
# torrents = Trans::Api::Torrent.all
|
243
|
+
# assert torrents.size == 7, "not 7 torrents found"
|
244
|
+
# # detect
|
245
|
+
# ts.each do |torrent|
|
246
|
+
# torrent.delete! delete_local_data: true
|
247
|
+
# end
|
248
|
+
|
249
|
+
# # wait for removal
|
250
|
+
# i = 0
|
251
|
+
# while true do
|
252
|
+
# torrents = Trans::Api::Torrent.all
|
253
|
+
# break if torrents.size == 1
|
254
|
+
# sleep 0.1
|
255
|
+
# i += 1
|
256
|
+
# assert false, "remove not received by client (iteration: #{i}/50)" if i > 20
|
257
|
+
# end
|
258
|
+
|
259
|
+
# # validate removal
|
260
|
+
# assert torrents.size == 1, "not 1 torrents found"
|
261
|
+
# end
|
262
|
+
# end
|
263
|
+
|
264
|
+
def test_torrent_rapid_safe_delete
|
265
|
+
# add a sample torrent
|
266
|
+
10.times.each do |t|
|
267
|
+
ts = []
|
268
|
+
file = File.expand_path(File.dirname(__FILE__) + "/torrents/debian-6.0.6-amd64-CD-2.iso.torrent")
|
269
|
+
ts << add_torrent_base64(file)
|
270
|
+
file = File.expand_path(File.dirname(__FILE__) + "/torrents/debian-6.0.6-amd64-CD-3.iso.torrent")
|
271
|
+
ts << add_torrent_base64(file)
|
272
|
+
file = File.expand_path(File.dirname(__FILE__) + "/torrents/debian-6.0.6-amd64-CD-4.iso.torrent")
|
273
|
+
ts << add_torrent_base64(file)
|
274
|
+
file = File.expand_path(File.dirname(__FILE__) + "/torrents/debian-6.0.6-amd64-CD-5.iso.torrent")
|
275
|
+
ts << add_torrent_base64(file)
|
276
|
+
file = File.expand_path(File.dirname(__FILE__) + "/torrents/debian-6.0.6-amd64-CD-6.iso.torrent")
|
277
|
+
ts << add_torrent_base64(file)
|
278
|
+
file = File.expand_path(File.dirname(__FILE__) + "/torrents/debian-6.0.6-amd64-CD-7.iso.torrent")
|
279
|
+
ts << add_torrent_base64(file)
|
280
|
+
# verify push
|
281
|
+
torrents = Trans::Api::Torrent.all
|
282
|
+
assert torrents.size == 7, "not 7 torrents found"
|
283
|
+
# detect
|
284
|
+
ts.each do |torrent|
|
285
|
+
# use waitfor to check the last_error `reset_exception`
|
286
|
+
# the torrent object cannot be reloaded (probably because it's missing)
|
287
|
+
torrent.waitfor(lambda{|t| t.last_error[:error] == "reset_exception"}).delete!(delete_local_data: true)
|
288
|
+
end
|
289
|
+
|
290
|
+
# wait for removal
|
291
|
+
i = 0
|
292
|
+
while true do
|
293
|
+
torrents = Trans::Api::Torrent.all
|
294
|
+
break if torrents.size == 1
|
295
|
+
sleep 0.1
|
296
|
+
i += 1
|
297
|
+
assert false, "remove not received by client (iteration: #{i}/50)" if i > 20
|
298
|
+
end
|
299
|
+
|
300
|
+
# validate removal
|
301
|
+
assert torrents.size == 1, "not 1 torrents found"
|
302
|
+
end
|
210
303
|
end
|
211
304
|
|
212
305
|
|
@@ -258,7 +351,7 @@ class TransTorrentObject < Test::Unit::TestCase
|
|
258
351
|
file = File.expand_path(File.dirname(__FILE__) + "/torrents/debian-6.0.6-amd64-CD-2.iso.torrent")
|
259
352
|
# hammer duplicate torrent
|
260
353
|
torrent = nil
|
261
|
-
10.times { |t| torrent =
|
354
|
+
10.times { |t| torrent = add_torrent_base64(file) }
|
262
355
|
assert Trans::Api::Torrent.all.size == 2
|
263
356
|
torrent.delete!
|
264
357
|
end
|
@@ -270,17 +363,17 @@ class TransTorrentObject < Test::Unit::TestCase
|
|
270
363
|
# add test torrents
|
271
364
|
torrents = []
|
272
365
|
file = File.expand_path(File.dirname(__FILE__) + "/torrents/debian-6.0.6-amd64-CD-2.iso.torrent")
|
273
|
-
torrents <<
|
366
|
+
torrents << add_torrent_base64(file)
|
274
367
|
file = File.expand_path(File.dirname(__FILE__) + "/torrents/debian-6.0.6-amd64-CD-3.iso.torrent")
|
275
|
-
torrents <<
|
368
|
+
torrents << add_torrent_base64(file)
|
276
369
|
file = File.expand_path(File.dirname(__FILE__) + "/torrents/debian-6.0.6-amd64-CD-4.iso.torrent")
|
277
|
-
torrents <<
|
370
|
+
torrents << add_torrent_base64(file)
|
278
371
|
file = File.expand_path(File.dirname(__FILE__) + "/torrents/debian-6.0.6-amd64-CD-5.iso.torrent")
|
279
|
-
torrents <<
|
372
|
+
torrents << add_torrent_base64(file)
|
280
373
|
file = File.expand_path(File.dirname(__FILE__) + "/torrents/debian-6.0.6-amd64-CD-6.iso.torrent")
|
281
|
-
torrents <<
|
374
|
+
torrents << add_torrent_base64(file)
|
282
375
|
file = File.expand_path(File.dirname(__FILE__) + "/torrents/debian-6.0.6-amd64-CD-7.iso.torrent")
|
283
|
-
torrents <<
|
376
|
+
torrents << add_torrent_base64(file)
|
284
377
|
|
285
378
|
# collect first and last
|
286
379
|
all = Trans::Api::Torrent.all
|
@@ -351,17 +444,16 @@ class TransTorrentObject < Test::Unit::TestCase
|
|
351
444
|
|
352
445
|
|
353
446
|
def test_torrent_add_by_base
|
447
|
+
# puts @CONFIG.inspect
|
354
448
|
file = File.expand_path(File.dirname(__FILE__) + "/torrents/debian-6.0.6-amd64-CD-5.iso.torrent")
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
assert torrent.name == "debian-6.0.6-amd64-CD-5.iso"
|
364
|
-
torrent.delete!
|
449
|
+
torrent1 = add_torrent_base64(file)
|
450
|
+
assert torrent1.name == "debian-6.0.6-amd64-CD-5.iso"
|
451
|
+
# test add duplicate (returns torrent1 reloaded)
|
452
|
+
file = File.expand_path(File.dirname(__FILE__) + "/torrents/debian-6.0.6-amd64-CD-5.iso.torrent")
|
453
|
+
torrent2 = add_torrent_base64(file)
|
454
|
+
assert torrent1.id == torrent2.id
|
455
|
+
assert torrent1.name == torrent2.name
|
456
|
+
torrent1.delete!
|
365
457
|
end
|
366
458
|
|
367
459
|
def test_find_torrent_by_value_name
|
@@ -375,6 +467,17 @@ class TransTorrentObject < Test::Unit::TestCase
|
|
375
467
|
protected
|
376
468
|
|
377
469
|
|
470
|
+
def add_torrent_base64(file)
|
471
|
+
filename = File.basename(file, ".*")
|
472
|
+
metainfo = ""
|
473
|
+
File.open(file, 'r') do |file|
|
474
|
+
tmp = file.read
|
475
|
+
metainfo += Base64.encode64 tmp
|
476
|
+
end
|
477
|
+
Trans::Api::Torrent.add_metainfo(metainfo, filename, paused: true)
|
478
|
+
end
|
479
|
+
|
480
|
+
|
378
481
|
# UTILS, probe block as long as pr callback returns false
|
379
482
|
|
380
483
|
def signal_wait_until(pr, &block)
|
data/trans-api.gemspec
CHANGED
@@ -15,7 +15,9 @@ Gem::Specification.new do |gem|
|
|
15
15
|
# dependencies
|
16
16
|
gem.add_dependency 'nokogiri', "> 1.5.0"
|
17
17
|
gem.add_dependency 'json', "> 1.6.1"
|
18
|
-
gem.add_development_dependency "
|
18
|
+
gem.add_development_dependency "rake", "> 10.0.0"
|
19
|
+
gem.add_development_dependency "test-unit", "> 3.0.0"
|
20
|
+
gem.add_development_dependency "coveralls", "> 0.7.0"
|
19
21
|
|
20
22
|
gem.files = `git ls-files`.split($/)
|
21
23
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
metadata
CHANGED
@@ -1,57 +1,85 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trans-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dennis Blommesteijn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>'
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 1.5.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '>'
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 1.5.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: json
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>'
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 1.6.1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>'
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 1.6.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>'
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 10.0.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>'
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 10.0.0
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: test-unit
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
|
-
- -
|
59
|
+
- - '>'
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 3.0.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>'
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 3.0.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: coveralls
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>'
|
46
74
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
75
|
+
version: 0.7.0
|
48
76
|
type: :development
|
49
77
|
prerelease: false
|
50
78
|
version_requirements: !ruby/object:Gem::Requirement
|
51
79
|
requirements:
|
52
|
-
- -
|
80
|
+
- - '>'
|
53
81
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
82
|
+
version: 0.7.0
|
55
83
|
description: Transmission (bittorrent client) RPC API for Ruby on Rails (gem)
|
56
84
|
email:
|
57
85
|
- dennis@blommesteijn.com
|
@@ -59,12 +87,16 @@ executables: []
|
|
59
87
|
extensions: []
|
60
88
|
extra_rdoc_files: []
|
61
89
|
files:
|
62
|
-
-
|
90
|
+
- .gitignore
|
91
|
+
- .travis.yml
|
92
|
+
- .vagrant/bootstrap/settings.json
|
93
|
+
- .vagrant/bootstrap/testing.sh
|
63
94
|
- Gemfile
|
64
95
|
- Gemfile.lock
|
65
96
|
- LICENSE.txt
|
66
97
|
- README.md
|
67
98
|
- Rakefile
|
99
|
+
- Vagrantfile
|
68
100
|
- lib/trans-api.rb
|
69
101
|
- lib/trans-api/client.rb
|
70
102
|
- lib/trans-api/connect.rb
|
@@ -72,6 +104,7 @@ files:
|
|
72
104
|
- lib/trans-api/session.rb
|
73
105
|
- lib/trans-api/torrent.rb
|
74
106
|
- lib/trans-api/version.rb
|
107
|
+
- test/test_helper.rb
|
75
108
|
- test/unit/torrents/debian-6.0.6-amd64-CD-1.iso.torrent
|
76
109
|
- test/unit/torrents/debian-6.0.6-amd64-CD-2.iso.torrent
|
77
110
|
- test/unit/torrents/debian-6.0.6-amd64-CD-3.iso.torrent
|
@@ -92,12 +125,12 @@ require_paths:
|
|
92
125
|
- lib
|
93
126
|
required_ruby_version: !ruby/object:Gem::Requirement
|
94
127
|
requirements:
|
95
|
-
- -
|
128
|
+
- - '>='
|
96
129
|
- !ruby/object:Gem::Version
|
97
130
|
version: '0'
|
98
131
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
132
|
requirements:
|
100
|
-
- -
|
133
|
+
- - '>='
|
101
134
|
- !ruby/object:Gem::Version
|
102
135
|
version: '0'
|
103
136
|
requirements: []
|
@@ -107,6 +140,7 @@ signing_key:
|
|
107
140
|
specification_version: 4
|
108
141
|
summary: Transmission (bittorrent client) RPC API for Ruby on Rails (gem)
|
109
142
|
test_files:
|
143
|
+
- test/test_helper.rb
|
110
144
|
- test/unit/torrents/debian-6.0.6-amd64-CD-1.iso.torrent
|
111
145
|
- test/unit/torrents/debian-6.0.6-amd64-CD-2.iso.torrent
|
112
146
|
- test/unit/torrents/debian-6.0.6-amd64-CD-3.iso.torrent
|
@@ -117,3 +151,4 @@ test_files:
|
|
117
151
|
- test/unit/trans_connect.rb
|
118
152
|
- test/unit/trans_session_object.rb
|
119
153
|
- test/unit/trans_torrent_object.rb
|
154
|
+
has_rdoc:
|