zip_tricks 4.2.4 → 4.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -12
- data/lib/zip_tricks/rails_streaming.rb +11 -0
- data/lib/zip_tricks/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18e1b263b59742dc2a50c28b7074691aed53728f
|
4
|
+
data.tar.gz: c1c6b01370b806478e85ecb5a2299efd4005fbf4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0d0386b54c8bc0d54fc57e4e79ff2dc962651defbfe60ca7789bf6d30e83e4fdcdb5ba099179a9643a138175e1b87e6e070df3f5918da549d9b1e4193c5d851
|
7
|
+
data.tar.gz: b6528fc6683c2db784a5845acef9073b74aa7ea5c86c6718b9109315d7c72e7f18ad9f6a8b1f46f95b56442714a72d3a3849b90dfd5d37cfef431fd21ab2b850
|
data/README.md
CHANGED
@@ -27,17 +27,11 @@ The easiest is to use the Rails' built-in streaming feature:
|
|
27
27
|
|
28
28
|
```ruby
|
29
29
|
class ZipsController < ActionController::Base
|
30
|
-
include ActionController::Live
|
31
|
-
|
30
|
+
include ActionController::Live # required for streaming
|
31
|
+
include ZipTricks::RailsStreaming
|
32
|
+
|
32
33
|
def download
|
33
|
-
|
34
|
-
|
35
|
-
# Create a wrapper for the write call that quacks like something you
|
36
|
-
# can << to, used by ZipTricks
|
37
|
-
w = ZipTricks::BlockWrite.new { |chunk| response.stream.write(chunk) }
|
38
|
-
|
39
|
-
# Send out the archive of some Substantially Large CSV Files (tm)
|
40
|
-
ZipTricks::Streamer.open(w) do |zip|
|
34
|
+
zip_tricks_stream do |zip|
|
41
35
|
zip.write_deflated_file('report1.csv') do |sink|
|
42
36
|
CSV(sink) do |csv_write|
|
43
37
|
csv << Person.column_names
|
@@ -50,8 +44,6 @@ class ZipsController < ActionController::Base
|
|
50
44
|
...
|
51
45
|
end
|
52
46
|
end
|
53
|
-
ensure
|
54
|
-
response.stream.close
|
55
47
|
end
|
56
48
|
end
|
57
49
|
```
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module ZipTricks::RailsStreaming
|
2
|
+
def zip_tricks_stream
|
3
|
+
response.headers['Content-Type'] = 'application/zip'
|
4
|
+
# Create a wrapper for the write call that quacks like something you
|
5
|
+
# can << to, used by ZipTricks
|
6
|
+
w = ZipTricks::BlockWrite.new { |chunk| response.stream.write(chunk) }
|
7
|
+
ZipTricks::Streamer.open(w){|z| yield(z) }
|
8
|
+
ensure
|
9
|
+
response.stream.close
|
10
|
+
end
|
11
|
+
end
|
data/lib/zip_tricks/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zip_tricks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julik Tarkhanov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -171,6 +171,7 @@ files:
|
|
171
171
|
- lib/zip_tricks/file_reader/stored_reader.rb
|
172
172
|
- lib/zip_tricks/null_writer.rb
|
173
173
|
- lib/zip_tricks/rack_body.rb
|
174
|
+
- lib/zip_tricks/rails_streaming.rb
|
174
175
|
- lib/zip_tricks/remote_io.rb
|
175
176
|
- lib/zip_tricks/remote_uncap.rb
|
176
177
|
- lib/zip_tricks/size_estimator.rb
|