zipline 1.4.1 → 1.5.0
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/.github/workflows/ci.yml +0 -1
- data/Gemfile +1 -0
- data/README.md +4 -1
- data/lib/zipline/version.rb +1 -1
- data/lib/zipline/zip_generator.rb +3 -2
- data/lib/zipline.rb +2 -2
- data/spec/lib/zipline/zip_generator_spec.rb +6 -1
- data/spec/lib/zipline/zipline_spec.rb +29 -0
- data/spec/spec_helper.rb +2 -0
- data/zipline.gemspec +1 -1
- metadata +9 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8735b5a6429dcffa8672a1a970cc37145eadfd5e5ff13e2cb5b3f08166895d14
|
4
|
+
data.tar.gz: a4555919f140b0661cb12fd0e6f92900e419319ebf7ec7c376ce19034dffd9a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 758292743ee475bc2a276bd00d953fa4f0b1cb1c4ccd2ceae7b2c7dbeced0e1a901a609d183a68c6eeaa898693045f3d5f4ee23bfece0c35b379fb7ce170cdc2
|
7
|
+
data.tar.gz: 7383e439111008fa964a2d762f6855351d3a0372df973d453e0b205aee57f53d9fc8aea54e4f7efed6719b3b8318768f8d125e314ad277f2855bac29fa63c5e2
|
data/.github/workflows/ci.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -41,7 +41,10 @@ class MyController < ApplicationController
|
|
41
41
|
# responds to :url, :path or :file.
|
42
42
|
# :modification_time is an optional third argument you can use.
|
43
43
|
files = users.map{ |user| [user.avatar, "#{user.username}.png", modification_time: 1.day.ago] }
|
44
|
-
|
44
|
+
|
45
|
+
# we can force duplicate file names to be renamed, or raise an error
|
46
|
+
# we can also pass in our own writer if required to conform with the Delegated [ZipTricks::Streamer object](https://github.com/WeTransfer/zip_tricks/blob/main/lib/zip_tricks/streamer.rb#L147) object.
|
47
|
+
zipline(files, 'avatars.zip', auto_rename_duplicate_filenames: true)
|
45
48
|
end
|
46
49
|
end
|
47
50
|
```
|
data/lib/zipline/version.rb
CHANGED
@@ -3,8 +3,9 @@
|
|
3
3
|
module Zipline
|
4
4
|
class ZipGenerator
|
5
5
|
# takes an array of pairs [[uploader, filename], ... ]
|
6
|
-
def initialize(files)
|
6
|
+
def initialize(files, **kwargs_for_new)
|
7
7
|
@files = files
|
8
|
+
@kwargs_for_new = kwargs_for_new
|
8
9
|
end
|
9
10
|
|
10
11
|
#this is supposed to be streamed!
|
@@ -29,7 +30,7 @@ module Zipline
|
|
29
30
|
# this might pose a problem. Unlikely that it will be an issue here though.
|
30
31
|
write_buffer_size = 16 * 1024
|
31
32
|
write_buffer = ZipTricks::WriteBuffer.new(fake_io_writer, write_buffer_size)
|
32
|
-
ZipTricks::Streamer.open(write_buffer) do |streamer|
|
33
|
+
ZipTricks::Streamer.open(write_buffer, **@kwargs_for_new) do |streamer|
|
33
34
|
@files.each do |file, name, options = {}|
|
34
35
|
handle_file(streamer, file, name.to_s, options)
|
35
36
|
end
|
data/lib/zipline.rb
CHANGED
@@ -12,8 +12,8 @@ require "zipline/zip_generator"
|
|
12
12
|
# end
|
13
13
|
# end
|
14
14
|
module Zipline
|
15
|
-
def zipline(files, zipname = 'zipline.zip')
|
16
|
-
zip_generator = ZipGenerator.new(files)
|
15
|
+
def zipline(files, zipname = 'zipline.zip', **kwargs_for_new)
|
16
|
+
zip_generator = ZipGenerator.new(files, **kwargs_for_new)
|
17
17
|
headers['Content-Disposition'] = ContentDisposition.format(disposition: 'attachment', filename: zipname)
|
18
18
|
headers['Content-Type'] = Mime::Type.lookup_by_extension('zip').to_s
|
19
19
|
response.sending_file = true
|
@@ -216,7 +216,7 @@ describe Zipline::ZipGenerator do
|
|
216
216
|
|
217
217
|
it 'passes the options hash through handle_file' do
|
218
218
|
expect(generator).to receive(:handle_file)
|
219
|
-
.with(anything, anything, anything, modification_time: mtime)
|
219
|
+
.with(anything, anything, anything, { modification_time: mtime })
|
220
220
|
generator.each { |_| 'Test' }
|
221
221
|
end
|
222
222
|
|
@@ -267,4 +267,9 @@ describe Zipline::ZipGenerator do
|
|
267
267
|
end
|
268
268
|
end
|
269
269
|
end
|
270
|
+
it 'passes along constructor options to ZipTricks streamer' do
|
271
|
+
expect(ZipTricks::Streamer).to receive(:open).with(anything, { :some => 'options' })
|
272
|
+
generator = Zipline::ZipGenerator.new([file, 'somefile'], :some => 'options')
|
273
|
+
generator.each { |_| 'Test' }
|
274
|
+
end
|
270
275
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'ostruct'
|
3
|
+
|
4
|
+
describe Zipline do
|
5
|
+
before { Fog.mock! }
|
6
|
+
|
7
|
+
let (:undertest) {
|
8
|
+
class TestZipline
|
9
|
+
|
10
|
+
attr_accessor :headers
|
11
|
+
attr_accessor :response
|
12
|
+
attr_accessor :response_body
|
13
|
+
def initialize
|
14
|
+
@headers = {}
|
15
|
+
@response = OpenStruct.new(:cache_control => {}, :headers => {} )
|
16
|
+
end
|
17
|
+
include Zipline
|
18
|
+
end
|
19
|
+
return TestZipline.new()
|
20
|
+
}
|
21
|
+
|
22
|
+
|
23
|
+
it 'passes arguments along' do
|
24
|
+
expect(Zipline::ZipGenerator).to receive(:new)
|
25
|
+
.with(['some', 'fake', 'files'], { some: 'options' })
|
26
|
+
undertest.zipline(['some', 'fake', 'files'], 'myfiles.zip', some: 'options')
|
27
|
+
expect(undertest.headers['Content-Disposition']).to eq("attachment; filename=\"myfiles.zip\"; filename*=UTF-8''myfiles.zip")
|
28
|
+
end
|
29
|
+
end
|
data/spec/spec_helper.rb
CHANGED
data/zipline.gemspec
CHANGED
@@ -23,5 +23,5 @@ Gem::Specification.new do |gem|
|
|
23
23
|
gem.add_dependency 'zip_tricks', ['>= 4.2.1', '< 6.0']
|
24
24
|
|
25
25
|
# https://github.com/rspec/rspec-mocks/issues/1457
|
26
|
-
gem.add_development_dependency 'rspec-mocks',
|
26
|
+
gem.add_development_dependency 'rspec-mocks', '3.10.2'
|
27
27
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zipline
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ram Dobson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-10-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -68,22 +68,16 @@ dependencies:
|
|
68
68
|
name: rspec-mocks
|
69
69
|
requirement: !ruby/object:Gem::Requirement
|
70
70
|
requirements:
|
71
|
-
- -
|
72
|
-
- !ruby/object:Gem::Version
|
73
|
-
version: '3.10'
|
74
|
-
- - "!="
|
71
|
+
- - '='
|
75
72
|
- !ruby/object:Gem::Version
|
76
|
-
version: 3.10.
|
73
|
+
version: 3.10.2
|
77
74
|
type: :development
|
78
75
|
prerelease: false
|
79
76
|
version_requirements: !ruby/object:Gem::Requirement
|
80
77
|
requirements:
|
81
|
-
- -
|
82
|
-
- !ruby/object:Gem::Version
|
83
|
-
version: '3.10'
|
84
|
-
- - "!="
|
78
|
+
- - '='
|
85
79
|
- !ruby/object:Gem::Version
|
86
|
-
version: 3.10.
|
80
|
+
version: 3.10.2
|
87
81
|
description: a module for streaming dynamically generated zip files
|
88
82
|
email:
|
89
83
|
- ram.dobson@solsystemscompany.com
|
@@ -101,6 +95,7 @@ files:
|
|
101
95
|
- lib/zipline/zip_generator.rb
|
102
96
|
- spec/fakefile.txt
|
103
97
|
- spec/lib/zipline/zip_generator_spec.rb
|
98
|
+
- spec/lib/zipline/zipline_spec.rb
|
104
99
|
- spec/spec_helper.rb
|
105
100
|
- zipline.gemspec
|
106
101
|
homepage: http://github.com/fringd/zipline
|
@@ -122,11 +117,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
117
|
- !ruby/object:Gem::Version
|
123
118
|
version: '0'
|
124
119
|
requirements: []
|
125
|
-
rubygems_version: 3.
|
120
|
+
rubygems_version: 3.3.11
|
126
121
|
signing_key:
|
127
122
|
specification_version: 4
|
128
123
|
summary: stream zip files from rails
|
129
124
|
test_files:
|
130
125
|
- spec/fakefile.txt
|
131
126
|
- spec/lib/zipline/zip_generator_spec.rb
|
127
|
+
- spec/lib/zipline/zipline_spec.rb
|
132
128
|
- spec/spec_helper.rb
|