saber 1.0.2 → 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/.bundle/config +2 -0
- data/CHANGELOG.md +6 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +13 -2
- data/README.md +1 -1
- data/lib/saber/autofetcher/client.rb +28 -32
- data/lib/saber/autofetcher/server.rb +13 -22
- data/lib/saber/rc.rb +10 -0
- data/lib/saber/version.rb +1 -1
- data/saber.gemspec +1 -1
- data/templates/_saberrc +0 -5
- metadata +5 -4
data/.bundle/config
ADDED
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -5,11 +5,21 @@ GEM
|
|
5
5
|
i18n (~> 0.6)
|
6
6
|
multi_json (~> 1.0)
|
7
7
|
addressable (2.3.2)
|
8
|
+
blather (0.8.0)
|
9
|
+
activesupport (>= 2.3.11)
|
10
|
+
eventmachine (>= 0.12.6)
|
11
|
+
girl_friday
|
12
|
+
niceogiri (~> 1.0)
|
13
|
+
nokogiri (~> 1.5.5)
|
14
|
+
connection_pool (0.9.2)
|
8
15
|
crack (0.3.1)
|
9
16
|
diff-lcs (1.1.3)
|
10
17
|
domain_name (0.5.3)
|
11
18
|
unf (~> 0.0.3)
|
19
|
+
eventmachine (1.0.0)
|
12
20
|
ffi (1.1.5)
|
21
|
+
girl_friday (0.10.0)
|
22
|
+
connection_pool (~> 0.9.0)
|
13
23
|
guard (1.3.2)
|
14
24
|
listen (>= 0.4.2)
|
15
25
|
thor (>= 0.14.6)
|
@@ -32,6 +42,8 @@ GEM
|
|
32
42
|
net-http-digest_auth (1.2.1)
|
33
43
|
net-http-persistent (2.7)
|
34
44
|
net-ssh (2.5.2)
|
45
|
+
niceogiri (1.0.2)
|
46
|
+
nokogiri (~> 1.4)
|
35
47
|
nokogiri (1.5.5)
|
36
48
|
ntlm-http (0.1.1)
|
37
49
|
optimism (3.3.1)
|
@@ -65,12 +77,12 @@ GEM
|
|
65
77
|
addressable (>= 2.2.7)
|
66
78
|
crack (>= 0.1.7)
|
67
79
|
webrobots (0.0.13)
|
68
|
-
xmpp4r (0.5)
|
69
80
|
|
70
81
|
PLATFORMS
|
71
82
|
ruby
|
72
83
|
|
73
84
|
DEPENDENCIES
|
85
|
+
blather (~> 0.8.0)
|
74
86
|
guard
|
75
87
|
guard-rspec
|
76
88
|
highline (~> 1.6.14)
|
@@ -87,4 +99,3 @@ DEPENDENCIES
|
|
87
99
|
thor (~> 0.16.0)
|
88
100
|
vcr
|
89
101
|
webmock
|
90
|
-
xmpp4r (~> 0.5)
|
data/README.md
CHANGED
@@ -122,7 +122,7 @@ Automatically fetch: when a file is finished download in rutorrent with label 's
|
|
122
122
|
|
123
123
|
Manually fetch: right click 'Saber Fetch' in rutorrent web ui, then it'll add to aria2.
|
124
124
|
|
125
|
-
Or from command line, send a download file to client: `saber drb_add <hash_id> saber
|
125
|
+
Or from command line, send a download file to client: `saber drb_add <hash_id> saber`, sometime the client need a long time(2 minutes) to recive the file list sent by server.
|
126
126
|
|
127
127
|
For ArchLinux, you can install `saber-server-daemon`, `user-saber-client-daemon`, `user-aria2-daemon` packages.
|
128
128
|
|
@@ -1,5 +1,4 @@
|
|
1
|
-
require "
|
2
|
-
require "xmpp4r/client"
|
1
|
+
require "blather/client/dsl"
|
3
2
|
require "drb"
|
4
3
|
|
5
4
|
module Saber
|
@@ -7,52 +6,47 @@ module Saber
|
|
7
6
|
class Client
|
8
7
|
class << self
|
9
8
|
def start
|
10
|
-
|
9
|
+
c = Client.new
|
10
|
+
c.start
|
11
11
|
|
12
|
-
|
13
|
-
p Thread.list
|
14
|
-
|
15
|
-
Thread.list.each{|v| v.join}
|
12
|
+
EM.run { c.run }
|
16
13
|
end
|
17
14
|
end
|
18
15
|
|
19
|
-
|
16
|
+
include Blather::DSL
|
17
|
+
|
18
|
+
attr_reader :fetcher
|
20
19
|
|
21
20
|
def initialize
|
22
|
-
@client = Jabber::Client.new(Jabber::JID.new(Rc.client.xmpp.jid))
|
23
21
|
@fetcher = Fetcher.new
|
24
22
|
end
|
25
23
|
|
24
|
+
def run
|
25
|
+
client.run
|
26
|
+
end
|
27
|
+
|
26
28
|
def start
|
27
|
-
|
28
|
-
|
29
|
+
rc = Rc.client.xmpp
|
30
|
+
setup rc.jid, rc.password, rc.host, rc.port
|
31
|
+
when_ready { Saber.ui.say ">> Connected to xmpp at #{jid}" }
|
32
|
+
disconnected { client.connect }
|
29
33
|
|
30
|
-
|
31
|
-
|
32
|
-
begin
|
33
|
-
client.send Jabber::Presence.new.set_type(:unavaliable)
|
34
|
-
rescue IOError # closed stream
|
35
|
-
Saber.ui.error "closed stream (IOError)"
|
36
|
-
end
|
34
|
+
message :chat?, :body, :from => /#{Rc.server.xmpp.jid}/ do |m|
|
35
|
+
process_msg m.body
|
37
36
|
end
|
38
|
-
|
39
|
-
client.add_message_callback { |msg|
|
40
|
-
if msg.from.bare == Rc.server.xmpp.jid
|
41
|
-
files = msg.body.split("\n")
|
42
|
-
Saber.ui.debug "RECV #{files}"
|
43
|
-
fetcher.add *files
|
44
|
-
end
|
45
|
-
pd "add done"
|
46
|
-
}
|
47
|
-
|
48
|
-
client.send Jabber::Iq.new_rosterget
|
49
|
-
client.send Jabber::Presence.new.set_type(:avaliable)
|
50
|
-
Saber.ui.say ">> Connected to xmpp with #{Rc.client.xmpp.jid}"
|
51
37
|
end
|
52
38
|
|
53
39
|
def stop
|
54
40
|
@client.close!
|
55
41
|
end
|
42
|
+
|
43
|
+
protected
|
44
|
+
|
45
|
+
def process_msg(body)
|
46
|
+
files = body.split("\n")
|
47
|
+
Saber.ui.debug files.map{|v| "RECV #{v}"}.join("\n")
|
48
|
+
fetcher.add *files
|
49
|
+
end
|
56
50
|
end
|
57
51
|
|
58
52
|
class DRbClient
|
@@ -65,9 +59,11 @@ module Saber
|
|
65
59
|
end
|
66
60
|
|
67
61
|
def add(*names)
|
68
|
-
Saber.ui.
|
62
|
+
Saber.ui.debug "DRbClient-ADD #{names.inspect}"
|
69
63
|
server.add(*names)
|
70
64
|
end
|
71
65
|
end
|
72
66
|
end
|
73
67
|
end
|
68
|
+
|
69
|
+
# vim: fdn=4
|
@@ -1,42 +1,35 @@
|
|
1
|
-
require "
|
2
|
-
require "xmpp4r/client"
|
1
|
+
require "blather/client/dsl"
|
3
2
|
require "drb"
|
4
3
|
|
5
4
|
module Saber
|
6
5
|
module AutoFetcher
|
7
6
|
class Server
|
7
|
+
include Blather::DSL
|
8
|
+
|
8
9
|
def self.start
|
9
10
|
s = Server.new
|
10
11
|
DRbServer.start(s)
|
11
12
|
s.start
|
12
13
|
|
13
|
-
|
14
|
+
EM.run { s.run }
|
14
15
|
end
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
def initialize
|
19
|
-
@client = Jabber::Client.new(Jabber::JID.new(Rc.server.xmpp.jid))
|
17
|
+
def run
|
18
|
+
client.run
|
20
19
|
end
|
21
20
|
|
22
21
|
def start
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
at_exit do
|
27
|
-
client.send Jabber::Presence.new.set_type(:unavaliable)
|
28
|
-
end
|
29
|
-
|
30
|
-
client.send Jabber::Iq.new_rosterget
|
31
|
-
client.send Jabber::Presence.new.set_type(:avaliable)
|
22
|
+
rc = Rc.server.xmpp
|
23
|
+
setup rc.jid, rc.password, rc.host, rc.port
|
32
24
|
|
33
|
-
Saber.ui.say ">> Connected to xmpp
|
25
|
+
when_ready { Saber.ui.say ">> Connected to xmpp at #{jid}" }
|
26
|
+
disconnected { client.connect }
|
34
27
|
end
|
35
28
|
|
36
29
|
def send(files)
|
37
|
-
|
38
|
-
|
39
|
-
|
30
|
+
msg = files.join("\n")
|
31
|
+
Saber.ui.debug files.map{|v| "SEND #{v}"}.join("\n")
|
32
|
+
say Rc.client.xmpp.jid , msg
|
40
33
|
end
|
41
34
|
end
|
42
35
|
|
@@ -61,9 +54,7 @@ module Saber
|
|
61
54
|
|
62
55
|
# drb. add a complete torrent.
|
63
56
|
def add(*names)
|
64
|
-
Saber.ui.debug "DRbServer-ADD #{names.inspect}"
|
65
57
|
files = build_files(*names)
|
66
|
-
|
67
58
|
saber_server.send(files)
|
68
59
|
end
|
69
60
|
|
data/lib/saber/rc.rb
CHANGED
data/lib/saber/version.rb
CHANGED
data/saber.gemspec
CHANGED
@@ -24,7 +24,7 @@ A complete solution for PT users.
|
|
24
24
|
s.add_dependency "retort", "~> 0.0.6"
|
25
25
|
s.add_dependency "thor", "~> 0.16.0"
|
26
26
|
s.add_dependency "net-ssh", "~> 2.5.2"
|
27
|
-
s.add_dependency "
|
27
|
+
s.add_dependency "blather", "~> 0.8.0"
|
28
28
|
s.add_dependency "mechanize", "~> 2.5.1"
|
29
29
|
s.add_dependency "highline", "~> 1.6.14"
|
30
30
|
s.add_dependency "reverse_markdown", "~> 0.3.0"
|
data/templates/_saberrc
CHANGED
@@ -19,18 +19,13 @@ bib:
|
|
19
19
|
# [saber-fetch]
|
20
20
|
server:
|
21
21
|
ftp = "ftp://seedbox/bt"
|
22
|
-
|
23
22
|
xmpp:
|
24
23
|
jid = "x1@gmail.com"
|
25
24
|
password = "y1"
|
26
|
-
host = nil
|
27
|
-
port = nil
|
28
25
|
|
29
26
|
client:
|
30
27
|
xmpp:
|
31
28
|
jid = "x2@gmail.com"
|
32
29
|
password = "y2"
|
33
|
-
host = nil
|
34
|
-
port = nil
|
35
30
|
|
36
31
|
# vim: ft=ruby
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: saber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -124,13 +124,13 @@ dependencies:
|
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: 2.5.2
|
126
126
|
- !ruby/object:Gem::Dependency
|
127
|
-
name:
|
127
|
+
name: blather
|
128
128
|
requirement: !ruby/object:Gem::Requirement
|
129
129
|
none: false
|
130
130
|
requirements:
|
131
131
|
- - ~>
|
132
132
|
- !ruby/object:Gem::Version
|
133
|
-
version:
|
133
|
+
version: 0.8.0
|
134
134
|
type: :runtime
|
135
135
|
prerelease: false
|
136
136
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -138,7 +138,7 @@ dependencies:
|
|
138
138
|
requirements:
|
139
139
|
- - ~>
|
140
140
|
- !ruby/object:Gem::Version
|
141
|
-
version:
|
141
|
+
version: 0.8.0
|
142
142
|
- !ruby/object:Gem::Dependency
|
143
143
|
name: mechanize
|
144
144
|
requirement: !ruby/object:Gem::Requirement
|
@@ -197,6 +197,7 @@ extensions:
|
|
197
197
|
- extconf.rb
|
198
198
|
extra_rdoc_files: []
|
199
199
|
files:
|
200
|
+
- .bundle/config
|
200
201
|
- .gitignore
|
201
202
|
- .rspec
|
202
203
|
- .travis.yml
|