zipline 1.3.0 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8de63c7a8518461b8fdbb249ce857b3f06ffc2bf3a7de69d6d5d6c5111f75015
4
- data.tar.gz: edfc26eed9a1d52987a4d47330a015d2ebb0e3129f2c0791199a51b3b5abec70
3
+ metadata.gz: b56c703c9733a9c781d4d81eb83826a8de4a647238a83d9ade835fa034c8a84c
4
+ data.tar.gz: 0f1cd2b80086cb0a3fcd572aa18d03f03228820870f93b8ec9da7cb6591c165c
5
5
  SHA512:
6
- metadata.gz: cc54e592ebd7c24cad03669786938a3662430389e81322ceef258898ec5d8e9949db956a7433ab7c4d139b4671100772c062c525f8d20b6782f3a221b80ea9f3
7
- data.tar.gz: 2482828adb931c9630c209b7a9a06c913b43d577232dea8d877b88acb1fa3b60834c35a92175608610da0d7e80ad36d6a1f8cd2379b9af5a249ce2b1f7456990
6
+ metadata.gz: 0b97a0e674b144d21eeacf5ed955dcf1e62639479f63e73c988d405d3ed707c8d45e64f33bf3bb98eeebc4fabeacf991f2e60c5c23367152a677e2a9e616e43c
7
+ data.tar.gz: e54fb0c40ad64959b1c1965a45312aafa5fe0fa6547d626f54795dab8027c0208a4550589fb933266620c0e00d98eb1685daede1b3395539da81f2bf24887a85
@@ -0,0 +1,27 @@
1
+ name: Tests
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ test:
7
+ name: Test (${{ matrix.ruby-version }})
8
+ runs-on: ubuntu-latest
9
+
10
+ strategy:
11
+ fail-fast: false
12
+ matrix:
13
+ ruby-version:
14
+ - head
15
+ - '3.1'
16
+ - '3.0'
17
+ - '2.7'
18
+
19
+ steps:
20
+ - uses: actions/checkout@v2
21
+ - name: Set up Ruby ${{ matrix.ruby-version }}
22
+ uses: ruby/setup-ruby@v1
23
+ with:
24
+ ruby-version: ${{ matrix.ruby-version }}
25
+ bundler-cache: true # 'bundle install' and cache
26
+ - name: Run tests
27
+ run: bundle exec rake
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # Zipline
2
- [![Build Status](https://travis-ci.org/fringd/zipline.svg?branch=master)](https://travis-ci.org/fringd/zipline)
2
+ [![Tests](https://github.com/fringd/zipline/actions/workflows/ci.yml/badge.svg)](https://github.com/fringd/zipline/actions/workflows/ci.yml)
3
3
  [![Gem Version](https://badge.fury.io/rb/zipline.svg)](https://badge.fury.io/rb/zipline)
4
4
 
5
5
  A gem to stream dynamically generated zip files from a rails application. Unlike other solutions that generate zips for user download, zipline does not wait for the entire zip file to be created (or even for the entire input file in the cloud to be downloaded) before it begins sending the zip file to the user. It does this by never seeking backwards during zip creation, and streaming the zip file over http as it is constructed. The advantages of this are:
@@ -1,3 +1,3 @@
1
1
  module Zipline
2
- VERSION = "1.3.0"
2
+ VERSION = "1.4.1"
3
3
  end
@@ -80,7 +80,7 @@ module Zipline
80
80
  end
81
81
 
82
82
  def write_file(streamer, file, name, options)
83
- streamer.write_deflated_file(name, options) do |writer_for_file|
83
+ streamer.write_deflated_file(name, **options.slice(:modification_time)) do |writer_for_file|
84
84
  if file[:url]
85
85
  the_remote_uri = URI(file[:url])
86
86
 
data/lib/zipline.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'content_disposition'
1
2
  require "zipline/version"
2
3
  require 'zip_tricks'
3
4
  require "zipline/zip_generator"
@@ -13,7 +14,7 @@ require "zipline/zip_generator"
13
14
  module Zipline
14
15
  def zipline(files, zipname = 'zipline.zip')
15
16
  zip_generator = ZipGenerator.new(files)
16
- headers['Content-Disposition'] = "attachment; filename=\"#{zipname.gsub '"', '\"'}\""
17
+ headers['Content-Disposition'] = ContentDisposition.format(disposition: 'attachment', filename: zipname)
17
18
  headers['Content-Type'] = Mime::Type.lookup_by_extension('zip').to_s
18
19
  response.sending_file = true
19
20
  response.cache_control[:public] ||= false
@@ -199,7 +199,7 @@ describe Zipline::ZipGenerator do
199
199
  it 'passes a string as filename to ZipTricks' do
200
200
  allow(file).to receive(:url).and_return('fakeurl')
201
201
  expect_any_instance_of(ZipTricks::Streamer).to receive(:write_deflated_file)
202
- .with('test', {})
202
+ .with('test')
203
203
  generator.each { |_| 'Test' }
204
204
  end
205
205
  end
@@ -220,7 +220,7 @@ describe Zipline::ZipGenerator do
220
220
  generator.each { |_| 'Test' }
221
221
  end
222
222
 
223
- it 'passes the options hash to ZipTricks' do
223
+ it 'passes the options hash to ZipTricks as kwargs' do
224
224
  allow(file).to receive(:url).and_return('fakeurl')
225
225
  expect_any_instance_of(ZipTricks::Streamer).to receive(:write_deflated_file)
226
226
  .with(anything, modification_time: mtime)
@@ -239,10 +239,30 @@ describe Zipline::ZipGenerator do
239
239
  generator.each { |_| 'Test' }
240
240
  end
241
241
 
242
- it 'passes the options hash to ZipTricks' do
242
+ it 'passes the options hash to ZipTricks as kwargs' do
243
243
  allow(file).to receive(:url).and_return('fakeurl')
244
244
  expect_any_instance_of(ZipTricks::Streamer).to receive(:write_deflated_file)
245
- .with(anything, {})
245
+ .with(anything)
246
+ generator.each { |_| 'Test' }
247
+ end
248
+ end
249
+
250
+ context 'with extra invalid options' do
251
+ let(:mtime) { 1.day.ago }
252
+ let(:generator) do
253
+ Zipline::ZipGenerator.new([[file, 'test', modification_time: mtime, extra: 'invalid']])
254
+ end
255
+
256
+ it 'passes the whole options hash through handle_file' do
257
+ expect(generator).to receive(:handle_file)
258
+ .with(anything, anything, anything, { modification_time: mtime, extra: 'invalid' })
259
+ generator.each { |_| 'Test' }
260
+ end
261
+
262
+ it 'only passes the kwargs to ZipTricks that it expects (i.e., :modification_time)' do
263
+ allow(file).to receive(:url).and_return('fakeurl')
264
+ expect_any_instance_of(ZipTricks::Streamer).to receive(:write_deflated_file)
265
+ .with(anything, modification_time: mtime)
246
266
  generator.each { |_| 'Test' }
247
267
  end
248
268
  end
data/zipline.gemspec CHANGED
@@ -16,6 +16,12 @@ Gem::Specification.new do |gem|
16
16
  gem.version = Zipline::VERSION
17
17
  gem.licenses = ['MIT']
18
18
 
19
- gem.add_dependency 'actionpack', ['>= 3.2.1', '< 7.0']
19
+ gem.required_ruby_version = ">= 2.7"
20
+
21
+ gem.add_dependency 'actionpack', ['>= 6.0', '< 8.0']
22
+ gem.add_dependency 'content_disposition', '~> 1.0'
20
23
  gem.add_dependency 'zip_tricks', ['>= 4.2.1', '< 6.0']
24
+
25
+ # https://github.com/rspec/rspec-mocks/issues/1457
26
+ gem.add_development_dependency 'rspec-mocks', ['~> 3.10', '!= 3.10.3']
21
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.3.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ram Dobson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-25 00:00:00.000000000 Z
11
+ date: 2022-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -16,20 +16,34 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 3.2.1
19
+ version: '6.0'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '7.0'
22
+ version: '8.0'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: 3.2.1
29
+ version: '6.0'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '7.0'
32
+ version: '8.0'
33
+ - !ruby/object:Gem::Dependency
34
+ name: content_disposition
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.0'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.0'
33
47
  - !ruby/object:Gem::Dependency
34
48
  name: zip_tricks
35
49
  requirement: !ruby/object:Gem::Requirement
@@ -50,6 +64,26 @@ dependencies:
50
64
  - - "<"
51
65
  - !ruby/object:Gem::Version
52
66
  version: '6.0'
67
+ - !ruby/object:Gem::Dependency
68
+ name: rspec-mocks
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - "~>"
72
+ - !ruby/object:Gem::Version
73
+ version: '3.10'
74
+ - - "!="
75
+ - !ruby/object:Gem::Version
76
+ version: 3.10.3
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '3.10'
84
+ - - "!="
85
+ - !ruby/object:Gem::Version
86
+ version: 3.10.3
53
87
  description: a module for streaming dynamically generated zip files
54
88
  email:
55
89
  - ram.dobson@solsystemscompany.com
@@ -57,7 +91,7 @@ executables: []
57
91
  extensions: []
58
92
  extra_rdoc_files: []
59
93
  files:
60
- - ".travis.yml"
94
+ - ".github/workflows/ci.yml"
61
95
  - Gemfile
62
96
  - LICENSE
63
97
  - README.md
@@ -81,7 +115,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
81
115
  requirements:
82
116
  - - ">="
83
117
  - !ruby/object:Gem::Version
84
- version: '0'
118
+ version: '2.7'
85
119
  required_rubygems_version: !ruby/object:Gem::Requirement
86
120
  requirements:
87
121
  - - ">="
data/.travis.yml DELETED
@@ -1,8 +0,0 @@
1
- language: ruby
2
- cache: bundler
3
- rvm:
4
- - 2.4
5
- - 2.5
6
- - 2.6
7
- - 2.7
8
- - 3.0