zipline 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -0
- data/Gemfile +2 -1
- data/README.md +6 -5
- data/Rakefile +2 -0
- data/lib/zipline/version.rb +1 -1
- data/lib/zipline/zip_generator.rb +2 -0
- data/spec/lib/zipline/zip_generator_spec.rb +27 -3
- 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: 9f78131919f81ca6a316cb1f1c7173515a230cee
|
4
|
+
data.tar.gz: 5143037d6d038adf9af45b269f8653f4dd9c1d47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 641f00ccfa244d4a5d7e25cb99aaac1356069e9ed1bdf1ea52da7437f613ebf6cc0a31ba0c707777bf0772c899f24d556e657ee29a39a3672a8841ff5d7ef7d7
|
7
|
+
data.tar.gz: bf7592dc54f890f4aadd6628d814048958308c8f20ea51ff3a34088312f497bc4b882b1b4a6fb8e8728dd03b130130cbb4c72617adc86484a738d9af810d22f6
|
data/.travis.yml
ADDED
data/Gemfile
CHANGED
@@ -4,7 +4,6 @@ source 'https://rubygems.org'
|
|
4
4
|
gemspec
|
5
5
|
|
6
6
|
group :development, :test do
|
7
|
-
gem 'rubyzip', '~> 1.2'
|
8
7
|
gem 'rspec', '~> 3'
|
9
8
|
gem 'fog'
|
10
9
|
gem 'fog-aws'
|
@@ -12,4 +11,6 @@ group :development, :test do
|
|
12
11
|
gem 'aws-sdk'
|
13
12
|
gem 'carrierwave'
|
14
13
|
gem 'paperclip'
|
14
|
+
gem 'rake'
|
15
|
+
gem 'rake-rspec'
|
15
16
|
end
|
data/README.md
CHANGED
@@ -19,11 +19,12 @@ And then execute:
|
|
19
19
|
|
20
20
|
## Usage
|
21
21
|
|
22
|
-
Set up some models with [
|
23
|
-
|
24
|
-
[
|
25
|
-
storage and S3 are supported in the case of
|
26
|
-
[paperclip](https://github.com/thoughtbot/paperclip). [Mutiple file storages](http://shrinerb.com/#external) are
|
22
|
+
Set up some models with [ActiveStorage](http://edgeguides.rubyonrails.org/active_storage_overview.html)
|
23
|
+
[carrierwave](https://github.com/jnicklas/carrierwave), [paperclip](https://github.com/thoughtbot/paperclip), or
|
24
|
+
[shrine](https://github.com/janko-m/shrine). Right now only plain file storage and S3 are supported in the case of
|
25
|
+
[carrierwave](https://github.com/jnicklas/carrierwave) and only plain file storage and S3 are supported in the case of
|
26
|
+
[paperclip](https://github.com/thoughtbot/paperclip). [Mutiple file storages](http://shrinerb.com/#external) are
|
27
|
+
supported with [shrine](https://github.com/janko-m/shrine).
|
27
28
|
|
28
29
|
You'll need to be using puma or some other server that supports streaming output.
|
29
30
|
|
data/Rakefile
CHANGED
data/lib/zipline/version.rb
CHANGED
@@ -44,6 +44,8 @@ module Zipline
|
|
44
44
|
{file: File.open(file.path)}
|
45
45
|
elsif is_io?(file)
|
46
46
|
{file: file}
|
47
|
+
elsif defined?(ActiveStorage::Blob) && file.is_a?(ActiveStorage::Blob)
|
48
|
+
{url: file.service_url}
|
47
49
|
elsif file.respond_to? :url
|
48
50
|
{url: file.url}
|
49
51
|
elsif file.respond_to? :path
|
@@ -2,7 +2,6 @@ require 'spec_helper'
|
|
2
2
|
require 'tempfile'
|
3
3
|
|
4
4
|
describe Zipline::ZipGenerator do
|
5
|
-
|
6
5
|
before { Fog.mock! }
|
7
6
|
let(:file_attributes){ {
|
8
7
|
key: 'fog_file_tests',
|
@@ -67,7 +66,7 @@ describe Zipline::ZipGenerator do
|
|
67
66
|
end
|
68
67
|
end
|
69
68
|
context "Paperclip" do
|
70
|
-
context "Local" do
|
69
|
+
context "Local" do
|
71
70
|
let(:file){ Paperclip::Attachment.new(:name, :instance) }
|
72
71
|
it "creates a File" do
|
73
72
|
allow(file).to receive(:path).and_return('spec/fakefile.txt')
|
@@ -76,7 +75,7 @@ describe Zipline::ZipGenerator do
|
|
76
75
|
expect(normalized[:file]).to be_a File
|
77
76
|
end
|
78
77
|
end
|
79
|
-
context "Remote" do
|
78
|
+
context "Remote" do
|
80
79
|
let(:file){ Paperclip::Attachment.new(:name, :instance, storage: :s3) }
|
81
80
|
it "creates a URL" do
|
82
81
|
allow(file).to receive(:expiring_url).and_return('fakeurl')
|
@@ -85,6 +84,31 @@ describe Zipline::ZipGenerator do
|
|
85
84
|
end
|
86
85
|
end
|
87
86
|
end
|
87
|
+
context "ActiveStorage::Blob" do
|
88
|
+
module ActiveStorage
|
89
|
+
class Filename; end
|
90
|
+
class Blob; end
|
91
|
+
end
|
92
|
+
|
93
|
+
let(:tempfile){ Tempfile.new('t').read }
|
94
|
+
let(:filename) do
|
95
|
+
fn = ActiveStorage::Filename.new()
|
96
|
+
allow(fn).to receive(:to_s).and_return('spec/fakefile.txt')
|
97
|
+
fn
|
98
|
+
end
|
99
|
+
let(:file) do
|
100
|
+
f = ActiveStorage::Blob.new()
|
101
|
+
allow(f).to receive(:filename).and_return(filename)
|
102
|
+
allow(f).to receive(:service_url).and_return('fakeurl')
|
103
|
+
f
|
104
|
+
end
|
105
|
+
it "creates a File" do
|
106
|
+
allow_any_instance_of(Object).to receive(:defined?).and_return(true)
|
107
|
+
normalized = generator.normalize(file)
|
108
|
+
expect(normalized.keys).to include(:url)
|
109
|
+
expect(normalized[:url]).to eq('fakeurl')
|
110
|
+
end
|
111
|
+
end
|
88
112
|
context "Fog" do
|
89
113
|
it "extracts url" do
|
90
114
|
allow(file).to receive(:url).and_return('fakeurl')
|
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.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ram Dobson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: zip_tricks
|
@@ -77,6 +77,7 @@ executables: []
|
|
77
77
|
extensions: []
|
78
78
|
extra_rdoc_files: []
|
79
79
|
files:
|
80
|
+
- ".travis.yml"
|
80
81
|
- Gemfile
|
81
82
|
- LICENSE
|
82
83
|
- README.md
|