leecher 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- leecher (1.1.0)
4
+ leecher (1.1.1)
5
5
  amqp
6
6
  daemon-kit
7
7
  erubis
@@ -6,22 +6,35 @@ module Leecher
6
6
 
7
7
  class << self
8
8
 
9
- def config
10
- DaemonKit::Config.load("leecher")
9
+ def config(config)
10
+ config = config.to_s
11
+ config += ".yml" unless config =~ /\.yml$/
12
+
13
+ # Development/git mode
14
+ path = File.join(DAEMON_ROOT, "config", config)
15
+
16
+ # Gem mode
17
+ unless File.exist?(path)
18
+ path = File.join(ENV["HOME"], ".leecher", config)
19
+ end
20
+
21
+ DaemonKit::Config.new(YAML.load_file(path))
22
+ end
23
+
24
+ def client_config
25
+ config("leecher")
11
26
  end
12
27
 
13
28
  def gheed_client
14
- config = DaemonKit::Config.load("gheed")
15
- Leecher::Gheed::Client.new(config)
29
+ Leecher::Gheed::Client.new(config("gheed"))
16
30
  end
17
31
 
18
32
  def aria2_client
19
- config = DaemonKit::Config.load("aria2")
20
- Leecher::Aria2::Client.new(config)
33
+ Leecher::Aria2::Client.new(config("aria2"))
21
34
  end
22
35
 
23
36
  def new
24
- Client.new(config, aria2_client, gheed_client)
37
+ Client.new(client_config, aria2_client, gheed_client)
25
38
  end
26
39
  end
27
40
  end
@@ -37,7 +37,15 @@ module Leecher
37
37
  uri = response["files"].first["uris"].first["uri"]
38
38
  state = response["status"].to_sym
39
39
  queue.set_store_entry(uri, :gid => gid, :state => state)
40
- notify_gheed(uri, state) if [:complete, :error].include?(state)
40
+
41
+ # Don't tell Gheed about completing metalink downloads - we only
42
+ # need to say when the file the metalink speaks about changes state
43
+ unless File.extname(uri) == ".metalink"
44
+ # .. and to a state we care about
45
+ if [:complete, :error].include?(state)
46
+ notify_gheed(uri, state)
47
+ end
48
+ end
41
49
  end
42
50
 
43
51
  def notify_gheed(uri, state)
@@ -1,3 +1,3 @@
1
1
  module Leecher
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
3
3
  end
@@ -46,14 +46,27 @@ module Leecher
46
46
  it "updates the store status" do
47
47
  response = {"bitfield"=>"80", "completedLength"=>"726", "connections"=>"0", "dir"=>"movies/720p/example", "downloadSpeed"=>"0", "errorCode"=>"0", "files"=>[{"completedLength"=>"726", "index"=>"1", "length"=>"726", "path"=>"movies/720p/example/nfo.metalink", "selected"=>"true", "uris"=>[{"status"=>"used", "uri"=>"http://example/download/metalinks/nfo.metalink"}, {"status"=>"waiting", "uri"=>"http://example/download/metalinks/nfo.metalink"}, {"status"=>"waiting", "uri"=>"http://example/download/metalinks/nfo.metalink"}, {"status"=>"waiting", "uri"=>"http://example/download/metalinks/nfo.metalink"}, {"status"=>"waiting", "uri"=>"http://example/download/metalinks/nfo.metalink"}]}], "followedBy"=>["2"], "gid"=>"1", "numPieces"=>"1", "pieceLength"=>"1048576", "status"=>"complete", "totalLength"=>"726", "uploadLength"=>"0", "uploadSpeed"=>"0"}
48
48
  aria2_client.should_receive(:tell_status).with(1).and_return(response)
49
- gheed_client.should_receive(:state_change).with("http://example/download/metalinks/nfo.metalink", :complete).
50
- and_return([{"metalink_url" => "http://example/download/metalinks/nfo.metalink"}, []])
51
49
  leecher.state_change(1)
52
50
  entry = leecher.queue.get_queue["http://example/download/metalinks/nfo.metalink"]
53
51
  entry.should_not be_nil
54
52
  entry[:gid].should eq(1)
55
53
  entry[:state].should eq(:complete)
56
54
  end
55
+
56
+ it "notifies gheed for non-metalinks and marks the related metalink as complete" do
57
+ response = {"bitfield"=>"80", "completedLength"=>"726", "connections"=>"0", "dir"=>"movies/720p/example", "downloadSpeed"=>"0", "errorCode"=>"0", "files"=>[{"completedLength"=>"726", "index"=>"1", "length"=>"726", "path"=>"movies/720p/example/nfo", "selected"=>"true", "uris"=>[{"status"=>"used", "uri"=>"http://example/download/metalinks/nfo"}, {"status"=>"waiting", "uri"=>"http://example/download/metalinks/nfo"}, {"status"=>"waiting", "uri"=>"http://example/download/metalinks/nfo"}, {"status"=>"waiting", "uri"=>"http://example/download/metalinks/nfo"}, {"status"=>"waiting", "uri"=>"http://example/download/metalinks/nfo"}]}], "followedBy"=>["2"], "gid"=>"1", "numPieces"=>"1", "pieceLength"=>"1048576", "status"=>"complete", "totalLength"=>"726", "uploadLength"=>"0", "uploadSpeed"=>"0"}
58
+ aria2_client.should_receive(:tell_status).with(1).and_return(response)
59
+ gheed_client.should_receive(:state_change).with("http://example/download/metalinks/nfo", :complete).
60
+ and_return([{"metalink_url" => "http://example/download/metalinks/nfo.metalink"}, []])
61
+ leecher.state_change(1)
62
+ entry = leecher.queue.get_queue["http://example/download/metalinks/nfo"]
63
+ entry.should_not be_nil
64
+ entry[:gid].should eq(1)
65
+ entry[:state].should eq(:complete)
66
+ entry = leecher.queue.get_queue["http://example/download/metalinks/nfo.metalink"]
67
+ entry.should_not be_nil
68
+ entry[:state].should eq(:complete)
69
+ end
57
70
  end
58
71
  end
59
72
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: leecher
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-07-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: daemon-kit
16
- requirement: &13644920 !ruby/object:Gem::Requirement
16
+ requirement: &14990740 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *13644920
24
+ version_requirements: *14990740
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: safely
27
- requirement: &13644100 !ruby/object:Gem::Requirement
27
+ requirement: &14989020 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *13644100
35
+ version_requirements: *14989020
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: multi_json
38
- requirement: &13643400 !ruby/object:Gem::Requirement
38
+ requirement: &14988280 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *13643400
46
+ version_requirements: *14988280
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: yajl-ruby
49
- requirement: &13642640 !ruby/object:Gem::Requirement
49
+ requirement: &14987540 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *13642640
57
+ version_requirements: *14987540
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: amqp
60
- requirement: &13641980 !ruby/object:Gem::Requirement
60
+ requirement: &14985540 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *13641980
68
+ version_requirements: *14985540
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: erubis
71
- requirement: &13639820 !ruby/object:Gem::Requirement
71
+ requirement: &15204020 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *13639820
79
+ version_requirements: *15204020
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: sys-filesystem
82
- requirement: &13638180 !ruby/object:Gem::Requirement
82
+ requirement: &15200540 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *13638180
90
+ version_requirements: *15200540
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: rest-client
93
- requirement: &13637180 !ruby/object:Gem::Requirement
93
+ requirement: &15197960 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :runtime
100
100
  prerelease: false
101
- version_requirements: *13637180
101
+ version_requirements: *15197960
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: rake
104
- requirement: &13690700 !ruby/object:Gem::Requirement
104
+ requirement: &15334280 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: '0'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *13690700
112
+ version_requirements: *15334280
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: rspec
115
- requirement: &13689740 !ruby/object:Gem::Requirement
115
+ requirement: &15354560 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ! '>='
@@ -120,7 +120,7 @@ dependencies:
120
120
  version: '0'
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *13689740
123
+ version_requirements: *15354560
124
124
  description: A server populates a queue, this client downloads those files
125
125
  email:
126
126
  - marcbowes+leecher@gmail.com
@@ -186,7 +186,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
186
186
  version: '0'
187
187
  segments:
188
188
  - 0
189
- hash: -4395843245282034706
189
+ hash: 2364743130667923727
190
190
  required_rubygems_version: !ruby/object:Gem::Requirement
191
191
  none: false
192
192
  requirements:
@@ -195,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
195
195
  version: '0'
196
196
  segments:
197
197
  - 0
198
- hash: -4395843245282034706
198
+ hash: 2364743130667923727
199
199
  requirements: []
200
200
  rubyforge_project: leecher
201
201
  rubygems_version: 1.8.11