retort 0.0.6 → 0.0.8
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 +15 -0
- data/README.rdoc +11 -1
- data/lib/retort.rb +1 -0
- data/lib/retort/file.rb +66 -0
- data/lib/retort/service.rb +1 -1
- data/lib/retort/torrent.rb +8 -1
- data/lib/retort/version.rb +1 -1
- metadata +12 -10
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NDIyMWFmZTJjMmJmODQ0MGE4Njk4Mjk2ZGM3YTYyZWZmM2ViMTNjZA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZmI0YzYzZjRlMWJjYjRjYTNiMTMyNDVhYjY5NGJjOGQxMzQ5ZGRkYw==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MDBjNjFhZWM5NTE1Nzk1NzUxNGU2MzQ2ZDMwNmMyNDlmNzNhMTc1OTc4NGQz
|
10
|
+
Njg4ODhlYzBmODZmMWIwODdlYTQxMTM5MzU5OTgxYWEwYzkzOTZmNTQyZDFh
|
11
|
+
Y2VmMzk3Y2IyMTkxM2ExNDFhMzUyOGQwMjA3MGZlOWNiZTljZDk=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
N2YzMjdkY2FkM2UyNTVlM2FjNTBiYWI2ZWY5MGUxMDQyMjVhOGJhNDEwZmJk
|
14
|
+
MWE1MDhiNTliZjM5MjNiYTIxNzFjMjg1MzM0OTNjMTEzODFiOTcwNGM4NjA5
|
15
|
+
ODAxMDhjMmY2N2RjOTUxMGRlNWY5NjE0YTgyNjMwNmUzYjYwOWM=
|
data/README.rdoc
CHANGED
@@ -12,7 +12,17 @@ Update your Gemfile with this and do a bundle install:
|
|
12
12
|
To get a list of all torrents:
|
13
13
|
|
14
14
|
require 'retort'
|
15
|
-
Retort::
|
15
|
+
Retort::Service.configure do |config|
|
16
|
+
config.url = 'https://username:password@your.server.com/path/to/rtorrent/rpc'
|
17
|
+
end
|
18
|
+
torrents = Retort::Torrent.all
|
19
|
+
torrent = torrents.first
|
20
|
+
|
21
|
+
files = torrent.files
|
22
|
+
file = files.first
|
23
|
+
|
24
|
+
file.set_priority(Retort::File::PRIORITY_HIGH) # sets the priority
|
25
|
+
torrent.commit_priorities # this is supposed to be an expensive call
|
16
26
|
|
17
27
|
== Contributions
|
18
28
|
|
data/lib/retort.rb
CHANGED
data/lib/retort/file.rb
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
module Retort
|
2
|
+
# A file inside a torrent
|
3
|
+
class File < Rtorrent
|
4
|
+
setup :f do
|
5
|
+
get_completed_chunks
|
6
|
+
get_frozen_path
|
7
|
+
is_created
|
8
|
+
is_open
|
9
|
+
get_last_touched
|
10
|
+
get_match_depth_next
|
11
|
+
get_match_depth_prev
|
12
|
+
get_offset
|
13
|
+
get_path
|
14
|
+
get_path_components
|
15
|
+
get_path_depth
|
16
|
+
get_priority
|
17
|
+
get_range_first
|
18
|
+
get_range_second
|
19
|
+
get_size_bytes
|
20
|
+
get_size_chunks
|
21
|
+
end
|
22
|
+
def [](v)
|
23
|
+
instance_variable_get "@#{v}".to_sym
|
24
|
+
end
|
25
|
+
def initialize(attributes, meta)
|
26
|
+
@index = meta.fetch(:index)
|
27
|
+
@torrent_info_hash = meta.fetch(:torrent_info_hash)
|
28
|
+
@attributes = {}
|
29
|
+
attributes.each do |attrib, value|
|
30
|
+
variable = "@#{attrib}".to_sym
|
31
|
+
if attrib =~ /is_/
|
32
|
+
bool_value = value.truth
|
33
|
+
variable = "@#{attrib.to_s.gsub(/is_/, "")}".to_sym
|
34
|
+
self.instance_variable_set variable, bool_value
|
35
|
+
elsif attrib =~ /get_/
|
36
|
+
variable = "@#{attrib.to_s.gsub(/get_/, "")}".to_sym
|
37
|
+
self.instance_variable_set variable, value
|
38
|
+
else
|
39
|
+
self.instance_variable_set variable, value
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
def completed?
|
45
|
+
@completed_chunks == @size_chunks
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.all(info_hash)
|
49
|
+
methods = attributes.map {|key,value| "#{value}="}
|
50
|
+
Service.call("f.multicall", info_hash,"", *methods).map.with_index do |r, index|
|
51
|
+
attributes = Hash[self.attributes.keys.zip(r)]
|
52
|
+
self.new attributes, {torrent_info_hash: info_hash, index: index}
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
PRIORITY_HIGH=2
|
57
|
+
PRIORITY_NORMAL=1
|
58
|
+
|
59
|
+
def set_priority(prio,commit=true)
|
60
|
+
Service.call("f.set_priority",@torrent_info_hash,@index, prio)
|
61
|
+
Torrent.new({info_hash: @torrent_info_hash}).commit_priorities if commit
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
|
data/lib/retort/service.rb
CHANGED
@@ -17,7 +17,7 @@ module Retort
|
|
17
17
|
# by default, if configure hasn't been call the url will be defaulted
|
18
18
|
# to http://localhost/RPC2
|
19
19
|
def service
|
20
|
-
@@service ||= XMLRPC::Client.new2("http://
|
20
|
+
@@service ||= XMLRPC::Client.new2("http://localhost/RPC2")
|
21
21
|
end
|
22
22
|
|
23
23
|
def call(*args)
|
data/lib/retort/torrent.rb
CHANGED
@@ -6,7 +6,7 @@ module Retort
|
|
6
6
|
|
7
7
|
setup :d do
|
8
8
|
info_hash name: 'hash'
|
9
|
-
name
|
9
|
+
torrent_name name: 'name'
|
10
10
|
connection_current
|
11
11
|
size name: 'size_bytes', type: :size
|
12
12
|
completed name: 'completed_bytes', type: :size
|
@@ -88,6 +88,13 @@ module Retort
|
|
88
88
|
|
89
89
|
actions
|
90
90
|
end
|
91
|
+
def files
|
92
|
+
File.all(self.info_hash)
|
93
|
+
end
|
94
|
+
def commit_priorities
|
95
|
+
Service.call("d.update_priorities",self.info_hash)
|
96
|
+
end
|
97
|
+
|
91
98
|
end
|
92
99
|
end
|
93
100
|
|
data/lib/retort/version.rb
CHANGED
metadata
CHANGED
@@ -1,27 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: retort
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.8
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Marcel Morgan
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-11-16 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rspec
|
16
|
-
requirement:
|
17
|
-
none: false
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
17
|
- - ! '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
|
-
version_requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
25
27
|
description: An rTorrent xmlrpc wrapper written in ruby
|
26
28
|
email:
|
27
29
|
- marcel.morgan@gmail.com
|
@@ -39,6 +41,7 @@ files:
|
|
39
41
|
- autotest/discover.rb
|
40
42
|
- lib/retort.rb
|
41
43
|
- lib/retort/core_ext.rb
|
44
|
+
- lib/retort/file.rb
|
42
45
|
- lib/retort/rtorrent.rb
|
43
46
|
- lib/retort/service.rb
|
44
47
|
- lib/retort/torrent.rb
|
@@ -49,27 +52,26 @@ files:
|
|
49
52
|
- spec/spec_helper.rb
|
50
53
|
homepage: https://github.com/mcmorgan/retort
|
51
54
|
licenses: []
|
55
|
+
metadata: {}
|
52
56
|
post_install_message:
|
53
57
|
rdoc_options: []
|
54
58
|
require_paths:
|
55
59
|
- lib
|
56
60
|
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
61
|
requirements:
|
59
62
|
- - ! '>='
|
60
63
|
- !ruby/object:Gem::Version
|
61
64
|
version: '0'
|
62
65
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
-
none: false
|
64
66
|
requirements:
|
65
67
|
- - ! '>='
|
66
68
|
- !ruby/object:Gem::Version
|
67
69
|
version: '0'
|
68
70
|
requirements: []
|
69
71
|
rubyforge_project: retort
|
70
|
-
rubygems_version:
|
72
|
+
rubygems_version: 2.4.3
|
71
73
|
signing_key:
|
72
|
-
specification_version:
|
74
|
+
specification_version: 4
|
73
75
|
summary: An rTorrent xmlrpc wrapper written in ruby
|
74
76
|
test_files:
|
75
77
|
- spec/rtorrent/methods_spec.rb
|