tryphon-pige-client 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/pige/client/chunk.rb +9 -3
- data/lib/pige/client/chunk_scheduler.rb +17 -2
- data/lib/pige/client/resource.rb +3 -1
- data/lib/pige/client/version.rb +1 -1
- metadata +4 -4
data/lib/pige/client/chunk.rb
CHANGED
@@ -5,7 +5,10 @@ module Pige::Client
|
|
5
5
|
time_attribute :begin, :end
|
6
6
|
|
7
7
|
def completion_rate
|
8
|
-
self.class.get("#{Pige::Client.box_url}/sources/1/chunks/#{id}.json")
|
8
|
+
response = self.class.get("#{Pige::Client.box_url}/sources/1/chunks/#{id}.json")
|
9
|
+
if response.code == 200
|
10
|
+
response["completion_rate"].to_f
|
11
|
+
end
|
9
12
|
end
|
10
13
|
|
11
14
|
def extension
|
@@ -21,12 +24,15 @@ module Pige::Client
|
|
21
24
|
end
|
22
25
|
|
23
26
|
def download(target)
|
24
|
-
File.
|
27
|
+
target_file = File.join(target, download_file)
|
28
|
+
|
29
|
+
File.open(target_file, "w") do |file|
|
25
30
|
open(download_url) do |url|
|
26
31
|
IO.copy_stream url, file
|
27
32
|
end
|
28
33
|
end
|
29
|
-
|
34
|
+
|
35
|
+
target_file
|
30
36
|
end
|
31
37
|
end
|
32
38
|
end
|
@@ -9,6 +9,11 @@ module Pige::Client
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def wait(timeout = nil)
|
12
|
+
if chunks.empty?
|
13
|
+
puts "No chunk to wait"
|
14
|
+
return
|
15
|
+
end
|
16
|
+
|
12
17
|
timeout ||= chunks.size * 5
|
13
18
|
print "Wait for new chunks to be ready : "
|
14
19
|
deadline = Time.now + (timeout * 60)
|
@@ -20,7 +25,7 @@ module Pige::Client
|
|
20
25
|
chunk.completion_rate == 1
|
21
26
|
end
|
22
27
|
if uncompleted_chunks.empty?
|
23
|
-
puts "done\nChunks are ready"
|
28
|
+
puts " done\nChunks are ready"
|
24
29
|
break
|
25
30
|
else
|
26
31
|
print "."
|
@@ -30,6 +35,11 @@ module Pige::Client
|
|
30
35
|
end
|
31
36
|
|
32
37
|
def download(target)
|
38
|
+
if chunks.empty?
|
39
|
+
puts "No chunk to download"
|
40
|
+
return []
|
41
|
+
end
|
42
|
+
|
33
43
|
wait
|
34
44
|
|
35
45
|
FileUtils.mkdir_p target
|
@@ -111,7 +121,12 @@ module Pige::Client
|
|
111
121
|
puts "Create Chunk with #{attributes.inspect}"
|
112
122
|
|
113
123
|
unless dry_run?
|
114
|
-
|
124
|
+
chunk = Pige::Client::Chunk.create(attributes)
|
125
|
+
if chunk
|
126
|
+
chunks << chunk
|
127
|
+
else
|
128
|
+
puts "Error: can't create Chunk with #{attributes.inspect}"
|
129
|
+
end
|
115
130
|
sleep options[:delay].to_i if options[:delay]
|
116
131
|
end
|
117
132
|
end
|
data/lib/pige/client/resource.rb
CHANGED
data/lib/pige/client/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tryphon-pige-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-
|
13
|
+
date: 2015-04-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: fakeweb
|
@@ -174,7 +174,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
174
174
|
version: '0'
|
175
175
|
segments:
|
176
176
|
- 0
|
177
|
-
hash:
|
177
|
+
hash: 356711308025352021
|
178
178
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
179
179
|
none: false
|
180
180
|
requirements:
|
@@ -183,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
183
183
|
version: '0'
|
184
184
|
segments:
|
185
185
|
- 0
|
186
|
-
hash:
|
186
|
+
hash: 356711308025352021
|
187
187
|
requirements: []
|
188
188
|
rubyforge_project:
|
189
189
|
rubygems_version: 1.8.23
|