rtransmission 0.2 → 0.3
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/lib/rtransmission.rb +3 -3
- data/lib/rtransmission/client.rb +11 -0
- data/lib/rtransmission/session.rb +50 -68
- data/lib/rtransmission/torrent.rb +121 -91
- data/lib/rtransmission/type.rb +55 -0
- data/lib/rtransmission/types.rb +22 -0
- data/lib/rtransmission/{fields → types}/day.rb +2 -2
- data/lib/rtransmission/{fields → types}/encryption.rb +2 -2
- data/lib/rtransmission/{fields → types}/error.rb +2 -2
- data/lib/rtransmission/{fields → types}/eta.rb +2 -2
- data/lib/rtransmission/{fields/percent.rb → types/file.rb} +7 -7
- data/lib/rtransmission/types/file_stat.rb +17 -0
- data/lib/rtransmission/types/peer.rb +30 -0
- data/lib/rtransmission/types/peers_from.rb +20 -0
- data/lib/rtransmission/{fields → types}/priority.rb +2 -2
- data/lib/rtransmission/{fields → types}/seed_idle_mode.rb +2 -2
- data/lib/rtransmission/{fields → types}/seed_ratio_mode.rb +2 -2
- data/lib/rtransmission/types/stats.rb +21 -0
- data/lib/rtransmission/{fields → types}/status.rb +2 -2
- data/lib/rtransmission/{fields → types}/time.rb +2 -2
- data/lib/rtransmission/types/tracker.rb +18 -0
- data/lib/rtransmission/types/tracker_stat.rb +41 -0
- data/lib/rtransmission/types/tracker_state.rb +15 -0
- data/lib/rtransmission/types/traffic_stats.rb +19 -0
- data/lib/rtransmission/version.rb +1 -1
- metadata +22 -23
- data/lib/rtransmission/field.rb +0 -24
- data/lib/rtransmission/fields.rb +0 -23
- data/lib/rtransmission/fields/file.rb +0 -17
- data/lib/rtransmission/fields/file_stat.rb +0 -17
- data/lib/rtransmission/fields/peer.rb +0 -30
- data/lib/rtransmission/fields/peers_from.rb +0 -20
- data/lib/rtransmission/fields/pieces.rb +0 -13
- data/lib/rtransmission/fields/stats.rb +0 -21
- data/lib/rtransmission/fields/tracker.rb +0 -18
- data/lib/rtransmission/fields/tracker_stat.rb +0 -41
- data/lib/rtransmission/fields/traffic_stats.rb +0 -19
data/lib/rtransmission.rb
CHANGED
@@ -6,8 +6,8 @@ require 'rtransmission/version'
|
|
6
6
|
require 'rtransmission/exception'
|
7
7
|
require 'rtransmission/request'
|
8
8
|
require 'rtransmission/response'
|
9
|
-
require 'rtransmission/
|
10
|
-
require 'rtransmission/
|
9
|
+
require 'rtransmission/client'
|
10
|
+
require 'rtransmission/type'
|
11
|
+
require 'rtransmission/types'
|
11
12
|
require 'rtransmission/session'
|
12
13
|
require 'rtransmission/torrent'
|
13
|
-
require 'rtransmission/client'
|
data/lib/rtransmission/client.rb
CHANGED
@@ -23,6 +23,17 @@ module RTransmission
|
|
23
23
|
session
|
24
24
|
end
|
25
25
|
|
26
|
+
def self.rpc_name_to_ruby_name(rpc_name)
|
27
|
+
name = nil
|
28
|
+
if rpc_name.index('-')
|
29
|
+
name = rpc_name.gsub('-', '_')
|
30
|
+
else
|
31
|
+
name = rpc_name.gsub(/[A-Z]/) { |x| '_' + x.downcase }
|
32
|
+
end
|
33
|
+
|
34
|
+
name
|
35
|
+
end
|
36
|
+
|
26
37
|
def initialize(args = {})
|
27
38
|
@host = args[:host] || 'localhost'
|
28
39
|
@port = args[:port] || 9091
|
@@ -6,21 +6,13 @@ module RTransmission
|
|
6
6
|
class Session
|
7
7
|
attr_reader :client
|
8
8
|
|
9
|
-
def self.
|
9
|
+
def self.attribute(rpc_name, args = {})
|
10
|
+
name = args[:name] || RTransmission::Client.rpc_name_to_ruby_name(rpc_name)
|
11
|
+
|
10
12
|
self.send :define_method, name.to_s do
|
11
13
|
request = RTransmission::Request.new('session-get', {}, 'Session.' + name.to_s) do |arguments|
|
12
|
-
|
13
|
-
|
14
|
-
type = args[:type]
|
15
|
-
if type.class == Array
|
16
|
-
type = type[0]
|
17
|
-
result.map! { |r| type.unmap(r) }
|
18
|
-
else
|
19
|
-
result = type.unmap(result)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
result
|
14
|
+
value = arguments[rpc_name]
|
15
|
+
RTransmission::Type.unmap(value, args[:type])
|
24
16
|
end
|
25
17
|
|
26
18
|
@client.call(request)
|
@@ -28,17 +20,7 @@ module RTransmission
|
|
28
20
|
|
29
21
|
if args[:writeable] == true
|
30
22
|
self.send :define_method, name.to_s.gsub('?', '') + '=' do |value|
|
31
|
-
rpc_value = value
|
32
|
-
if args[:type]
|
33
|
-
type = args[:type]
|
34
|
-
if type.class == Array
|
35
|
-
type = type[0]
|
36
|
-
rpc_value.map! { |r| type.map(r) }
|
37
|
-
else
|
38
|
-
rpc_value = type.map(rpc_value)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
23
|
+
rpc_value = RTransmission::Type.unmap(value, args[:type])
|
42
24
|
request = RTransmission::Request.new('session-set', {rpc_name => rpc_value}, 'Session.' + name.to_s + '=') do
|
43
25
|
value
|
44
26
|
end
|
@@ -48,49 +30,49 @@ module RTransmission
|
|
48
30
|
end
|
49
31
|
end
|
50
32
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
33
|
+
attribute 'alt-speed-down', :writeable => true
|
34
|
+
attribute 'alt-speed-enabled', :name => :alt_speed_enabled?, :writeable => true
|
35
|
+
attribute 'alt-speed-time-begin', :writeable => true
|
36
|
+
attribute 'alt-speed-time-enabled', :name => :alt_speed_time_enabled?, :writeable => true
|
37
|
+
attribute 'alt-speed-time-end', :writeable => true
|
38
|
+
attribute 'alt-speed-time-day', :type => :day, :writeable => true
|
39
|
+
attribute 'alt-speed-up', :writeable => true
|
40
|
+
attribute 'blocklist-url', :writeable => true
|
41
|
+
attribute 'blocklist-enabled', :name => :blocklist_enabled?, :writeable => true
|
42
|
+
attribute 'blocklist-size'
|
43
|
+
attribute 'cache-size-mb', :writeable => true
|
44
|
+
attribute 'config-dir'
|
45
|
+
attribute 'download-dir', :writeable => true
|
46
|
+
attribute 'download-dir-free-space'
|
47
|
+
attribute 'dht-enabled', :name => :dht_enabled?, :writeable => true
|
48
|
+
attribute 'encryption', :type => :encryption, :writeable => true
|
49
|
+
attribute 'idle-seeding-limit', :writeable => true
|
50
|
+
attribute 'idle-seeding-limit-enabled', :name => :idle_seeding_limit_enabled?, :writeable => true
|
51
|
+
attribute 'incomplete-dir', :writeable => true
|
52
|
+
attribute 'incomplete-dir-enabled', :name => :incomplete_dir_enabled?, :writeable => true
|
53
|
+
attribute 'lpd-enabled', :name => :lpd_enabled?, :writeable => true
|
54
|
+
attribute 'peer-limit-global', :writeable => true
|
55
|
+
attribute 'peer-limit-per-torrent', :writeable => true
|
56
|
+
attribute 'pex-enabled', :name => :pex_enabled?, :writeable => true
|
57
|
+
attribute 'peer-port', :writeable => true
|
58
|
+
attribute 'peer-port-random-on-start', :name => :peer_port_random_on_start?, :writeable => true
|
59
|
+
attribute 'port-forwarding-enabled', :name => :port_forwarding_enabled?, :writeable => true
|
60
|
+
attribute 'rename-partial-files', :name => :rename_partial_files?, :writeable => true
|
61
|
+
attribute 'rpc-version'
|
62
|
+
attribute 'rpc-version-minimum'
|
63
|
+
attribute 'script-torrent-done-filename', :writeable => true
|
64
|
+
attribute 'script-torrent-done-enabled', :name => :script_torrent_done_enabled?, :writeable => true
|
65
|
+
attribute 'seedRatioLimit', :writeable => true
|
66
|
+
attribute 'seedRatioLimited', :name => :seed_ratio_limited?, :writeable => true
|
67
|
+
attribute 'speed-limit-down', :writeable => true
|
68
|
+
attribute 'speed-limit-down-enabled', :name => :speed_limit_down_enabled?, :writeable => true
|
69
|
+
attribute 'speed-limit-up', :writeable => true
|
70
|
+
attribute 'speed-limit-up-enabled', :name => :speed_limit_up_enabled?, :writeable => true
|
71
|
+
attribute 'start-added-torrents', :name => :start_added_torrents?, :writeable => true
|
72
|
+
attribute 'trash-original-torrent-files', :name => :trash_original_torrent_files?, :writeable => true
|
73
|
+
attribute 'units' # FIXME: add type and writeable
|
74
|
+
attribute 'utp-enabled', :name => :utp_enabled?, :writeable => true
|
75
|
+
attribute 'version'
|
94
76
|
|
95
77
|
def initialize(client)
|
96
78
|
@client = client
|
@@ -98,7 +80,7 @@ module RTransmission
|
|
98
80
|
|
99
81
|
def stats
|
100
82
|
request = RTransmission::Request.new('session-stats', {}, 'Session.stats') do |arguments|
|
101
|
-
RTransmission::
|
83
|
+
RTransmission::Types::Stats.unmap(arguments)
|
102
84
|
end
|
103
85
|
|
104
86
|
@client.call(request)
|
@@ -4,9 +4,8 @@
|
|
4
4
|
|
5
5
|
require 'base64'
|
6
6
|
|
7
|
-
# FIXME: files-wanted/unwanted & prioriry-high/low/normal for
|
7
|
+
# FIXME: files-wanted/unwanted & prioriry-high/low/normal for new torrents
|
8
8
|
# FIXME: add/remove/replace trackers
|
9
|
-
# FIXME: location set support
|
10
9
|
module RTransmission
|
11
10
|
class Torrent
|
12
11
|
attr_reader :id
|
@@ -17,7 +16,7 @@ module RTransmission
|
|
17
16
|
raise RTransmission::Exception.new('Torrent#add: only one of remote_file, url, or torrent must be specified') if (args.keys & [:remote_file, :url, :torrent]).count != 1
|
18
17
|
pargs['filename'] = args[:remote_file] if args[:remote_file]
|
19
18
|
pargs['filename'] = args[:url] if args[:url]
|
20
|
-
pargs['metainfo'] = Base64::
|
19
|
+
pargs['metainfo'] = Base64::encode64(args[:torrent]) if args[:torrent]
|
21
20
|
|
22
21
|
pargs['cookies'] = args[:cookies] if args[:cookies]
|
23
22
|
pargs['download-dir'] = args[:download_dir] if args[:download_dir]
|
@@ -45,21 +44,13 @@ module RTransmission
|
|
45
44
|
session.client.call(request)
|
46
45
|
end
|
47
46
|
|
48
|
-
def self.
|
47
|
+
def self.attribute(rpc_name, args = {})
|
48
|
+
name = args[:name] || RTransmission::Client.rpc_name_to_ruby_name(rpc_name)
|
49
|
+
|
49
50
|
self.send :define_method, name.to_s do
|
50
51
|
request = RTransmission::Request.new('torrent-get', {'ids' => @id, 'fields' => [rpc_name]}, 'Torrent.' + name.to_s) do |arguments|
|
51
|
-
|
52
|
-
|
53
|
-
type = args[:type]
|
54
|
-
if type.class == Array
|
55
|
-
type = type[0]
|
56
|
-
result.map! { |r| type.unmap(r) }
|
57
|
-
else
|
58
|
-
result = type.unmap(result)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
result
|
52
|
+
value = arguments['torrents'][0][rpc_name]
|
53
|
+
RTransmission::Type.unmap(value, args[:type])
|
63
54
|
end
|
64
55
|
|
65
56
|
@session.client.call(request)
|
@@ -67,17 +58,7 @@ module RTransmission
|
|
67
58
|
|
68
59
|
if args[:writeable] == true
|
69
60
|
self.send :define_method, name.to_s.gsub('?', '') + '=' do |value|
|
70
|
-
rpc_value = value
|
71
|
-
if args[:type]
|
72
|
-
type = args[:type]
|
73
|
-
if type.class == Array
|
74
|
-
type = type[0]
|
75
|
-
rpc_value.map! { |r| type.map(r) }
|
76
|
-
else
|
77
|
-
rpc_value = type.map(rpc_value)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
61
|
+
rpc_value = RTransmission::Type.map(value, args[:type])
|
81
62
|
request = RTransmission::Request.new('torrent-set', {'ids' => @id, rpc_name => rpc_value}, 'Torrent.' + name.to_s + '=') do
|
82
63
|
value
|
83
64
|
end
|
@@ -87,70 +68,69 @@ module RTransmission
|
|
87
68
|
end
|
88
69
|
end
|
89
70
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
define_field :webseeds_sending_to_us, 'webseedsSendingToUs'
|
71
|
+
attribute 'activityDate', :type => :time
|
72
|
+
attribute 'addedDate', :type => :time
|
73
|
+
attribute 'bandwidthPriority', :type => :priority, :writeable => true
|
74
|
+
attribute 'comment'
|
75
|
+
attribute 'corruptEver'
|
76
|
+
attribute 'creator'
|
77
|
+
attribute 'dateCreated', :type => :time
|
78
|
+
attribute 'desiredAvailable'
|
79
|
+
attribute 'doneDate', :type => :time
|
80
|
+
attribute 'downloadDir'
|
81
|
+
attribute 'downloadedEver'
|
82
|
+
attribute 'downloadLimit', :writeable => true
|
83
|
+
attribute 'downloadLimited', :name => :download_limited?, :writeable => true
|
84
|
+
attribute 'error', :type => :error
|
85
|
+
attribute 'errorString'
|
86
|
+
attribute 'eta', :type => :eta
|
87
|
+
attribute 'files', :type => [:file]
|
88
|
+
attribute 'fileStats', :name => :files_stats, :type => [:file_stat]
|
89
|
+
attribute 'hashString'
|
90
|
+
attribute 'haveUnchecked'
|
91
|
+
attribute 'haveValid'
|
92
|
+
attribute 'honorsSessionLimits', :name => :honors_session_limits?, :writeable => true
|
93
|
+
attribute 'isFinished', :name => :finished?
|
94
|
+
attribute 'isPrivate', :name => :private?
|
95
|
+
attribute 'leftUntilDone'
|
96
|
+
attribute 'magnetLink'
|
97
|
+
attribute 'manualAnnounceTime' # FIXME: add type
|
98
|
+
attribute 'maxConnectedPeers'
|
99
|
+
attribute 'metadataPercentComplete'
|
100
|
+
attribute 'name'
|
101
|
+
attribute 'peer-limit', :writeable => true
|
102
|
+
attribute 'peers', :type => [:peer]
|
103
|
+
attribute 'peersConnected'
|
104
|
+
attribute 'peersFrom', :type => :peers_from
|
105
|
+
attribute 'peersGettingFromUs'
|
106
|
+
attribute 'peersSendingToUs'
|
107
|
+
attribute 'percentDone'
|
108
|
+
attribute 'pieceCount'
|
109
|
+
attribute 'pieceSize'
|
110
|
+
attribute 'priorities', :type => [:priority]
|
111
|
+
attribute 'rateDownload'
|
112
|
+
attribute 'rateUpload'
|
113
|
+
attribute 'recheckProgress'
|
114
|
+
attribute 'secondsDownloading'
|
115
|
+
attribute 'secondsSeeding'
|
116
|
+
attribute 'seedIdleLimit', :writeable => true
|
117
|
+
attribute 'seedIdleMode', :type => :seed_idle_mode, :writeable => true
|
118
|
+
attribute 'seedRatioLimit', :writeable => true
|
119
|
+
attribute 'seedRatioMode', :type => :seed_ratio_mode, :writeable => true
|
120
|
+
attribute 'sizeWhenDone'
|
121
|
+
attribute 'startDate', :type => :time
|
122
|
+
attribute 'status', :type => :status
|
123
|
+
attribute 'trackers', :type => [:tracker]
|
124
|
+
attribute 'trackerStats', :name => :trackers_stats, :type => [:tracker_stat]
|
125
|
+
attribute 'totalSize'
|
126
|
+
attribute 'torrentFile'
|
127
|
+
attribute 'uploadedEver'
|
128
|
+
attribute 'uploadLimit', :writeable => true
|
129
|
+
attribute 'uploadLimited', :name => :upload_limited?, :writeable => true
|
130
|
+
attribute 'uploadRatio'
|
131
|
+
attribute 'wanted'
|
132
|
+
attribute 'webseeds' # FIXME: add type
|
133
|
+
attribute 'webseedsSendingToUs'
|
154
134
|
|
155
135
|
def initialize(session, id)
|
156
136
|
@session = session
|
@@ -189,5 +169,55 @@ module RTransmission
|
|
189
169
|
|
190
170
|
@session.client.call(RTransmission::Request.new('torrent-set-location', {'ids' => @id}.merge(pargs), 'Torrent.move'))
|
191
171
|
end
|
172
|
+
|
173
|
+
def pieces
|
174
|
+
request = RTransmission::Request.new('torrent-get', {'ids' => @id, 'fields' => ['pieces']}, 'Torrent.pieces') do |arguments|
|
175
|
+
pieces = arguments['torrents'][0]['pieces']
|
176
|
+
Base64::decode64(pieces).unpack('B*')[0][0 .. piece_count - 1]
|
177
|
+
end
|
178
|
+
|
179
|
+
@session.client.call(request)
|
180
|
+
end
|
181
|
+
|
182
|
+
def priorities=(priorities)
|
183
|
+
phigh = []
|
184
|
+
pnormal = []
|
185
|
+
plow = []
|
186
|
+
0.upto(priorities.size - 1) do |i|
|
187
|
+
phigh << i if priorities[i] == :high
|
188
|
+
pnormal << i if priorities[i] == :normal
|
189
|
+
plow << i if priorities[i] == :low
|
190
|
+
end
|
191
|
+
|
192
|
+
pargs = {}
|
193
|
+
pargs.merge!({'priority-high' => phigh}) if phigh.size != 0
|
194
|
+
pargs.merge!({'priority-normal' => pnormal}) if pnormal.size != 0
|
195
|
+
pargs.merge!({'priority-low' => plow}) if plow.size != 0
|
196
|
+
|
197
|
+
request = RTransmission::Request.new('torrent-set', {'ids' => @id}.merge(pargs), 'Torrent.files_priorities=') do
|
198
|
+
priorities
|
199
|
+
end
|
200
|
+
|
201
|
+
@session.client.call(request)
|
202
|
+
end
|
203
|
+
|
204
|
+
def wanted=(wanted)
|
205
|
+
pwanted = []
|
206
|
+
punwanted = []
|
207
|
+
0.upto(wanted.size - 1) do |i|
|
208
|
+
pwanted << i if wanted[i]
|
209
|
+
punwanted << i unless wanted[i]
|
210
|
+
end
|
211
|
+
|
212
|
+
pargs = {}
|
213
|
+
pargs.merge!({'files-wanted' => pwanted}) if pwanted.size != 0
|
214
|
+
pargs.merge!({'files-unwanted' => punwanted}) if punwanted.size != 0
|
215
|
+
|
216
|
+
request = RTransmission::Request.new('torrent-set', {'ids' => @id}.merge(pargs), 'Torrent.wanted=') do
|
217
|
+
wanted
|
218
|
+
end
|
219
|
+
|
220
|
+
@session.client.call(request)
|
221
|
+
end
|
192
222
|
end
|
193
223
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# Copyright (c) 2011, Andrew Kirilenko <andrew.kirilenko@gmail.com>
|
2
|
+
# All rights reserved.
|
3
|
+
# Use of this source code is governed by a BSD-style license that can be found in the COPYING file.
|
4
|
+
|
5
|
+
module RTransmission
|
6
|
+
class Type
|
7
|
+
def self.type_to_class(type)
|
8
|
+
type = type.to_s
|
9
|
+
type = '_' + type
|
10
|
+
type.gsub!(/_./) { |x| x[1].upcase }
|
11
|
+
|
12
|
+
RTransmission::Types.const_get(type)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.unmap(value, type)
|
16
|
+
if type
|
17
|
+
if type.class == Array
|
18
|
+
type = RTransmission::Type.type_to_class(type[0])
|
19
|
+
value.map! { |v| type.unmap(v) }
|
20
|
+
else
|
21
|
+
type = RTransmission::Type.type_to_class(type)
|
22
|
+
value = type.unmap(value)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
value
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.map(value, type)
|
30
|
+
if type
|
31
|
+
if type.class == Array
|
32
|
+
type = RTransmission::Type.type_to_class(type[0])
|
33
|
+
value.map! { |v| type.map(v) }
|
34
|
+
else
|
35
|
+
type = RTransmission::Type.type_to_class(type)
|
36
|
+
value = type.map(value)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
value
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.attribute(rpc_name, args = {})
|
44
|
+
name = args[:name] || RTransmission::Client.rpc_name_to_ruby_name(rpc_name)
|
45
|
+
|
46
|
+
self.send :define_method, name.to_s do
|
47
|
+
RTransmission::Type.unmap(@hash[rpc_name], args[:type])
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def initialize(hash)
|
52
|
+
@hash = hash
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# Copyright (c) 2011, Andrew Kirilenko <andrew.kirilenko@gmail.com>
|
2
|
+
# All rights reserved.
|
3
|
+
# Use of this source code is governed by a BSD-style license that can be found in the COPYING file.
|
4
|
+
|
5
|
+
require 'rtransmission/types/error'
|
6
|
+
require 'rtransmission/types/eta'
|
7
|
+
require 'rtransmission/types/priority'
|
8
|
+
require 'rtransmission/types/time'
|
9
|
+
require 'rtransmission/types/file'
|
10
|
+
require 'rtransmission/types/file_stat'
|
11
|
+
require 'rtransmission/types/peer'
|
12
|
+
require 'rtransmission/types/peers_from'
|
13
|
+
require 'rtransmission/types/seed_idle_mode'
|
14
|
+
require 'rtransmission/types/seed_ratio_mode'
|
15
|
+
require 'rtransmission/types/status'
|
16
|
+
require 'rtransmission/types/tracker'
|
17
|
+
require 'rtransmission/types/tracker_state'
|
18
|
+
require 'rtransmission/types/tracker_stat'
|
19
|
+
require 'rtransmission/types/day'
|
20
|
+
require 'rtransmission/types/encryption'
|
21
|
+
require 'rtransmission/types/traffic_stats'
|
22
|
+
require 'rtransmission/types/stats'
|
@@ -3,8 +3,8 @@
|
|
3
3
|
# Use of this source code is governed by a BSD-style license that can be found in the COPYING file.
|
4
4
|
|
5
5
|
module RTransmission
|
6
|
-
module
|
7
|
-
class Day
|
6
|
+
module Types
|
7
|
+
class Day < RTransmission::Type
|
8
8
|
MAP = {1 => :sunday, 2 => :monday, 4 => :tuesday, 8 => :wednesday, 16 => :thursday, 32 => :friday, 64 => :saturday}
|
9
9
|
|
10
10
|
def self.unmap(value)
|
@@ -3,8 +3,8 @@
|
|
3
3
|
# Use of this source code is governed by a BSD-style license that can be found in the COPYING file.
|
4
4
|
|
5
5
|
module RTransmission
|
6
|
-
module
|
7
|
-
class Encryption
|
6
|
+
module Types
|
7
|
+
class Encryption < RTransmission::Type
|
8
8
|
def self.unmap(value)
|
9
9
|
value.to_sym
|
10
10
|
end
|
@@ -3,8 +3,8 @@
|
|
3
3
|
# Use of this source code is governed by a BSD-style license that can be found in the COPYING file.
|
4
4
|
|
5
5
|
module RTransmission
|
6
|
-
module
|
7
|
-
class Error
|
6
|
+
module Types
|
7
|
+
class Error < RTransmission::Type
|
8
8
|
MAP = {0 => :ok, 1 => :tracker_warning, 2 => :tracker_error, 3 => :local_error}
|
9
9
|
|
10
10
|
def self.unmap(value)
|
@@ -3,8 +3,8 @@
|
|
3
3
|
# Use of this source code is governed by a BSD-style license that can be found in the COPYING file.
|
4
4
|
|
5
5
|
module RTransmission
|
6
|
-
module
|
7
|
-
class
|
6
|
+
module Types
|
7
|
+
class Eta < RTransmission::Type
|
8
8
|
MAP = {-1 => :not_available, -2 => :unknown}
|
9
9
|
|
10
10
|
def self.unmap(value)
|
@@ -3,14 +3,14 @@
|
|
3
3
|
# Use of this source code is governed by a BSD-style license that can be found in the COPYING file.
|
4
4
|
|
5
5
|
module RTransmission
|
6
|
-
module
|
7
|
-
class
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
module Types
|
7
|
+
class File < RTransmission::Type
|
8
|
+
attribute 'name'
|
9
|
+
attribute 'length'
|
10
|
+
attribute 'bytesCompleted'
|
11
11
|
|
12
|
-
def self.
|
13
|
-
value
|
12
|
+
def self.unmap(value)
|
13
|
+
RTransmission::Types::File.new(value)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# Copyright (c) 2011, Andrew Kirilenko <andrew.kirilenko@gmail.com>
|
2
|
+
# All rights reserved.
|
3
|
+
# Use of this source code is governed by a BSD-style license that can be found in the COPYING file.
|
4
|
+
|
5
|
+
module RTransmission
|
6
|
+
module Types
|
7
|
+
class FileStat < RTransmission::Type
|
8
|
+
attribute 'bytesCompleted'
|
9
|
+
attribute 'wanted', :name => :wanted?
|
10
|
+
attribute 'priority', :type => :priority
|
11
|
+
|
12
|
+
def self.unmap(value)
|
13
|
+
RTransmission::Types::FileStat.new(value)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# Copyright (c) 2011, Andrew Kirilenko <andrew.kirilenko@gmail.com>
|
2
|
+
# All rights reserved.
|
3
|
+
# Use of this source code is governed by a BSD-style license that can be found in the COPYING file.
|
4
|
+
|
5
|
+
module RTransmission
|
6
|
+
module Types
|
7
|
+
class Peer < RTransmission::Type
|
8
|
+
attribute 'address'
|
9
|
+
attribute 'clientIsChoked', :name => :client_choked?
|
10
|
+
attribute 'clientIsInterested', :name => :client_interested?
|
11
|
+
attribute 'clientName'
|
12
|
+
attribute 'flagStr'
|
13
|
+
attribute 'isDownloadingFrom', :name => :downloading_from?
|
14
|
+
attribute 'isEncrypted', :name => :encrypted?
|
15
|
+
attribute 'isIncoming', :name => :incoming?
|
16
|
+
attribute 'isUTP', :name => :utp?
|
17
|
+
attribute 'isUploadingTo', :name => :uploading_to?
|
18
|
+
attribute 'peerIsChoked', :name => :peer_choked?
|
19
|
+
attribute 'peerIsInterested', :name => :peer_interested?
|
20
|
+
attribute 'port'
|
21
|
+
attribute 'progress'
|
22
|
+
attribute 'rateToClient'
|
23
|
+
attribute 'rateToPeer'
|
24
|
+
|
25
|
+
def self.unmap(value)
|
26
|
+
RTransmission::Types::Peer.new(value)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# Copyright (c) 2011, Andrew Kirilenko <andrew.kirilenko@gmail.com>
|
2
|
+
# All rights reserved.
|
3
|
+
# Use of this source code is governed by a BSD-style license that can be found in the COPYING file.
|
4
|
+
|
5
|
+
module RTransmission
|
6
|
+
module Types
|
7
|
+
class PeersFrom < RTransmission::Type
|
8
|
+
attribute 'fromCache', :name => :cache
|
9
|
+
attribute 'fromDht', :name => :dht
|
10
|
+
attribute 'fromIncoming', :name => :incoming
|
11
|
+
attribute 'fromLtep', :name => :ltep
|
12
|
+
attribute 'fromPex', :name => :pex
|
13
|
+
attribute 'fromTracker', :name => :tracker
|
14
|
+
|
15
|
+
def self.unmap(value)
|
16
|
+
RTransmission::Types::PeersFrom.new(value)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -3,8 +3,8 @@
|
|
3
3
|
# Use of this source code is governed by a BSD-style license that can be found in the COPYING file.
|
4
4
|
|
5
5
|
module RTransmission
|
6
|
-
module
|
7
|
-
class Priority
|
6
|
+
module Types
|
7
|
+
class Priority < RTransmission::Type
|
8
8
|
MAP = {-1 => :low, 0 => :normal, 1 => :high}
|
9
9
|
|
10
10
|
def self.unmap(value)
|
@@ -3,8 +3,8 @@
|
|
3
3
|
# Use of this source code is governed by a BSD-style license that can be found in the COPYING file.
|
4
4
|
|
5
5
|
module RTransmission
|
6
|
-
module
|
7
|
-
class SeedIdleMode
|
6
|
+
module Types
|
7
|
+
class SeedIdleMode < RTransmission::Type
|
8
8
|
MAP = {0 => :global, 1 => :single, 2 => :unlimited}
|
9
9
|
|
10
10
|
def self.unmap(value)
|
@@ -3,8 +3,8 @@
|
|
3
3
|
# Use of this source code is governed by a BSD-style license that can be found in the COPYING file.
|
4
4
|
|
5
5
|
module RTransmission
|
6
|
-
module
|
7
|
-
class SeedRatioMode
|
6
|
+
module Types
|
7
|
+
class SeedRatioMode < RTransmission::Type
|
8
8
|
MAP = {0 => :global, 1 => :single, 2 => :unlimited}
|
9
9
|
|
10
10
|
def self.unmap(value)
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# Copyright (c) 2011, Andrew Kirilenko <andrew.kirilenko@gmail.com>
|
2
|
+
# All rights reserved.
|
3
|
+
# Use of this source code is governed by a BSD-style license that can be found in the COPYING file.
|
4
|
+
|
5
|
+
module RTransmission
|
6
|
+
module Types
|
7
|
+
class Stats < RTransmission::Type
|
8
|
+
attribute 'activeTorrentCount'
|
9
|
+
attribute 'downloadSpeed'
|
10
|
+
attribute 'pausedTorrentCount'
|
11
|
+
attribute 'torrentCount'
|
12
|
+
attribute 'uploadSpeed'
|
13
|
+
attribute 'cumulative-stats', :type => :traffic_stats
|
14
|
+
attribute 'current-stats', :type => :traffic_stats
|
15
|
+
|
16
|
+
def self.unmap(value)
|
17
|
+
RTransmission::Types::Stats.new(value)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -3,8 +3,8 @@
|
|
3
3
|
# Use of this source code is governed by a BSD-style license that can be found in the COPYING file.
|
4
4
|
|
5
5
|
module RTransmission
|
6
|
-
module
|
7
|
-
class Status
|
6
|
+
module Types
|
7
|
+
class Status < RTransmission::Type
|
8
8
|
MAP = {1 => :check_wait, 2 => :check, 4 => :download, 8 => :seed, 16 => :stopped}
|
9
9
|
|
10
10
|
def self.unmap(value)
|
@@ -3,8 +3,8 @@
|
|
3
3
|
# Use of this source code is governed by a BSD-style license that can be found in the COPYING file.
|
4
4
|
|
5
5
|
module RTransmission
|
6
|
-
module
|
7
|
-
class Time
|
6
|
+
module Types
|
7
|
+
class Time < RTransmission::Type
|
8
8
|
def self.unmap(value)
|
9
9
|
value == 0 ? nil : ::Time.at(value)
|
10
10
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# Copyright (c) 2011, Andrew Kirilenko <andrew.kirilenko@gmail.com>
|
2
|
+
# All rights reserved.
|
3
|
+
# Use of this source code is governed by a BSD-style license that can be found in the COPYING file.
|
4
|
+
|
5
|
+
module RTransmission
|
6
|
+
module Types
|
7
|
+
class Tracker < RTransmission::Type
|
8
|
+
attribute 'id'
|
9
|
+
attribute 'announce'
|
10
|
+
attribute 'scrape'
|
11
|
+
attribute 'tier'
|
12
|
+
|
13
|
+
def self.unmap(value)
|
14
|
+
RTransmission::Types::Tracker.new(value)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# Copyright (c) 2011, Andrew Kirilenko <andrew.kirilenko@gmail.com>
|
2
|
+
# All rights reserved.
|
3
|
+
# Use of this source code is governed by a BSD-style license that can be found in the COPYING file.
|
4
|
+
|
5
|
+
# FIXME: add types where needed
|
6
|
+
module RTransmission
|
7
|
+
module Types
|
8
|
+
class TrackerStat < RTransmission::Type
|
9
|
+
attribute 'id'
|
10
|
+
attribute 'announce'
|
11
|
+
attribute 'announceState', :type => :tracker_state
|
12
|
+
attribute 'downloadCount'
|
13
|
+
attribute 'hasAnnounced', :name => :announced?
|
14
|
+
attribute 'hasScraped', :name => :scraped?
|
15
|
+
attribute 'host'
|
16
|
+
attribute 'isBackup', :name => :backup?
|
17
|
+
attribute 'lastAnnouncePeerCount'
|
18
|
+
attribute 'lastAnnounceResult'
|
19
|
+
attribute 'lastAnnounceStartTime', :type => :time
|
20
|
+
attribute 'lastAnnounceSucceeded', :name => :last_announce_succeeded?
|
21
|
+
attribute 'lastAnnounceTime', :type => :time
|
22
|
+
attribute 'lastAnnounceTimedOut', :name => :last_announce_timed_out?
|
23
|
+
attribute 'lastScrapeResult'
|
24
|
+
attribute 'lastScrapeStartTime', :type => :time
|
25
|
+
attribute 'lastScrapeSucceeded', :name => :last_scrape_succeeded?
|
26
|
+
attribute 'lastScrapeTime', :type => :time
|
27
|
+
attribute 'lastScrapeTimedOut', :name => :last_scrape_timed_out?
|
28
|
+
attribute 'leecherCount'
|
29
|
+
attribute 'nextAnnounceTime', :type => :time
|
30
|
+
attribute 'nextScrapeTime', :type => :time
|
31
|
+
attribute 'scrape'
|
32
|
+
attribute 'scrapeState', :type => :tracker_state
|
33
|
+
attribute 'seederCount'
|
34
|
+
attribute 'tier'
|
35
|
+
|
36
|
+
def self.unmap(value)
|
37
|
+
RTransmission::Types::TrackerStat.new(value)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# Copyright (c) 2011, Andrew Kirilenko <andrew.kirilenko@gmail.com>
|
2
|
+
# All rights reserved.
|
3
|
+
# Use of this source code is governed by a BSD-style license that can be found in the COPYING file.
|
4
|
+
|
5
|
+
module RTransmission
|
6
|
+
module Types
|
7
|
+
class TrackerState < RTransmission::Type
|
8
|
+
MAP = {0 => :inactive, 1 => :waiting, 2 => :queued, 3 => :active}
|
9
|
+
|
10
|
+
def self.unmap(value)
|
11
|
+
MAP[value]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# Copyright (c) 2011, Andrew Kirilenko <andrew.kirilenko@gmail.com>
|
2
|
+
# All rights reserved.
|
3
|
+
# Use of this source code is governed by a BSD-style license that can be found in the COPYING file.
|
4
|
+
|
5
|
+
module RTransmission
|
6
|
+
module Types
|
7
|
+
class TrafficStats < RTransmission::Type
|
8
|
+
attribute 'uploadedBytes'
|
9
|
+
attribute 'downloadedBytes'
|
10
|
+
attribute 'filesAdded'
|
11
|
+
attribute 'sessionCount'
|
12
|
+
attribute 'secondsActive'
|
13
|
+
|
14
|
+
def self.unmap(value)
|
15
|
+
RTransmission::Types::TrafficStats.new(value)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: rtransmission
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: "0.
|
5
|
+
version: "0.3"
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Andrew Kirilenko
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-06-
|
13
|
+
date: 2011-06-07 00:00:00 +03:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|
@@ -26,34 +26,33 @@ files:
|
|
26
26
|
- COPYING
|
27
27
|
- README.md
|
28
28
|
- rtransmission.gemspec
|
29
|
-
- lib/rtransmission/fields.rb
|
30
29
|
- lib/rtransmission/client.rb
|
31
30
|
- lib/rtransmission/session.rb
|
31
|
+
- lib/rtransmission/types/eta.rb
|
32
|
+
- lib/rtransmission/types/time.rb
|
33
|
+
- lib/rtransmission/types/tracker_stat.rb
|
34
|
+
- lib/rtransmission/types/encryption.rb
|
35
|
+
- lib/rtransmission/types/error.rb
|
36
|
+
- lib/rtransmission/types/tracker.rb
|
37
|
+
- lib/rtransmission/types/stats.rb
|
38
|
+
- lib/rtransmission/types/peers_from.rb
|
39
|
+
- lib/rtransmission/types/file_stat.rb
|
40
|
+
- lib/rtransmission/types/tracker_state.rb
|
41
|
+
- lib/rtransmission/types/file.rb
|
42
|
+
- lib/rtransmission/types/status.rb
|
43
|
+
- lib/rtransmission/types/seed_ratio_mode.rb
|
44
|
+
- lib/rtransmission/types/peer.rb
|
45
|
+
- lib/rtransmission/types/priority.rb
|
46
|
+
- lib/rtransmission/types/traffic_stats.rb
|
47
|
+
- lib/rtransmission/types/seed_idle_mode.rb
|
48
|
+
- lib/rtransmission/types/day.rb
|
32
49
|
- lib/rtransmission/version.rb
|
33
50
|
- lib/rtransmission/torrent.rb
|
51
|
+
- lib/rtransmission/types.rb
|
34
52
|
- lib/rtransmission/response.rb
|
53
|
+
- lib/rtransmission/type.rb
|
35
54
|
- lib/rtransmission/exception.rb
|
36
55
|
- lib/rtransmission/request.rb
|
37
|
-
- lib/rtransmission/fields/eta.rb
|
38
|
-
- lib/rtransmission/fields/time.rb
|
39
|
-
- lib/rtransmission/fields/tracker_stat.rb
|
40
|
-
- lib/rtransmission/fields/encryption.rb
|
41
|
-
- lib/rtransmission/fields/error.rb
|
42
|
-
- lib/rtransmission/fields/tracker.rb
|
43
|
-
- lib/rtransmission/fields/stats.rb
|
44
|
-
- lib/rtransmission/fields/peers_from.rb
|
45
|
-
- lib/rtransmission/fields/file_stat.rb
|
46
|
-
- lib/rtransmission/fields/percent.rb
|
47
|
-
- lib/rtransmission/fields/pieces.rb
|
48
|
-
- lib/rtransmission/fields/file.rb
|
49
|
-
- lib/rtransmission/fields/status.rb
|
50
|
-
- lib/rtransmission/fields/seed_ratio_mode.rb
|
51
|
-
- lib/rtransmission/fields/peer.rb
|
52
|
-
- lib/rtransmission/fields/priority.rb
|
53
|
-
- lib/rtransmission/fields/traffic_stats.rb
|
54
|
-
- lib/rtransmission/fields/seed_idle_mode.rb
|
55
|
-
- lib/rtransmission/fields/day.rb
|
56
|
-
- lib/rtransmission/field.rb
|
57
56
|
- lib/rtransmission.rb
|
58
57
|
has_rdoc: true
|
59
58
|
homepage: http://github.com/iced/rtransmission
|
data/lib/rtransmission/field.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
# Copyright (c) 2011, Andrew Kirilenko <andrew.kirilenko@gmail.com>
|
2
|
-
# All rights reserved.
|
3
|
-
# Use of this source code is governed by a BSD-style license that can be found in the COPYING file.
|
4
|
-
|
5
|
-
module RTransmission
|
6
|
-
class Field
|
7
|
-
def self.unmap(value)
|
8
|
-
value
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.define_attribute(name, rpc_name, args = {})
|
12
|
-
self.send :define_method, name.to_s do
|
13
|
-
value = @hash[rpc_name]
|
14
|
-
value = args[:type].unmap(value) if args[:type]
|
15
|
-
|
16
|
-
value
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def initialize(hash)
|
21
|
-
@hash = hash
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
data/lib/rtransmission/fields.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
# Copyright (c) 2011, Andrew Kirilenko <andrew.kirilenko@gmail.com>
|
2
|
-
# All rights reserved.
|
3
|
-
# Use of this source code is governed by a BSD-style license that can be found in the COPYING file.
|
4
|
-
|
5
|
-
require 'rtransmission/fields/error'
|
6
|
-
require 'rtransmission/fields/eta'
|
7
|
-
require 'rtransmission/fields/percent'
|
8
|
-
require 'rtransmission/fields/priority'
|
9
|
-
require 'rtransmission/fields/time'
|
10
|
-
require 'rtransmission/fields/file'
|
11
|
-
require 'rtransmission/fields/file_stat'
|
12
|
-
require 'rtransmission/fields/peer'
|
13
|
-
require 'rtransmission/fields/peers_from'
|
14
|
-
require 'rtransmission/fields/pieces'
|
15
|
-
require 'rtransmission/fields/seed_idle_mode'
|
16
|
-
require 'rtransmission/fields/seed_ratio_mode'
|
17
|
-
require 'rtransmission/fields/status'
|
18
|
-
require 'rtransmission/fields/tracker'
|
19
|
-
require 'rtransmission/fields/tracker_stat'
|
20
|
-
require 'rtransmission/fields/day'
|
21
|
-
require 'rtransmission/fields/encryption'
|
22
|
-
require 'rtransmission/fields/traffic_stats'
|
23
|
-
require 'rtransmission/fields/stats'
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# Copyright (c) 2011, Andrew Kirilenko <andrew.kirilenko@gmail.com>
|
2
|
-
# All rights reserved.
|
3
|
-
# Use of this source code is governed by a BSD-style license that can be found in the COPYING file.
|
4
|
-
|
5
|
-
module RTransmission
|
6
|
-
module Fields
|
7
|
-
class File < RTransmission::Field
|
8
|
-
define_attribute :name, 'name'
|
9
|
-
define_attribute :length, 'length'
|
10
|
-
define_attribute :bytes_completed, 'bytesCompleted'
|
11
|
-
|
12
|
-
def self.unmap(value)
|
13
|
-
RTransmission::Fields::File.new(value)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# Copyright (c) 2011, Andrew Kirilenko <andrew.kirilenko@gmail.com>
|
2
|
-
# All rights reserved.
|
3
|
-
# Use of this source code is governed by a BSD-style license that can be found in the COPYING file.
|
4
|
-
|
5
|
-
module RTransmission
|
6
|
-
module Fields
|
7
|
-
class FileStat < RTransmission::Field
|
8
|
-
define_attribute :bytes_completed, 'bytesCompleted'
|
9
|
-
define_attribute :wanted?, 'wanted'
|
10
|
-
define_attribute :priority, 'priority', :type => RTransmission::Fields::Priority
|
11
|
-
|
12
|
-
def self.unmap(value)
|
13
|
-
RTransmission::Fields::FileStat.new(value)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# Copyright (c) 2011, Andrew Kirilenko <andrew.kirilenko@gmail.com>
|
2
|
-
# All rights reserved.
|
3
|
-
# Use of this source code is governed by a BSD-style license that can be found in the COPYING file.
|
4
|
-
|
5
|
-
module RTransmission
|
6
|
-
module Fields
|
7
|
-
class Peer < RTransmission::Field
|
8
|
-
define_attribute :address, 'address'
|
9
|
-
define_attribute :client_choked?, 'clientIsChoked'
|
10
|
-
define_attribute :client_interested?, 'clientIsInterested'
|
11
|
-
define_attribute :client_name, 'clientName'
|
12
|
-
define_attribute :flag_str, 'flagStr'
|
13
|
-
define_attribute :downloading_from?, 'isDownloadingFrom'
|
14
|
-
define_attribute :encrypted?, 'isEncrypted'
|
15
|
-
define_attribute :incoming?, 'isIncoming'
|
16
|
-
define_attribute :utp?, 'isUTP'
|
17
|
-
define_attribute :uploading_to?, 'isUploadingTo'
|
18
|
-
define_attribute :peer_choked?, 'peerIsChoked'
|
19
|
-
define_attribute :peer_interested?, 'peerIsInterested'
|
20
|
-
define_attribute :port, 'port'
|
21
|
-
define_attribute :progress, 'progress', :type => RTransmission::Fields::Percent
|
22
|
-
define_attribute :rate_to_client, 'rateToClient'
|
23
|
-
define_attribute :rate_to_peer, 'rateToPeer'
|
24
|
-
|
25
|
-
def self.unmap(value)
|
26
|
-
RTransmission::Fields::Peer.new(value)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# Copyright (c) 2011, Andrew Kirilenko <andrew.kirilenko@gmail.com>
|
2
|
-
# All rights reserved.
|
3
|
-
# Use of this source code is governed by a BSD-style license that can be found in the COPYING file.
|
4
|
-
|
5
|
-
module RTransmission
|
6
|
-
module Fields
|
7
|
-
class PeersFrom < RTransmission::Field
|
8
|
-
define_attribute :cache, 'fromCache'
|
9
|
-
define_attribute :dht, 'fromDht'
|
10
|
-
define_attribute :incoming, 'fromIncoming'
|
11
|
-
define_attribute :ltep, 'fromLtep'
|
12
|
-
define_attribute :pex, 'fromPex'
|
13
|
-
define_attribute :tracker, 'fromTracker'
|
14
|
-
|
15
|
-
def self.unmap(value)
|
16
|
-
RTransmission::Fields::PeersFrom.new(value)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# Copyright (c) 2011, Andrew Kirilenko <andrew.kirilenko@gmail.com>
|
2
|
-
# All rights reserved.
|
3
|
-
# Use of this source code is governed by a BSD-style license that can be found in the COPYING file.
|
4
|
-
|
5
|
-
module RTransmission
|
6
|
-
module Fields
|
7
|
-
class Pieces
|
8
|
-
def self.unmap(value)
|
9
|
-
value
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# Copyright (c) 2011, Andrew Kirilenko <andrew.kirilenko@gmail.com>
|
2
|
-
# All rights reserved.
|
3
|
-
# Use of this source code is governed by a BSD-style license that can be found in the COPYING file.
|
4
|
-
|
5
|
-
module RTransmission
|
6
|
-
module Fields
|
7
|
-
class Stats < RTransmission::Field
|
8
|
-
define_attribute :active_torrent_count, 'activeTorrentCount'
|
9
|
-
define_attribute :download_speed, 'downloadSpeed'
|
10
|
-
define_attribute :paused_torrent_count, 'pausedTorrentCount'
|
11
|
-
define_attribute :torrent_count, 'torrentCount'
|
12
|
-
define_attribute :upload_speed, 'uploadSpeed'
|
13
|
-
define_attribute :cumulative_stats, 'cumulative-stats', :type => RTransmission::Fields::TrafficStats
|
14
|
-
define_attribute :current_stats, 'current-stats', :type => RTransmission::Fields::TrafficStats
|
15
|
-
|
16
|
-
def self.unmap(value)
|
17
|
-
RTransmission::Fields::Stats.new(value)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# Copyright (c) 2011, Andrew Kirilenko <andrew.kirilenko@gmail.com>
|
2
|
-
# All rights reserved.
|
3
|
-
# Use of this source code is governed by a BSD-style license that can be found in the COPYING file.
|
4
|
-
|
5
|
-
module RTransmission
|
6
|
-
module Fields
|
7
|
-
class Tracker < RTransmission::Field
|
8
|
-
define_attribute :id, 'id'
|
9
|
-
define_attribute :announce, 'announce'
|
10
|
-
define_attribute :scrape, 'scrape'
|
11
|
-
define_attribute :tier, 'tier'
|
12
|
-
|
13
|
-
def self.unmap(value)
|
14
|
-
RTransmission::Fields::Tracker.new(value)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
# Copyright (c) 2011, Andrew Kirilenko <andrew.kirilenko@gmail.com>
|
2
|
-
# All rights reserved.
|
3
|
-
# Use of this source code is governed by a BSD-style license that can be found in the COPYING file.
|
4
|
-
|
5
|
-
# FIXME: add types where needed
|
6
|
-
module RTransmission
|
7
|
-
module Fields
|
8
|
-
class TrackerStat < RTransmission::Field
|
9
|
-
define_attribute :id, 'id'
|
10
|
-
define_attribute :announce, 'announce'
|
11
|
-
define_attribute :announce_state, 'announceState'
|
12
|
-
define_attribute :download_count, 'downloadCount'
|
13
|
-
define_attribute :has_announced, 'hasAnnounced'
|
14
|
-
define_attribute :has_scraped, 'hasScraped'
|
15
|
-
define_attribute :host, 'host'
|
16
|
-
define_attribute :is_backup, 'isBackup'
|
17
|
-
define_attribute :last_announce_peer_count, 'lastAnnouncePeerCount'
|
18
|
-
define_attribute :last_announce_result, 'lastAnnounceResult'
|
19
|
-
define_attribute :last_announce_start_time, 'lastAnnounceStartTime'
|
20
|
-
define_attribute :last_announce_succeeded, 'lastAnnounceSucceeded'
|
21
|
-
define_attribute :last_announce_time, 'lastAnnounceTime'
|
22
|
-
define_attribute :last_announce_timed_out, 'lastAnnounceTimedOut'
|
23
|
-
define_attribute :last_scrape_result, 'lastScrapeResult'
|
24
|
-
define_attribute :last_scrape_start_time, 'lastScrapeStartTime'
|
25
|
-
define_attribute :last_scrape_succeeded, 'lastScrapeSucceeded'
|
26
|
-
define_attribute :last_scrape_time, 'lastScrapeTime'
|
27
|
-
define_attribute :last_scrape_timed_out, 'lastScrapeTimedOut'
|
28
|
-
define_attribute :leecher_count, 'leecherCount'
|
29
|
-
define_attribute :next_announce_time, 'nextAnnounceTime'
|
30
|
-
define_attribute :next_scrape_time, 'nextScrapeTime'
|
31
|
-
define_attribute :scrape, 'scrape'
|
32
|
-
define_attribute :scrape_state, 'scrapeState'
|
33
|
-
define_attribute :seeder_count, 'seederCount'
|
34
|
-
define_attribute :tier, 'tier'
|
35
|
-
|
36
|
-
def self.unmap(value)
|
37
|
-
RTransmission::Fields::TrackerStat.new(value)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# Copyright (c) 2011, Andrew Kirilenko <andrew.kirilenko@gmail.com>
|
2
|
-
# All rights reserved.
|
3
|
-
# Use of this source code is governed by a BSD-style license that can be found in the COPYING file.
|
4
|
-
|
5
|
-
module RTransmission
|
6
|
-
module Fields
|
7
|
-
class TrafficStats < RTransmission::Field
|
8
|
-
define_attribute :uploaded_bytes, 'uploadedBytes'
|
9
|
-
define_attribute :downloaded_bytes, 'downloadedBytes'
|
10
|
-
define_attribute :files_added, 'filesAdded'
|
11
|
-
define_attribute :session_count, 'sessionCount'
|
12
|
-
define_attribute :seconds_active, 'secondsActive'
|
13
|
-
|
14
|
-
def self.unmap(value)
|
15
|
-
RTransmission::Fields::TrafficStats.new(value)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|