shrine 2.19.1 → 2.19.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of shrine might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: '0846af73d2a421712ff8e555dc2570115e8f7261'
4
- data.tar.gz: b3a033fa950c7a55203c179e24aed2d72c40b3f2
2
+ SHA256:
3
+ metadata.gz: 14cd1140359997859d3f25aa72f22d425e778f7cfec37af3570690a45985f9d3
4
+ data.tar.gz: 1e2b2f745d676377b6eaab0169290475feb1735583331c52f397e6adbe9d7a7b
5
5
  SHA512:
6
- metadata.gz: 56d4630870e6dc0ee182828d30b4a0ac3f3f8c7f5e1b2df044931791091e82f66dd15eb14827914a5501600a30eb736d16aebf0980b438922c84a463bd62febc
7
- data.tar.gz: ae223fef4115d4292d97eb7c19ff29c310fae3bffc63f9bb8e239281a629af571805a9e86eda02a332c91a15a3e8bd28bf92106a8ad3f546c4f5bc69a6a0f444
6
+ metadata.gz: 7e2c323641f065c9cca255dc4d036404ec3c0e18ec55632f2ce73351d166e08767720c77660090cd41f225028762f9af6b7559dc0ebc94355e3741dcd6f06a52
7
+ data.tar.gz: 8b1666efb1bdd5e4d4e06376398f2d82e60aab9e4a1113570bd72c790d51b0ee6d4370ee1465cea32ae43d8d7e62610408b45999fa504bd8cb817d34435bfd2d
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## 2.19.2 (2018-07-25)
2
+
3
+ * `default_url_options` – Allow deleting passed options when using a block (@janko)
4
+
5
+ * `activerecord` – Make it work with ActiveRecord 3 (@texpert)
6
+
7
+ * `infer_extension` – Fix compatibility with `pretty_location` plugin (@janko)
8
+
1
9
  ## 2.19.1 (2018-07-20)
2
10
 
3
11
  * Bring back support for Ruby 2.3 (@janko)
@@ -13,7 +13,7 @@ which will receive the UploadedFile object along with any options that were
13
13
  passed to `UploadedFile#url`.
14
14
 
15
15
  ```rb
16
- plugin :default_url_options, store: -> (io, **options) do
16
+ plugin :default_url_options, store: -> (io, options) do
17
17
  { response_content_disposition: ContentDisposition.attachment(io.original_filename) }
18
18
  end
19
19
  ```
data/lib/shrine.rb CHANGED
@@ -244,7 +244,7 @@ class Shrine
244
244
  # file extension. Can be overriden in uploaders for generating custom
245
245
  # location.
246
246
  def generate_location(io, context = {})
247
- basic_location(io)
247
+ basic_location(io, metadata: context[:metadata] || {})
248
248
  end
249
249
 
250
250
  # Extracts filename, size and MIME type from the file, which is later
@@ -337,7 +337,7 @@ class Shrine
337
337
  end
338
338
 
339
339
  # Generates a basic location for an uploaded file
340
- def basic_location(io)
340
+ def basic_location(io, metadata:)
341
341
  extension = ".#{io.extension}" if io.is_a?(UploadedFile) && io.extension
342
342
  extension ||= File.extname(extract_filename(io).to_s).downcase
343
343
  basename = generate_uid(io)
@@ -35,12 +35,14 @@ class Shrine
35
35
  attacher.save if attacher.changed?
36
36
  end
37
37
 
38
- model.after_commit on: [:create, :update] do
39
- attacher = send("#{name}_attacher")
40
- attacher.finalize if attacher.changed?
38
+ [:create, :update].each do |action|
39
+ model.after_commit on: action do
40
+ attacher = send("#{name}_attacher")
41
+ attacher.finalize if attacher.changed?
42
+ end
41
43
  end
42
44
 
43
- model.after_commit on: [:destroy] do
45
+ model.after_commit on: :destroy do
44
46
  send("#{name}_attacher").destroy
45
47
  end
46
48
  end
@@ -14,7 +14,7 @@ class Shrine
14
14
  module FileMethods
15
15
  def url(**options)
16
16
  default_options = default_url_options
17
- default_options = default_options.call(self, **options) if default_options.respond_to?(:call)
17
+ default_options = default_options.call(self, options) if default_options.respond_to?(:call)
18
18
  default_options ||= {}
19
19
 
20
20
  super(default_options.merge(options))
@@ -53,14 +53,12 @@ class Shrine
53
53
  end
54
54
 
55
55
  module InstanceMethods
56
- def generate_location(io, context = {})
57
- mime_type = (context[:metadata] || {})["mime_type"]
58
-
56
+ def basic_location(io, metadata:)
59
57
  location = super
60
58
  current_extension = File.extname(location)
61
59
 
62
60
  if current_extension.empty? || opts[:infer_extension][:force]
63
- inferred_extension = infer_extension(mime_type)
61
+ inferred_extension = infer_extension(metadata["mime_type"])
64
62
  location = location.chomp(current_extension) << inferred_extension unless inferred_extension.empty?
65
63
  end
66
64
 
@@ -16,13 +16,13 @@ class Shrine
16
16
  pretty_location(io, context)
17
17
  end
18
18
 
19
- def pretty_location(io, name: nil, record: nil, version: nil, identifier: nil, **)
19
+ def pretty_location(io, name: nil, record: nil, version: nil, identifier: nil, metadata: {}, **)
20
20
  if record
21
21
  namespace = record_namespace(record)
22
22
  identifier ||= record_identifier(record)
23
23
  end
24
24
 
25
- basename = basic_location(io)
25
+ basename = basic_location(io, metadata: metadata)
26
26
  basename = "#{version}-#{basename}" if version
27
27
 
28
28
  [*namespace, *identifier, *name, basename].join("/")
@@ -8,7 +8,7 @@ class Shrine
8
8
  module VERSION
9
9
  MAJOR = 2
10
10
  MINOR = 19
11
- TINY = 1
11
+ TINY = 2
12
12
  PRE = nil
13
13
 
14
14
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shrine
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.19.1
4
+ version: 2.19.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Janko Marohnić
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-20 00:00:00.000000000 Z
11
+ date: 2019-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: down
@@ -566,8 +566,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
566
566
  - !ruby/object:Gem::Version
567
567
  version: '0'
568
568
  requirements: []
569
- rubyforge_project:
570
- rubygems_version: 2.5.2.3
569
+ rubygems_version: 3.0.3
571
570
  signing_key:
572
571
  specification_version: 4
573
572
  summary: Toolkit for file attachments in Ruby applications