kt-paperclip 6.4.0 → 6.4.2

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: ff919875bc708cb71a8aa4d23b799de1d78db5bcc9b3ea67681d3a8bde2b52f8
4
- data.tar.gz: 4c68f86a643f7dd52ed167a8e1b447770fdd8bea4c9a462265e42fefca235125
3
+ metadata.gz: 7cff96583dd89dcd0254140d27f4b8043137acd917c804d7710367d719342119
4
+ data.tar.gz: 27c6a63b58e72a52ec6ea87e82267d0a3ddb87815333295618d8d179c5c52d45
5
5
  SHA512:
6
- metadata.gz: 7646e2ae1e2770a48d322d765ace1b0afcea3d4d0da1c2cceab6d97a70e2c562d6c115532373723152f2bd2a2e028a4c68739d5ef5b3e699d9a502c148c0bdc2
7
- data.tar.gz: c6cebbef6816c9b987a4806a7a1581b213e882d7f8179fb19845f80650622253f27e2a85412ca61743153295ccd09863ac676bbec2a7771555eb750703458a20
6
+ metadata.gz: c37f46113c6c74e4e862b287174873f58d467adcfaee18766738c87eaa1757deac8363810883b3b0ae604d4cfa8b1223ec7edbe3af9687972c7ba53cc62578ab
7
+ data.tar.gz: 8cc931814748df871550746bb8798cc06bc018285659f4ddf07632d24d72fa374f867b840a7aa776da957821755cbe869a130abd77ce75636b71a6f5a9df14ed
@@ -50,10 +50,20 @@ module Paperclip
50
50
  "index.html"
51
51
  end
52
52
 
53
- def download_content
54
- options = { read_timeout: Paperclip.options[:read_timeout] }.compact
53
+ if RUBY_VERSION < '2.5'
54
+ def download_content
55
+ options = { read_timeout: Paperclip.options[:read_timeout] }.compact
55
56
 
56
- self.open(@target, options)
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)
@@ -47,7 +47,7 @@ module Paperclip
47
47
  end
48
48
 
49
49
  def mark_invalid(record, attribute, types)
50
- record.errors.add attribute, :invalid, options.merge(types: types.join(", "))
50
+ record.errors.add attribute, :invalid, **options.merge(types: types.join(", "))
51
51
  end
52
52
 
53
53
  def allowed_types
@@ -43,7 +43,7 @@ module Paperclip
43
43
  end
44
44
 
45
45
  def mark_invalid(record, attribute, patterns)
46
- record.errors.add attribute, :invalid, options.merge(names: patterns.join(", "))
46
+ record.errors.add attribute, :invalid, **options.merge(names: patterns.join(", "))
47
47
  end
48
48
 
49
49
  def allowed
@@ -4,7 +4,7 @@ module Paperclip
4
4
  module Validators
5
5
  class AttachmentPresenceValidator < ActiveModel::EachValidator
6
6
  def validate_each(record, attribute, _value)
7
- record.errors.add(attribute, :blank, options) if record.send("#{attribute}_file_name").blank?
7
+ record.errors.add(attribute, :blank, **options) if record.send("#{attribute}_file_name").blank?
8
8
  end
9
9
 
10
10
  def self.helper_method_name
@@ -39,7 +39,7 @@ module Paperclip
39
39
  unless value.send(CHECKS[option], option_value)
40
40
  error_message_key = options[:in] ? :in_between : option
41
41
  error_attrs.each do |error_attr_name|
42
- record.errors.add(error_attr_name, error_message_key, filtered_options(value).merge(
42
+ record.errors.add(error_attr_name, error_message_key, **filtered_options(value).merge(
43
43
  min: min_value_in_human_size(record),
44
44
  max: max_value_in_human_size(record),
45
45
  count: human_size(option_value)
@@ -1,3 +1,3 @@
1
1
  module Paperclip
2
- VERSION = "6.4.0" unless defined?(Paperclip::VERSION)
2
+ VERSION = "6.4.2" unless defined?(Paperclip::VERSION)
3
3
  end
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"
@@ -193,9 +193,18 @@ describe Paperclip::UriAdapter do
193
193
 
194
194
  describe "#download_content" do
195
195
  before do
196
- allow_any_instance_of(Paperclip::UriAdapter).to receive(:open).and_return(@open_return)
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(@subject).to receive(:open).with(@uri, {}).at_least(1).times
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(@subject).to receive(:open).with(@uri, read_timeout: 120).at_least(1).times
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
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.0
4
+ version: 6.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Surendra Singhi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-13 00:00:00.000000000 Z
11
+ date: 2022-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -547,7 +547,7 @@ files:
547
547
  - spec/support/reporting.rb
548
548
  - spec/support/test_data.rb
549
549
  - spec/support/version_helper.rb
550
- homepage: https://github.com/kreeti/paperclip
550
+ homepage: https://github.com/kreeti/kt-paperclip
551
551
  licenses:
552
552
  - MIT
553
553
  metadata: {}
@@ -584,7 +584,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
584
584
  version: '0'
585
585
  requirements:
586
586
  - ImageMagick
587
- rubygems_version: 3.0.1
587
+ rubygems_version: 3.1.6
588
588
  signing_key:
589
589
  specification_version: 4
590
590
  summary: File attachments as attributes for ActiveRecord