em-zipper 0.0.1 → 0.0.2
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 +4 -4
- data/examples/async_sinatra.md +1 -0
- data/examples/file.rb +20 -6
- data/examples/files/sample1.txt +94981 -0
- data/examples/io.rb +40 -27
- data/lib/em-zipper/base.rb +23 -9
- data/lib/em-zipper/version.rb +5 -0
- data/lib/em-zipper/zip_output_stream.rb +4 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc727f74fced2747964e208ae1ec001d672f26fa
|
4
|
+
data.tar.gz: 837304dea8ffb7568c0b820359f89d615ccb1054
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb7f794cc055025fa377a42c2c9bf1110780f626511812f0a4671262ec98c6b0c7f368357d309013b610b3bc9527708a45b6aa5b1a2ec3a163fc9119dcc12e25
|
7
|
+
data.tar.gz: bee9cd5d524c65446229b7bcee7891cf787b10eaa8e3bba1569ff82210548463bcda71b65608f12b5da0abe1b106b4c8209fd27c649f9409a2984c263e97bef5
|
@@ -0,0 +1 @@
|
|
1
|
+
[Async Sinatra Example here](https://github.com/nowk/async-sinatra-em-zipper-example)
|
data/examples/file.rb
CHANGED
@@ -4,17 +4,31 @@ require './lib/em-zipper'
|
|
4
4
|
EM.run do
|
5
5
|
EM.add_periodic_timer(1) { puts 'tick' } # tick tock
|
6
6
|
|
7
|
+
|
8
|
+
# file zip to file
|
9
|
+
#
|
7
10
|
files = %w(sample1.txt sample2.txt).map do |file_name|
|
8
11
|
File.join(File.expand_path("./examples/files"), file_name)
|
9
12
|
end
|
10
13
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
+
fbuff = File.new('file-non-blocking.zip', 'w')
|
15
|
+
fzip = EM::Zipper.new(files, fbuff)
|
16
|
+
fzip.callback do |io|
|
17
|
+
puts 'File zipped from files'
|
18
|
+
end
|
14
19
|
|
15
|
-
|
16
|
-
|
17
|
-
|
20
|
+
|
21
|
+
# http remotes to file
|
22
|
+
#
|
23
|
+
sites = %w(http://www.google.com/ https://www.github.com/)
|
24
|
+
rbuff = File.new('remotes-file-non-blocking.zip', 'w')
|
25
|
+
rzip = EM::Zipper.new(sites, rbuff)
|
26
|
+
rzip.callback do |io|
|
27
|
+
puts 'File zipped from remotes'
|
18
28
|
end
|
29
|
+
|
30
|
+
|
31
|
+
fzip.zip!
|
32
|
+
rzip.zip!
|
19
33
|
end
|
20
34
|
|