zipline 1.2.1 → 1.3.0

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
- SHA1:
3
- metadata.gz: 60e9847b29f301c7d2a2b7ff9614454f0e3a1193
4
- data.tar.gz: b9b391b9478f96f0fa067918e4368a5415332123
2
+ SHA256:
3
+ metadata.gz: 8de63c7a8518461b8fdbb249ce857b3f06ffc2bf3a7de69d6d5d6c5111f75015
4
+ data.tar.gz: edfc26eed9a1d52987a4d47330a015d2ebb0e3129f2c0791199a51b3b5abec70
5
5
  SHA512:
6
- metadata.gz: e25c8bba3c7b7d6c093637c1323d0a4bb6660e94457e4445cc3e6798f7125e8c5c0b99a334de0430ef4ced180e00a4001c29b6ab9c92525dd0a6eca689b0dbe7
7
- data.tar.gz: db9b45bfb987cf97f025c4c2cbeb818a821bd7968524df56ac44d6eaebea4b8420b634815b6a6cde8ff32976e67b20183f8dfa404a0ffa05b91aef824c645a79
6
+ metadata.gz: cc54e592ebd7c24cad03669786938a3662430389e81322ceef258898ec5d8e9949db956a7433ab7c4d139b4671100772c062c525f8d20b6782f3a221b80ea9f3
7
+ data.tar.gz: 2482828adb931c9630c209b7a9a06c913b43d577232dea8d877b88acb1fa3b60834c35a92175608610da0d7e80ad36d6a1f8cd2379b9af5a249ce2b1f7456990
@@ -1,8 +1,8 @@
1
1
  language: ruby
2
2
  cache: bundler
3
3
  rvm:
4
- - 2.3
5
4
  - 2.4
6
5
  - 2.5
7
6
  - 2.6
8
7
  - 2.7
8
+ - 3.0
data/Gemfile CHANGED
@@ -5,12 +5,10 @@ gemspec
5
5
 
6
6
  group :development, :test do
7
7
  gem 'rspec', '~> 3'
8
- gem 'fog'
9
8
  gem 'fog-aws'
10
9
  gem 'activesupport'
11
- gem 'aws-sdk'
10
+ gem 'aws-sdk-s3'
12
11
  gem 'carrierwave'
13
12
  gem 'paperclip'
14
13
  gem 'rake'
15
- gem 'rake-rspec'
16
14
  end
data/Rakefile CHANGED
@@ -1,4 +1,12 @@
1
1
  #!/usr/bin/env rake
2
2
  require "bundler/gem_tasks"
3
- require "rake/rspec"
4
- task :default => :spec
3
+
4
+ begin
5
+ require 'rspec/core/rake_task'
6
+
7
+ RSpec::Core::RakeTask.new(:spec)
8
+
9
+ task default: :spec
10
+ rescue LoadError
11
+ # no rspec available
12
+ end
@@ -1,3 +1,3 @@
1
1
  module Zipline
2
- VERSION = "1.2.1"
2
+ VERSION = "1.3.0"
3
3
  end
@@ -14,11 +14,27 @@ module Zipline
14
14
 
15
15
  def each(&block)
16
16
  fake_io_writer = ZipTricks::BlockWrite.new(&block)
17
- ZipTricks::Streamer.open(fake_io_writer) do |streamer|
17
+ # ZipTricks outputs lots of strings in rapid succession, and with
18
+ # servers it can be beneficial to avoid doing too many tiny writes so that
19
+ # the number of syscalls is minimized. See https://github.com/WeTransfer/zip_tricks/issues/78
20
+ # There is a built-in facility for this in ZipTricks which can be used to implement
21
+ # some cheap buffering here (it exists both in version 4 and version 5). The buffer is really
22
+ # tiny and roughly equal to the medium Linux socket buffer size (16 KB). Although output
23
+ # will be not so immediate with this buffering the overall performance will be better,
24
+ # especially with multiple clients being serviced at the same time.
25
+ # Note that the WriteBuffer writes the same, retained String object - but the contents
26
+ # of that object changes between calls. This should work fine with servers where the
27
+ # contents of the string gets written to a socket immediately before the execution inside
28
+ # the WriteBuffer resumes), but if the strings get retained somewhere - like in an Array -
29
+ # this might pose a problem. Unlikely that it will be an issue here though.
30
+ write_buffer_size = 16 * 1024
31
+ write_buffer = ZipTricks::WriteBuffer.new(fake_io_writer, write_buffer_size)
32
+ ZipTricks::Streamer.open(write_buffer) do |streamer|
18
33
  @files.each do |file, name, options = {}|
19
- handle_file(streamer, file, name, options)
34
+ handle_file(streamer, file, name.to_s, options)
20
35
  end
21
36
  end
37
+ write_buffer.flush! # for any remaining writes
22
38
  end
23
39
 
24
40
  def handle_file(streamer, file, name, options)
@@ -1,6 +1,23 @@
1
1
  require 'spec_helper'
2
2
  require 'tempfile'
3
3
 
4
+ module ActiveStorage
5
+ class Attached
6
+ class One < Attached
7
+ end
8
+ end
9
+ class Attachment; end
10
+ class Blob; end
11
+ class Filename
12
+ def initialize(name)
13
+ @name = name
14
+ end
15
+ def to_s
16
+ @name
17
+ end
18
+ end
19
+ end
20
+
4
21
  describe Zipline::ZipGenerator do
5
22
  before { Fog.mock! }
6
23
  let(:file_attributes){ {
@@ -85,15 +102,6 @@ describe Zipline::ZipGenerator do
85
102
  end
86
103
  end
87
104
  context "ActiveStorage" do
88
- module ActiveStorage
89
- class Attached
90
- class One < Attached
91
- end
92
- end
93
- class Attachment; end
94
- class Blob; end
95
- end
96
-
97
105
  context "Attached::One" do
98
106
  it "get blob" do
99
107
  attached = create_attached_one
@@ -147,8 +155,15 @@ describe Zipline::ZipGenerator do
147
155
  def create_blob
148
156
  blob = ActiveStorage::Blob.new
149
157
  allow(blob).to receive(:service_url).and_return('fakeurl')
158
+ filename = create_filename
159
+ allow(blob).to receive(:filename).and_return(filename)
150
160
  blob
151
161
  end
162
+
163
+ def create_filename
164
+ # Rails wraps Blob#filname in this class since Rails 5.2
165
+ ActiveStorage::Filename.new('test')
166
+ end
152
167
  end
153
168
  context "Fog" do
154
169
  it "extracts url" do
@@ -171,6 +186,25 @@ describe Zipline::ZipGenerator do
171
186
  end
172
187
  end
173
188
 
189
+ describe '.write_file' do
190
+ let(:file) { StringIO.new('passthrough') }
191
+
192
+ context 'when passing an ActiveStorage::Filename object as filename' do
193
+ let(:filename) { ActiveStorage::Filename.new('test') }
194
+
195
+ let(:generator) do
196
+ Zipline::ZipGenerator.new([[file, filename]])
197
+ end
198
+
199
+ it 'passes a string as filename to ZipTricks' do
200
+ allow(file).to receive(:url).and_return('fakeurl')
201
+ expect_any_instance_of(ZipTricks::Streamer).to receive(:write_deflated_file)
202
+ .with('test', {})
203
+ generator.each { |_| 'Test' }
204
+ end
205
+ end
206
+ end
207
+
174
208
  describe 'passing an options hash' do
175
209
  let(:file) { StringIO.new('passthrough') }
176
210
 
@@ -2,9 +2,7 @@ require 'rspec'
2
2
  require 'active_support'
3
3
  require 'active_support/core_ext'
4
4
  require 'zipline'
5
- require 'aws-sdk'
6
5
  require 'paperclip'
7
- require 'fog'
8
6
  require 'fog-aws'
9
7
  require 'carrierwave'
10
8
 
@@ -21,8 +19,6 @@ CarrierWave.configure do |config|
21
19
 
22
20
  end
23
21
 
24
-
25
-
26
22
  RSpec.configure do |config|
27
23
  config.color = true
28
24
  config.order = :random
@@ -16,6 +16,6 @@ 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
20
  gem.add_dependency 'zip_tricks', ['>= 4.2.1', '< 6.0']
20
- gem.add_dependency 'rails', ['>= 3.2.1', '< 6.1']
21
21
  end
metadata CHANGED
@@ -1,55 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zipline
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ram Dobson
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-25 00:00:00.000000000 Z
11
+ date: 2021-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: zip_tricks
14
+ name: actionpack
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 4.2.1
19
+ version: 3.2.1
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '6.0'
22
+ version: '7.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: 4.2.1
29
+ version: 3.2.1
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '6.0'
32
+ version: '7.0'
33
33
  - !ruby/object:Gem::Dependency
34
- name: rails
34
+ name: zip_tricks
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: 3.2.1
39
+ version: 4.2.1
40
40
  - - "<"
41
41
  - !ruby/object:Gem::Version
42
- version: '6.1'
42
+ version: '6.0'
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
46
46
  requirements:
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: 3.2.1
49
+ version: 4.2.1
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
- version: '6.1'
52
+ version: '6.0'
53
53
  description: a module for streaming dynamically generated zip files
54
54
  email:
55
55
  - ram.dobson@solsystemscompany.com
@@ -73,7 +73,7 @@ homepage: http://github.com/fringd/zipline
73
73
  licenses:
74
74
  - MIT
75
75
  metadata: {}
76
- post_install_message:
76
+ post_install_message:
77
77
  rdoc_options: []
78
78
  require_paths:
79
79
  - lib
@@ -88,9 +88,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  requirements: []
91
- rubyforge_project:
92
- rubygems_version: 2.6.14
93
- signing_key:
91
+ rubygems_version: 3.2.3
92
+ signing_key:
94
93
  specification_version: 4
95
94
  summary: stream zip files from rails
96
95
  test_files: