shrine 3.0.0 → 3.0.1
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 +4 -4
- data/CHANGELOG.md +41 -33
- data/README.md +85 -0
- data/doc/advantages.md +3 -3
- data/doc/attacher.md +14 -15
- data/doc/carrierwave.md +4 -4
- data/doc/design.md +2 -2
- data/doc/external/articles.md +1 -0
- data/doc/external/extensions.md +1 -0
- data/doc/getting_started.md +8 -7
- data/doc/paperclip.md +5 -5
- data/doc/plugins/activerecord.md +4 -4
- data/doc/plugins/derivatives.md +4 -4
- data/doc/plugins/entity.md +3 -3
- data/doc/plugins/model.md +4 -4
- data/doc/plugins/sequel.md +4 -4
- data/doc/plugins/versions.md +4 -4
- data/doc/release_notes/3.0.0.md +274 -257
- data/doc/release_notes/3.0.1.md +18 -0
- data/doc/upgrading_to_3.md +19 -1
- data/lib/shrine/attacher.rb +1 -1
- data/lib/shrine/plugins/derivatives.rb +3 -3
- data/lib/shrine/plugins/metadata_attributes.rb +1 -1
- data/lib/shrine/uploaded_file.rb +5 -0
- data/lib/shrine/version.rb +1 -1
- metadata +3 -2
@@ -0,0 +1,18 @@
|
|
1
|
+
## Regressions
|
2
|
+
|
3
|
+
* Fixed `metadata_attributes` plugin raising an exception when the attachment
|
4
|
+
is removed (assigned to `nil`).
|
5
|
+
|
6
|
+
## Improvements
|
7
|
+
|
8
|
+
* Simplified `UploadedFile#inspect` output:
|
9
|
+
|
10
|
+
```rb
|
11
|
+
# before
|
12
|
+
uploaded_file.inspect
|
13
|
+
#=> #<Shrine::UploadedFile:0x00007fa4e4140d30 @id="cda84bbdab12b2bd41ea34590060a807", @storage_key=:memory, @metadata={"filename"=>nil, "size"=>0, "mime_type"=>nil}>
|
14
|
+
|
15
|
+
# after
|
16
|
+
uploaded_file.inspect
|
17
|
+
#=> #<Shrine::UploadedFile id="488b887dd792b4c82d3fc445140c5a38" storage=:memory metadata={"filename"=>nil, "size"=>0, "mime_type"=>nil}>
|
18
|
+
```
|
data/doc/upgrading_to_3.md
CHANGED
@@ -4,7 +4,11 @@ title: Upgrading to Shrine 3.x
|
|
4
4
|
---
|
5
5
|
|
6
6
|
This guide provides instructions for upgrading Shrine in your apps to version
|
7
|
-
3.x. If you're looking for a full list of changes, see the [3.0 release
|
7
|
+
3.x. If you're looking for a full list of changes, see the **[3.0 release
|
8
|
+
notes]**.
|
9
|
+
|
10
|
+
If you would like assistance with the upgrade, I'm available for consultation,
|
11
|
+
you can email me at <janko.marohnic@gmail.com>.
|
8
12
|
|
9
13
|
## Attacher
|
10
14
|
|
@@ -72,6 +76,20 @@ attacher.reload
|
|
72
76
|
attacher.file #=> #<Shrine::UploadedFile ...>
|
73
77
|
```
|
74
78
|
|
79
|
+
### Assigning
|
80
|
+
|
81
|
+
The `Attacher#assign` method now raises an exception when non-cached uploaded
|
82
|
+
file data is assigned:
|
83
|
+
|
84
|
+
```rb
|
85
|
+
# Shrine 2.x
|
86
|
+
attacher.assign('{"id": "...", "storage": "store", "metadata": {...}}') # ignored
|
87
|
+
|
88
|
+
# Shrine 3.0
|
89
|
+
attacher.assign('{"id": "...", "storage": "store", "metadata": {...}}')
|
90
|
+
#~> Shrine::Error: expected cached file, got #<Shrine::UploadedFile storage=:store ...>
|
91
|
+
```
|
92
|
+
|
75
93
|
### Validation
|
76
94
|
|
77
95
|
The validation functionality has been extracted into the `validation` plugin.
|
data/lib/shrine/attacher.rb
CHANGED
@@ -352,7 +352,7 @@ class Shrine
|
|
352
352
|
# reject files not uploaded to temporary storage, because otherwise
|
353
353
|
# attackers could hijack other users' attachments
|
354
354
|
unless cached?(uploaded_file)
|
355
|
-
fail Shrine::Error, "expected cached file, got #{
|
355
|
+
fail Shrine::Error, "expected cached file, got #{uploaded_file.inspect}"
|
356
356
|
end
|
357
357
|
|
358
358
|
uploaded_file
|
@@ -525,13 +525,13 @@ class Shrine
|
|
525
525
|
# Converts data into a Hash of derivatives.
|
526
526
|
#
|
527
527
|
# Shrine.derivatives('{"thumb":{"id":"foo","storage":"store","metadata":{}}}')
|
528
|
-
# #=> { thumb: #<Shrine::UploadedFile
|
528
|
+
# #=> { thumb: #<Shrine::UploadedFile id="foo" storage=:store metadata={}> }
|
529
529
|
#
|
530
530
|
# Shrine.derivatives({ "thumb" => { "id" => "foo", "storage" => "store", "metadata" => {} } })
|
531
|
-
# #=> { thumb: #<Shrine::UploadedFile
|
531
|
+
# #=> { thumb: #<Shrine::UploadedFile id="foo" storage=:store metadata={}> }
|
532
532
|
#
|
533
533
|
# Shrine.derivatives({ thumb: { id: "foo", storage: "store", metadata: {} } })
|
534
|
-
# #=> { thumb: #<Shrine::UploadedFile
|
534
|
+
# #=> { thumb: #<Shrine::UploadedFile id="foo" storage=:store metadata={}> }
|
535
535
|
def derivatives(object)
|
536
536
|
if object.is_a?(String)
|
537
537
|
derivatives JSON.parse(object)
|
data/lib/shrine/uploaded_file.rb
CHANGED
@@ -249,6 +249,11 @@ class Shrine
|
|
249
249
|
self.class.shrine_class
|
250
250
|
end
|
251
251
|
|
252
|
+
# Returns simplified inspect output.
|
253
|
+
def inspect
|
254
|
+
"#<#{self.class.inspect} storage=#{storage_key.inspect} id=#{id.inspect} metadata=#{metadata.inspect}>"
|
255
|
+
end
|
256
|
+
|
252
257
|
private
|
253
258
|
|
254
259
|
# Returns an opened IO object for the uploaded file by calling `#open`
|
data/lib/shrine/version.rb
CHANGED
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: 3.0.
|
4
|
+
version: 3.0.1
|
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-10-
|
11
|
+
date: 2019-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: down
|
@@ -466,6 +466,7 @@ files:
|
|
466
466
|
- doc/release_notes/2.8.0.md
|
467
467
|
- doc/release_notes/2.9.0.md
|
468
468
|
- doc/release_notes/3.0.0.md
|
469
|
+
- doc/release_notes/3.0.1.md
|
469
470
|
- doc/retrieving_uploads.md
|
470
471
|
- doc/securing_uploads.md
|
471
472
|
- doc/storage/file_system.md
|