kt-paperclip 6.3.0 → 6.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/FUNDING.yml +3 -0
- data/.hound.yml +1 -1
- data/.travis.yml +7 -0
- data/README.md +1 -1
- data/lib/paperclip/io_adapters/http_url_proxy_adapter.rb +2 -2
- data/lib/paperclip/io_adapters/uri_adapter.rb +13 -3
- data/lib/paperclip/schema.rb +2 -2
- data/lib/paperclip/url_generator.rb +8 -1
- data/lib/paperclip/version.rb +1 -1
- data/paperclip.gemspec +1 -1
- data/spec/paperclip/io_adapters/http_url_proxy_adapter_spec.rb +20 -15
- data/spec/paperclip/io_adapters/uri_adapter_spec.rb +13 -3
- data/spec/paperclip/storage/s3_spec.rb +1 -3
- data/spec/paperclip/url_generator_spec.rb +10 -0
- data/spec/support/model_reconstruction.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5feef0e82a301e5ec7bface30f82007d82864dbad49f6ffe9f521522dc4cbf42
|
4
|
+
data.tar.gz: 2f0e12df815225d400486c6dbe8779ab9eb665afca82f529c0a94fcd7c607ab5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ded6bae6f8422c9f51aa9ec0d0b098af61f0a502468550afcbfece6e9516e1e4ce4d8b7989f472c92802cdbb17fa5dd33d98c5372161728b22c6ab57801304d
|
7
|
+
data.tar.gz: d3562d3f7e7e5fd35535972157e5d668ad9f2294db4d906e2307227c5c648c63dff231d28809df6d1a670a69f0c21d1e661fa8c0e475256bd8168f8bacb3b233
|
data/.github/FUNDING.yml
ADDED
data/.hound.yml
CHANGED
@@ -1040,7 +1040,7 @@ Lint/UselessAssignment:
|
|
1040
1040
|
Description: Checks for useless assignment to a local variable.
|
1041
1041
|
StyleGuide: https://github.com/bbatsov/ruby-style-guide#underscore-unused-vars
|
1042
1042
|
Enabled: true
|
1043
|
-
Lint/
|
1043
|
+
Lint/BinaryOperatorWithIdenticalOperands:
|
1044
1044
|
Description: Checks for comparison of something with itself.
|
1045
1045
|
Enabled: true
|
1046
1046
|
Lint/UselessElseWithoutRescue:
|
data/.travis.yml
CHANGED
@@ -6,6 +6,7 @@ rvm:
|
|
6
6
|
- 2.4
|
7
7
|
- 2.5
|
8
8
|
- 2.6
|
9
|
+
- 2.7
|
9
10
|
|
10
11
|
script: "bundle exec rake clean spec cucumber"
|
11
12
|
|
@@ -36,3 +37,9 @@ matrix:
|
|
36
37
|
rvm: 2.3
|
37
38
|
- gemfile: gemfiles/6.0.gemfile
|
38
39
|
rvm: 2.4
|
40
|
+
- gemfile: gemfiles/4.2.gemfile
|
41
|
+
rvm: 2.7
|
42
|
+
- gemfile: gemfiles/5.0.gemfile
|
43
|
+
rvm: 2.7
|
44
|
+
- gemfile: gemfiles/5.1.gemfile
|
45
|
+
rvm: 2.7
|
data/README.md
CHANGED
@@ -171,7 +171,7 @@ Paperclip is distributed as a gem, which is how it should be used in your app.
|
|
171
171
|
Include the gem in your Gemfile:
|
172
172
|
|
173
173
|
```ruby
|
174
|
-
gem "kt-paperclip", "~> 6.
|
174
|
+
gem "kt-paperclip", "~> 6.3"
|
175
175
|
```
|
176
176
|
|
177
177
|
Or, if you want to get the latest, you can get master from the main paperclip repository:
|
@@ -9,8 +9,8 @@ module Paperclip
|
|
9
9
|
REGEXP = /\Ahttps?:\/\//.freeze
|
10
10
|
|
11
11
|
def initialize(target, options = {})
|
12
|
-
escaped =
|
13
|
-
super(URI(target ==
|
12
|
+
escaped = Paperclip::UrlGenerator.escape(target)
|
13
|
+
super(URI(target == Paperclip::UrlGenerator.unescape(target) ? escaped : target), options)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -50,10 +50,20 @@ module Paperclip
|
|
50
50
|
"index.html"
|
51
51
|
end
|
52
52
|
|
53
|
-
|
54
|
-
|
53
|
+
if RUBY_VERSION < '2.5'
|
54
|
+
def download_content
|
55
|
+
options = { read_timeout: Paperclip.options[:read_timeout] }.compact
|
55
56
|
|
56
|
-
|
57
|
+
# rubocop:disable Security/Open
|
58
|
+
open(@target, options)
|
59
|
+
# rubocop:enable Security/Open
|
60
|
+
end
|
61
|
+
else
|
62
|
+
def download_content
|
63
|
+
options = { read_timeout: Paperclip.options[:read_timeout] }.compact
|
64
|
+
|
65
|
+
URI.open(@target, options)
|
66
|
+
end
|
57
67
|
end
|
58
68
|
|
59
69
|
def copy_to_tempfile(src)
|
data/lib/paperclip/schema.rb
CHANGED
@@ -26,7 +26,7 @@ module Paperclip
|
|
26
26
|
attachment_names.each do |attachment_name|
|
27
27
|
COLUMNS.each_pair do |column_name, column_type|
|
28
28
|
column_options = options.merge(options[column_name.to_sym] || {})
|
29
|
-
add_column(table_name, "#{attachment_name}_#{column_name}", column_type, column_options)
|
29
|
+
add_column(table_name, "#{attachment_name}_#{column_name}", column_type, **column_options)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
@@ -55,7 +55,7 @@ module Paperclip
|
|
55
55
|
attachment_names.each do |attachment_name|
|
56
56
|
COLUMNS.each_pair do |column_name, column_type|
|
57
57
|
column_options = options.merge(options[column_name.to_sym] || {})
|
58
|
-
column("#{attachment_name}_#{column_name}", column_type, column_options)
|
58
|
+
column("#{attachment_name}_#{column_name}", column_type, **column_options)
|
59
59
|
end
|
60
60
|
end
|
61
61
|
end
|
@@ -3,6 +3,13 @@ require "active_support/core_ext/module/delegation"
|
|
3
3
|
|
4
4
|
module Paperclip
|
5
5
|
class UrlGenerator
|
6
|
+
class << self
|
7
|
+
def encoder
|
8
|
+
@encoder ||= URI::RFC2396_Parser.new
|
9
|
+
end
|
10
|
+
delegate :escape, :unescape, to: :encoder
|
11
|
+
end
|
12
|
+
|
6
13
|
def initialize(attachment)
|
7
14
|
@attachment = attachment
|
8
15
|
end
|
@@ -65,7 +72,7 @@ module Paperclip
|
|
65
72
|
if url.respond_to?(:escape)
|
66
73
|
url.escape
|
67
74
|
else
|
68
|
-
|
75
|
+
self.class.escape(url).gsub(escape_regex) { |m| "%#{m.ord.to_s(16).upcase}" }
|
69
76
|
end
|
70
77
|
end
|
71
78
|
|
data/lib/paperclip/version.rb
CHANGED
data/paperclip.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.platform = Gem::Platform::RUBY
|
8
8
|
s.author = "Surendra Singhi"
|
9
9
|
s.email = ["ssinghi@kreeti.com"]
|
10
|
-
s.homepage = "https://github.com/kreeti/paperclip"
|
10
|
+
s.homepage = "https://github.com/kreeti/kt-paperclip"
|
11
11
|
s.summary = "File attachments as attributes for ActiveRecord"
|
12
12
|
s.description = "Easy upload management for ActiveRecord"
|
13
13
|
s.license = "MIT"
|
@@ -16,54 +16,59 @@ describe Paperclip::HttpUrlProxyAdapter do
|
|
16
16
|
context "a new instance" do
|
17
17
|
before do
|
18
18
|
@url = "http://thoughtbot.com/images/thoughtbot-logo.png"
|
19
|
-
@subject = Paperclip.io_adapters.for(@url, hash_digest: Digest::MD5)
|
20
19
|
end
|
21
20
|
|
21
|
+
subject { Paperclip.io_adapters.for(@url, hash_digest: Digest::MD5) }
|
22
|
+
|
22
23
|
after do
|
23
|
-
|
24
|
+
subject.close
|
24
25
|
end
|
25
26
|
|
26
27
|
it "returns a file name" do
|
27
|
-
|
28
|
+
expect(subject.original_filename).to(eq("thoughtbot-logo.png"))
|
28
29
|
end
|
29
30
|
|
30
31
|
it "closes open handle after reading" do
|
31
|
-
|
32
|
+
expect { subject }.to(change { @open_return.closed? }.from(false).to(true))
|
32
33
|
end
|
33
34
|
|
34
35
|
it "returns a content type" do
|
35
|
-
|
36
|
+
expect(subject.content_type).to(eq("image/png"))
|
36
37
|
end
|
37
38
|
|
38
39
|
it "returns the size of the data" do
|
39
|
-
|
40
|
+
expect(subject.size).to(eq(@open_return.size))
|
40
41
|
end
|
41
42
|
|
42
43
|
it "generates an MD5 hash of the contents" do
|
43
|
-
|
44
|
+
expect(subject.fingerprint).to(eq(Digest::MD5.hexdigest("xxx")))
|
44
45
|
end
|
45
46
|
|
46
47
|
it "generates correct fingerprint after read" do
|
47
|
-
fingerprint = Digest::MD5.hexdigest(
|
48
|
-
|
48
|
+
fingerprint = Digest::MD5.hexdigest(subject.read)
|
49
|
+
expect(subject.fingerprint).to(eq(fingerprint))
|
49
50
|
end
|
50
51
|
|
51
52
|
it "generates same fingerprint" do
|
52
|
-
|
53
|
+
expect(subject.fingerprint).to(eq(subject.fingerprint))
|
53
54
|
end
|
54
55
|
|
55
56
|
it "returns the data contained in the StringIO" do
|
56
|
-
|
57
|
+
expect(subject.read).to(eq("xxx"))
|
57
58
|
end
|
58
59
|
|
59
60
|
it "accepts a content_type" do
|
60
|
-
|
61
|
-
|
61
|
+
subject.content_type = "image/png"
|
62
|
+
expect(subject.content_type).to(eq("image/png"))
|
62
63
|
end
|
63
64
|
|
64
65
|
it "accepts an original_filename" do
|
65
|
-
|
66
|
-
|
66
|
+
subject.original_filename = "image.png"
|
67
|
+
expect(subject.original_filename).to(eq("image.png"))
|
68
|
+
end
|
69
|
+
|
70
|
+
it "doesn't emit deprecation warnings" do
|
71
|
+
expect { subject }.to_not(output(/URI\.(un)?escape is obsolete/).to_stderr)
|
67
72
|
end
|
68
73
|
end
|
69
74
|
|
@@ -193,9 +193,18 @@ describe Paperclip::UriAdapter do
|
|
193
193
|
|
194
194
|
describe "#download_content" do
|
195
195
|
before do
|
196
|
-
|
196
|
+
allowed_mock =
|
197
|
+
if RUBY_VERSION < '2.5'
|
198
|
+
allow_any_instance_of(Paperclip::UriAdapter)
|
199
|
+
else
|
200
|
+
allow(URI)
|
201
|
+
end
|
202
|
+
|
203
|
+
allowed_mock.to receive(:open).and_return(@open_return)
|
204
|
+
|
197
205
|
@uri = URI.parse("https://github.com/thoughtbot/paper:clip.jpg")
|
198
206
|
@subject = Paperclip.io_adapters.for(@uri)
|
207
|
+
@uri_opener = RUBY_VERSION < '2.5' ? @subject : URI
|
199
208
|
end
|
200
209
|
|
201
210
|
after do
|
@@ -204,7 +213,7 @@ describe Paperclip::UriAdapter do
|
|
204
213
|
|
205
214
|
context "with default read_timeout" do
|
206
215
|
it "calls open without options" do
|
207
|
-
expect(@
|
216
|
+
expect(@uri_opener).to receive(:open).with(@uri, {}).at_least(1).times
|
208
217
|
end
|
209
218
|
end
|
210
219
|
|
@@ -214,7 +223,8 @@ describe Paperclip::UriAdapter do
|
|
214
223
|
end
|
215
224
|
|
216
225
|
it "calls open with read_timeout option" do
|
217
|
-
expect(@
|
226
|
+
expect(@uri_opener)
|
227
|
+
.to receive(:open).with(@uri, read_timeout: 120).at_least(1).times
|
218
228
|
end
|
219
229
|
end
|
220
230
|
end
|
@@ -194,6 +194,16 @@ describe Paperclip::UrlGenerator do
|
|
194
194
|
"expected the interpolator to be passed #{expected.inspect} but it wasn't"
|
195
195
|
end
|
196
196
|
|
197
|
+
it "doesn't emit deprecation warnings" do
|
198
|
+
expected = "the expected result"
|
199
|
+
mock_interpolator = MockInterpolator.new(result: expected)
|
200
|
+
options = { interpolator: mock_interpolator }
|
201
|
+
mock_attachment = MockAttachment.new(options)
|
202
|
+
url_generator = Paperclip::UrlGenerator.new(mock_attachment)
|
203
|
+
|
204
|
+
expect { url_generator.for(:style_name, escape: true) }.to_not(output(/URI\.(un)?escape is obsolete/).to_stderr)
|
205
|
+
end
|
206
|
+
|
197
207
|
describe "should be able to escape (, ), [, and ]." do
|
198
208
|
def generate(expected, updated_at = nil)
|
199
209
|
mock_interpolator = MockInterpolator.new(result: expected)
|
@@ -28,7 +28,7 @@ module ModelReconstruction
|
|
28
28
|
|
29
29
|
def reset_table(_table_name, &block)
|
30
30
|
block ||= lambda { |_table| true }
|
31
|
-
ActiveRecord::Base.connection.create_table :dummies, { force: true }, &block
|
31
|
+
ActiveRecord::Base.connection.create_table :dummies, **{ force: true }, &block
|
32
32
|
end
|
33
33
|
|
34
34
|
def modify_table(&block)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kt-paperclip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.
|
4
|
+
version: 6.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Surendra Singhi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -354,6 +354,7 @@ extensions: []
|
|
354
354
|
extra_rdoc_files: []
|
355
355
|
files:
|
356
356
|
- ".codeclimate.yml"
|
357
|
+
- ".github/FUNDING.yml"
|
357
358
|
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
358
359
|
- ".github/ISSUE_TEMPLATE/custom.md"
|
359
360
|
- ".github/ISSUE_TEMPLATE/feature_request.md"
|
@@ -546,7 +547,7 @@ files:
|
|
546
547
|
- spec/support/reporting.rb
|
547
548
|
- spec/support/test_data.rb
|
548
549
|
- spec/support/version_helper.rb
|
549
|
-
homepage: https://github.com/kreeti/paperclip
|
550
|
+
homepage: https://github.com/kreeti/kt-paperclip
|
550
551
|
licenses:
|
551
552
|
- MIT
|
552
553
|
metadata: {}
|
@@ -583,8 +584,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
583
584
|
version: '0'
|
584
585
|
requirements:
|
585
586
|
- ImageMagick
|
586
|
-
|
587
|
-
rubygems_version: 2.7.9
|
587
|
+
rubygems_version: 3.0.1
|
588
588
|
signing_key:
|
589
589
|
specification_version: 4
|
590
590
|
summary: File attachments as attributes for ActiveRecord
|