ganapati 0.0.2 → 0.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/ganapati/client.rb +14 -7
- metadata +3 -3
data/lib/ganapati/client.rb
CHANGED
|
@@ -34,17 +34,24 @@ module Ganapati
|
|
|
34
34
|
# copy remote file to local
|
|
35
35
|
def get(remotepath, destpath)
|
|
36
36
|
Kernel.open(destpath, 'w') { |dest|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
index = 0
|
|
40
|
-
while index < size
|
|
41
|
-
dest.write(source.read(index, 1048576))
|
|
42
|
-
index += 1048576
|
|
43
|
-
end
|
|
37
|
+
readchunks(remotepath) { |chunk|
|
|
38
|
+
dest.write chunk
|
|
44
39
|
}
|
|
45
40
|
}
|
|
46
41
|
end
|
|
47
42
|
|
|
43
|
+
# yeild chunksize of path one chunk at a time
|
|
44
|
+
def readchunks(path, chunksize=1048576)
|
|
45
|
+
open(path) { |source|
|
|
46
|
+
size = source.length
|
|
47
|
+
index = 0
|
|
48
|
+
while index < size
|
|
49
|
+
yield source.read(index, chunksize)
|
|
50
|
+
index += chunksize
|
|
51
|
+
end
|
|
52
|
+
}
|
|
53
|
+
end
|
|
54
|
+
|
|
48
55
|
# for writing to a new file
|
|
49
56
|
def create(path, &block)
|
|
50
57
|
file_handle :create, path, &block
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ganapati
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 25
|
|
5
5
|
prerelease: false
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
8
|
- 0
|
|
9
|
-
-
|
|
10
|
-
version: 0.0.
|
|
9
|
+
- 3
|
|
10
|
+
version: 0.0.3
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Brian Muller
|