trans-api 0.0.1 → 0.0.2
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 +10 -10
- data/Gemfile.lock +3 -0
- data/lib/trans-api/client.rb +1 -0
- data/lib/trans-api/torrent.rb +12 -2
- data/lib/trans-api/version.rb +1 -1
- data/test/unit/trans_torrent_object.rb +19 -1
- data/trans-api.gemspec +2 -2
- metadata +29 -30
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
2
|
+
SHA1:
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YTE4YzBlYmRjN2Q1ZDQwZWYwNWM0MjA4ZDE2YmE0ZjNmNmYzMGI5MQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
7
|
-
|
6
|
+
NDZhNjBkNTZjYmYyMjM4NDU5NzJmMDBmZWQzMzMwMjYwNTNmYjExYg==
|
7
|
+
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YWJkNjJiZTdlNzE4NjgxZDc2YjE0MWQzZGI1NzY5N2EzZjY3MDhiYWNjZjlh
|
10
|
+
YTdjYTEwMTg5NGU2NjZkZDJjNTE4NjdkN2EzZmRiMTAzODljZTM3ZjZlNDlm
|
11
|
+
YjY3ZTRlMTgzNjlhOWNkOThmMTViMzdhZGU2ZTY3ZmQ5YjMyZDc=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NDY5MjgyOGZmODQ1N2ZiYWNhMmMyMjUwMzg3MTMxYWU3OTRjNTJlMzYzMTUy
|
14
|
+
ZWZiYjI0NmZjYjZjMDljNDgzNDVkZmZlYWQ1N2FlZmEzMmY3NzNkMWNmNGJm
|
15
|
+
YjNiYTFiMjQ0N2UyNzhkYTVhNDNlM2VjNWYzODM1Nzc0YTU3Zjk=
|
data/Gemfile.lock
CHANGED
data/lib/trans-api/client.rb
CHANGED
data/lib/trans-api/torrent.rb
CHANGED
@@ -27,6 +27,9 @@ module Trans
|
|
27
27
|
:ids, :location, :peer_limit, :priority_high, :priority_low, :priority_normal, :queuePosition, :seedIdleLimit,
|
28
28
|
:seedIdleMode, :seedRatioLimit, :seedRatioMode, :trackerAdd, :trackerRemove, :trackerReplace, :uploadLimit, :uploadLimited ]
|
29
29
|
|
30
|
+
CONTROL = [:start!, :start_now!, :stop!, :verify!, :reannounce!, :set_location!, :delete!, :queue_top!, :queue_bottom!,
|
31
|
+
:queue_up!, :queue_down!]
|
32
|
+
|
30
33
|
# torrent add fields
|
31
34
|
ADD = [ :cookies, :download_dir, :filename, :metainfo, :paused, :peer_limit, :bandwidthPriority, :files_wanted,
|
32
35
|
:files_unwanted, :priority_high, :priority_low, :priority_normal ]
|
@@ -80,11 +83,10 @@ module Trans
|
|
80
83
|
# files wrapped by an File object
|
81
84
|
def files_objects
|
82
85
|
ret = []
|
83
|
-
# i = -1
|
84
86
|
torrent = @client.connect.torrent_get([:files, :fileStats], [self.id]).first
|
85
87
|
@fields[:files] = torrent[:files]
|
86
88
|
@fields[:fileStatus] = torrent[:fileStats]
|
87
|
-
|
89
|
+
@fields[:files].each_with_index{ |f,i| ret << Trans::Api::File.new( torrent: self, fields: @fields,
|
88
90
|
file: f.merge(id: i).merge(fileStat: torrent[:fileStats][i])) }
|
89
91
|
ret
|
90
92
|
end
|
@@ -204,6 +206,14 @@ module Trans
|
|
204
206
|
Torrent.new torrent: torrent
|
205
207
|
end
|
206
208
|
|
209
|
+
def add_metainfo(metainfo, options={})
|
210
|
+
options[:metainfo] = metainfo
|
211
|
+
client = Client.new
|
212
|
+
torrent = client.connect.torrent_add options
|
213
|
+
torrent = client.connect.torrent_get( @@default_fields, [torrent[:id]]).first
|
214
|
+
Torrent.new torrent: torrent
|
215
|
+
end
|
216
|
+
|
207
217
|
def default_fields=(list=[])
|
208
218
|
@@default_fields << :id unless list.include? :id
|
209
219
|
@@default_fields |= list
|
data/lib/trans-api/version.rb
CHANGED
@@ -13,7 +13,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../lib/trans-api")
|
|
13
13
|
|
14
14
|
class TransTorrentObject < Test::Unit::TestCase
|
15
15
|
|
16
|
-
CONFIG = { host: "localhost", port:
|
16
|
+
CONFIG = { host: "localhost", port: 8078, user: "pinguin", pass: "100110", path: "/transmission/rpc" }
|
17
17
|
|
18
18
|
def setup
|
19
19
|
Trans::Api::Client.config = CONFIG
|
@@ -337,6 +337,24 @@ class TransTorrentObject < Test::Unit::TestCase
|
|
337
337
|
|
338
338
|
end
|
339
339
|
|
340
|
+
|
341
|
+
def test_torrent_add_by_base
|
342
|
+
file = File.expand_path(File.dirname(__FILE__) + "/torrents/debian-6.0.6-amd64-CD-5.iso.torrent")
|
343
|
+
|
344
|
+
metainfo = ""
|
345
|
+
File.open(file, 'r') do |file|
|
346
|
+
tmp = file.read
|
347
|
+
metainfo += Base64.encode64 tmp
|
348
|
+
end
|
349
|
+
|
350
|
+
torrent = Trans::Api::Torrent.add_metainfo(metainfo, paused: true)
|
351
|
+
assert torrent.name == "debian-6.0.6-amd64-CD-5.iso"
|
352
|
+
torrent.delete!
|
353
|
+
|
354
|
+
end
|
355
|
+
|
356
|
+
|
357
|
+
|
340
358
|
protected
|
341
359
|
|
342
360
|
|
data/trans-api.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |gem|
|
|
8
8
|
gem.version = Trans::Api::VERSION
|
9
9
|
gem.authors = ["Dennis Blommesteijn"]
|
10
10
|
gem.email = ["dennis@blommesteijn.com"]
|
11
|
-
gem.description = %q{
|
12
|
-
gem.summary = %q{
|
11
|
+
gem.description = %q{Transmission RPC API for Ruby on Rails (gem).}
|
12
|
+
gem.summary = %q{Transmission RPC API for Ruby on Rails (gem)}
|
13
13
|
gem.homepage = ""
|
14
14
|
|
15
15
|
# dependencies
|
metadata
CHANGED
@@ -1,65 +1,65 @@
|
|
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dennis Blommesteijn
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
15
|
+
version_requirements: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
15
20
|
requirement: !ruby/object:Gem::Requirement
|
16
21
|
requirements:
|
17
|
-
- -
|
22
|
+
- - ">="
|
18
23
|
- !ruby/object:Gem::Version
|
19
24
|
version: '0'
|
20
|
-
type: :runtime
|
21
25
|
prerelease: false
|
26
|
+
type: :runtime
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json
|
22
29
|
version_requirements: !ruby/object:Gem::Requirement
|
23
30
|
requirements:
|
24
|
-
- -
|
31
|
+
- - ">="
|
25
32
|
- !ruby/object:Gem::Version
|
26
33
|
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: json
|
29
34
|
requirement: !ruby/object:Gem::Requirement
|
30
35
|
requirements:
|
31
|
-
- -
|
36
|
+
- - ">="
|
32
37
|
- !ruby/object:Gem::Version
|
33
38
|
version: '0'
|
34
|
-
type: :runtime
|
35
39
|
prerelease: false
|
40
|
+
type: :runtime
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: test-unit
|
36
43
|
version_requirements: !ruby/object:Gem::Requirement
|
37
44
|
requirements:
|
38
|
-
- -
|
45
|
+
- - ">="
|
39
46
|
- !ruby/object:Gem::Version
|
40
47
|
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: test-unit
|
43
48
|
requirement: !ruby/object:Gem::Requirement
|
44
49
|
requirements:
|
45
|
-
- -
|
50
|
+
- - ">="
|
46
51
|
- !ruby/object:Gem::Version
|
47
52
|
version: '0'
|
48
|
-
type: :development
|
49
53
|
prerelease: false
|
50
|
-
|
51
|
-
|
52
|
-
- - ! '>='
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
description: transmission torrent client rpc interface library
|
54
|
+
type: :development
|
55
|
+
description: Transmission RPC API for Ruby on Rails (gem).
|
56
56
|
email:
|
57
57
|
- dennis@blommesteijn.com
|
58
58
|
executables: []
|
59
59
|
extensions: []
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
|
-
- .gitignore
|
62
|
+
- ".gitignore"
|
63
63
|
- Gemfile
|
64
64
|
- Gemfile.lock
|
65
65
|
- LICENSE.txt
|
@@ -89,26 +89,26 @@ files:
|
|
89
89
|
homepage: ''
|
90
90
|
licenses: []
|
91
91
|
metadata: {}
|
92
|
-
post_install_message:
|
92
|
+
post_install_message:
|
93
93
|
rdoc_options: []
|
94
94
|
require_paths:
|
95
95
|
- lib
|
96
96
|
required_ruby_version: !ruby/object:Gem::Requirement
|
97
97
|
requirements:
|
98
|
-
- -
|
98
|
+
- - ">="
|
99
99
|
- !ruby/object:Gem::Version
|
100
100
|
version: '0'
|
101
101
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
102
|
requirements:
|
103
|
-
- -
|
103
|
+
- - ">="
|
104
104
|
- !ruby/object:Gem::Version
|
105
105
|
version: '0'
|
106
106
|
requirements: []
|
107
|
-
rubyforge_project:
|
108
|
-
rubygems_version: 2.0.
|
109
|
-
signing_key:
|
107
|
+
rubyforge_project:
|
108
|
+
rubygems_version: 2.0.3
|
109
|
+
signing_key:
|
110
110
|
specification_version: 4
|
111
|
-
summary:
|
111
|
+
summary: Transmission RPC API for Ruby on Rails (gem)
|
112
112
|
test_files:
|
113
113
|
- test/test_helper.rb
|
114
114
|
- test/unit/torrents/debian-6.0.6-amd64-CD-1.iso.torrent
|
@@ -121,4 +121,3 @@ test_files:
|
|
121
121
|
- test/unit/trans_connect.rb
|
122
122
|
- test/unit/trans_session_object.rb
|
123
123
|
- test/unit/trans_torrent_object.rb
|
124
|
-
has_rdoc:
|