shrine 2.19.4 → 3.0.0.alpha

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.

Files changed (110) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +299 -11
  3. data/README.md +9 -3
  4. data/doc/advantages.md +1 -1
  5. data/doc/carrierwave.md +4 -4
  6. data/doc/creating_persistence_plugins.md +172 -0
  7. data/doc/creating_plugins.md +1 -1
  8. data/doc/creating_storages.md +3 -1
  9. data/doc/design.md +2 -2
  10. data/doc/direct_s3.md +0 -22
  11. data/doc/paperclip.md +3 -3
  12. data/doc/plugins/activerecord.md +211 -42
  13. data/doc/plugins/atomic_helpers.md +153 -0
  14. data/doc/plugins/column.md +90 -0
  15. data/doc/plugins/derivation_endpoint.md +54 -62
  16. data/doc/plugins/derivatives.md +752 -0
  17. data/doc/plugins/entity.md +204 -0
  18. data/doc/plugins/infer_extension.md +8 -8
  19. data/doc/plugins/instrumentation.md +33 -13
  20. data/doc/plugins/keep_files.md +5 -15
  21. data/doc/plugins/model.md +157 -0
  22. data/doc/plugins/presign_endpoint.md +2 -1
  23. data/doc/plugins/refresh_metadata.md +44 -7
  24. data/doc/plugins/sequel.md +190 -33
  25. data/doc/plugins/{default_url_options.md → url_options.md} +5 -5
  26. data/doc/processing.md +1 -1
  27. data/doc/release_notes/1.1.0.md +2 -2
  28. data/doc/release_notes/2.15.0.md +1 -1
  29. data/doc/storage/s3.md +2 -2
  30. data/doc/testing.md +1 -1
  31. data/lib/shrine.rb +72 -138
  32. data/lib/shrine/attacher.rb +272 -176
  33. data/lib/shrine/attachment.rb +2 -42
  34. data/lib/shrine/plugins/activerecord.rb +103 -26
  35. data/lib/shrine/plugins/add_metadata.rb +9 -10
  36. data/lib/shrine/plugins/atomic_helpers.rb +111 -0
  37. data/lib/shrine/plugins/attacher_options.rb +55 -0
  38. data/lib/shrine/plugins/backgrounding.rb +147 -115
  39. data/lib/shrine/plugins/cached_attachment_data.rb +6 -9
  40. data/lib/shrine/plugins/column.rb +104 -0
  41. data/lib/shrine/plugins/data_uri.rb +35 -38
  42. data/lib/shrine/plugins/default_storage.rb +18 -12
  43. data/lib/shrine/plugins/default_url.rb +11 -21
  44. data/lib/shrine/plugins/default_url_options.rb +3 -30
  45. data/lib/shrine/plugins/delete_raw.rb +9 -13
  46. data/lib/shrine/plugins/derivation_endpoint.rb +75 -114
  47. data/lib/shrine/plugins/derivatives.rb +576 -0
  48. data/lib/shrine/plugins/determine_mime_type.rb +3 -15
  49. data/lib/shrine/plugins/download_endpoint.rb +83 -131
  50. data/lib/shrine/plugins/dynamic_storage.rb +4 -8
  51. data/lib/shrine/plugins/entity.rb +128 -0
  52. data/lib/shrine/plugins/form_assign.rb +107 -0
  53. data/lib/shrine/plugins/included.rb +4 -3
  54. data/lib/shrine/plugins/infer_extension.rb +10 -17
  55. data/lib/shrine/plugins/instrumentation.rb +45 -25
  56. data/lib/shrine/plugins/keep_files.rb +2 -12
  57. data/lib/shrine/plugins/metadata_attributes.rb +15 -14
  58. data/lib/shrine/plugins/model.rb +137 -0
  59. data/lib/shrine/plugins/module_include.rb +2 -0
  60. data/lib/shrine/plugins/presign_endpoint.rb +1 -15
  61. data/lib/shrine/plugins/pretty_location.rb +5 -5
  62. data/lib/shrine/plugins/processing.rb +21 -6
  63. data/lib/shrine/plugins/rack_file.rb +1 -39
  64. data/lib/shrine/plugins/rack_response.rb +14 -7
  65. data/lib/shrine/plugins/recache.rb +5 -2
  66. data/lib/shrine/plugins/refresh_metadata.rb +12 -8
  67. data/lib/shrine/plugins/remote_url.rb +44 -53
  68. data/lib/shrine/plugins/remove_attachment.rb +7 -2
  69. data/lib/shrine/plugins/remove_invalid.rb +8 -4
  70. data/lib/shrine/plugins/restore_cached_data.rb +12 -4
  71. data/lib/shrine/plugins/sequel.rb +115 -27
  72. data/lib/shrine/plugins/signature.rb +2 -7
  73. data/lib/shrine/plugins/store_dimensions.rb +13 -27
  74. data/lib/shrine/plugins/upload_endpoint.rb +14 -15
  75. data/lib/shrine/plugins/upload_options.rb +9 -8
  76. data/lib/shrine/plugins/url_options.rb +33 -0
  77. data/lib/shrine/plugins/validation.rb +87 -0
  78. data/lib/shrine/plugins/validation_helpers.rb +33 -54
  79. data/lib/shrine/plugins/versions.rb +106 -84
  80. data/lib/shrine/storage/file_system.rb +32 -57
  81. data/lib/shrine/storage/linter.rb +9 -1
  82. data/lib/shrine/storage/memory.rb +42 -0
  83. data/lib/shrine/storage/s3.rb +38 -146
  84. data/lib/shrine/uploaded_file.rb +22 -29
  85. data/lib/shrine/version.rb +4 -4
  86. data/shrine.gemspec +2 -3
  87. metadata +27 -54
  88. data/doc/plugins/backup.md +0 -31
  89. data/doc/plugins/copy.md +0 -24
  90. data/doc/plugins/delete_promoted.md +0 -12
  91. data/doc/plugins/direct_upload.md +0 -172
  92. data/doc/plugins/hooks.md +0 -58
  93. data/doc/plugins/logging.md +0 -42
  94. data/doc/plugins/migration_helpers.md +0 -60
  95. data/doc/plugins/moving.md +0 -19
  96. data/doc/plugins/multi_delete.md +0 -20
  97. data/doc/plugins/parallelize.md +0 -16
  98. data/doc/plugins/parsed_json.md +0 -23
  99. data/lib/shrine/plugins/background_helpers.rb +0 -5
  100. data/lib/shrine/plugins/backup.rb +0 -90
  101. data/lib/shrine/plugins/copy.rb +0 -50
  102. data/lib/shrine/plugins/delete_promoted.rb +0 -20
  103. data/lib/shrine/plugins/direct_upload.rb +0 -217
  104. data/lib/shrine/plugins/hooks.rb +0 -90
  105. data/lib/shrine/plugins/logging.rb +0 -142
  106. data/lib/shrine/plugins/migration_helpers.rb +0 -70
  107. data/lib/shrine/plugins/moving.rb +0 -57
  108. data/lib/shrine/plugins/multi_delete.rb +0 -32
  109. data/lib/shrine/plugins/parallelize.rb +0 -78
  110. data/lib/shrine/plugins/parsed_json.rb +0 -29
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f87dfd3785a6b526ee6bea2746ee7218a3bf817a0935ce11daa4f3d01fdd53ad
4
- data.tar.gz: c11cc48b95b4dce2d3da10232dd148e94e93079e594b1fe81a39f949fdc89ac8
3
+ metadata.gz: 36715577aa30205e12419931f31b3dfad46e30e659372c88e5e926d536984dfc
4
+ data.tar.gz: fd74dd99deef2030ebc5c2935bccb15447e5a5eb9a916c8379e6d57db87bba23
5
5
  SHA512:
6
- metadata.gz: 319325474e6a12e40943d3d969fb4b1c06d17136c64aa7a241d319d4b7d765391be68c847ba920d58b36ab61807e934aee543c9ab6bedac1681be4806bce5f5f
7
- data.tar.gz: cd919fd2e5fd4e69da13f2723c17702d235f1f41b33eb51d75e42f12e1eed06778261c11622a2c2ebe2a08fbe3eaf5959c2cf3d76657ca4d7fd051433cd53ed3
6
+ metadata.gz: 2fbc8cce3080e6728d04c59e6e56b2653b47df3c0d8dece92f62590cebcd5d30a54c9f7f31ba11ff6fcf6041190438ee20785075c7ca3dce6863ac77311ca69b
7
+ data.tar.gz: '038a34aade2923b6c5ce0f36d6d8897dc1ac7cc06b06a06dd46cbffc26cc57db0345ead5674562ac1d84a7a8825e49a8a536ce0321321d7edbf3f429795fa492'
data/CHANGELOG.md CHANGED
@@ -1,24 +1,312 @@
1
- ## 2.19.4 (2020-01-16)
1
+ ## 3.0.0.alpha (2019-08-19)
2
2
 
3
- * Relax Down version to allow 5.x (@janko)
3
+ * `form_assign` Add new plugin for assigning attachment from form params without a form object (@janko)
4
4
 
5
- ## 2.19.3 (2019-08-09)
5
+ * `derivation_endpoint` – Allow passing generic IO objects to `Derivation#upload` (@janko)
6
6
 
7
- * `store_dimensions` – Ignore dimensions extraction errors by default (@janko)
7
+ * `derivation_endpoint` – Accept additional uploader options in `Derivation#upload` (@janko)
8
8
 
9
- * `file_system` – Un-deprecate `FileSystem#upload` receiving unrecognized options (@janko)
9
+ * `derivation_endpoint` – Close the uploaded file in `Derivation#upload` (@janko)
10
10
 
11
- ## 2.19.2 (2019-07-25)
11
+ * `core` – Stop rescuing `IO#close` exceptions in `Shrine#upload` (@janko)
12
12
 
13
- * `default_url_options` – Allow deleting passed options when using a block (@janko)
13
+ * `core` – Add `:delete` option to `Shrine#upload` for deleting uploaded file (@janko)
14
14
 
15
- * `activerecord` – Make it work with ActiveRecord 3 (@texpert)
15
+ * `s3` – Stop returning `:object` in `Down::ChunkedIO#data` in `S3#open` (@janko)
16
16
 
17
- * `infer_extension` – Fix compatibility with `pretty_location` plugin (@janko)
17
+ * `s3` – Eliminate `#head_object` request in `S3#open` (@janko)
18
18
 
19
- ## 2.19.1 (2019-07-20)
19
+ * `download_endpoint` – Remove extra `Storage#exists?` check (@janko)
20
20
 
21
- * Bring back support for Ruby 2.3 (@janko)
21
+ * `derivation_endpoint` Remove support for derivative being deleted during upload (@janko)
22
+
23
+ * `derivation_endpoint` – Add `Derivation#opened` for retrieving an opened derivation result (@janko)
24
+
25
+ * `derivation_endpoint` – Remove extra `Storage#exists?` check when `:upload` is enabled but not `:upload_redirect` (@janko)
26
+
27
+ * `derivation_endpoint` - Don't pass source `UploadedFile` object when `:download` is `false` (@janko)
28
+
29
+ * `derivation_endpoint` – Remove `:include_uploaded_file` option (@janko)
30
+
31
+ * `derivation_endpoint` – Evaluate derivation block in context of `Shrine::Derivation` (@janko)
32
+
33
+ * `derivation_endpoint` – Remove `:download_errors` option (@janko)
34
+
35
+ * `memory` – Raise `Shrine::FileNotFound` on nonexistent file in `Memory#open` (@janko)
36
+
37
+ * `file_system` – Raise `Shrine::FileNotFound` on nonexistent file in `FileSystem#open` (@janko)
38
+
39
+ * `s3` – Raise `Shrine::FileNotFound` on nonexistent object in `S3#open` (@janko)
40
+
41
+ * `core` – Add `Shrine::FileNotFound` exception and require storages to raise it on `Storage#open` (janko)
42
+
43
+ * `instrumentation` – Remove `:metadata` from `:options` in `metadata.shrine` event (@janko)
44
+
45
+ * `instrumentation` – Remove `:location`, `:upload_options` and `:metadata` from `:options` in `upload.shrine` event (@janko)
46
+
47
+ * `instrumentation` – Add `:metadata` to the `upload.shrine` event (@janko)
48
+
49
+ * `download_endpoint` – Drop support for legacy `/:storage/:id` URLs (@janko)
50
+
51
+ * `core` – In `UploadedFile#==` require files to be of the same class (@janko)
52
+
53
+ * `core` – Add `:close` option to `Shrine#upload` for preventing closing file after upload (@janko)
54
+
55
+ * `memory` – Add `Shrine::Storage::Memory` from `shrine-memory` gem (@janko)
56
+
57
+ * `default_url_options` – Rename to just `url_options` (@janko)
58
+
59
+ * `delete_raw` – Deprecate plugin in favour of `derivatives` (@janko)
60
+
61
+ * `recache` – Deprecate plugin in favour of `derivatives` (@janko)
62
+
63
+ * `processing` – Deprecate plugin in favour of `derivatives` (@janko)
64
+
65
+ * `versions` – Deprecate plugin in favour of `derivatives` (@janko)
66
+
67
+ * `derivatives` – Add new plugin for storing processed files (@janko)
68
+
69
+ * `derivation_endpoint` – Allow using symbol and string derivation names interchangeably (@janko)
70
+
71
+ * `dynamic_storage` – Remove `Shrine.dynamic_storages` method (@janko)
72
+
73
+ * `core` – Deep duplicate `Shrine.opts` on subclassing (@janko)
74
+
75
+ * `core` – Add `Attacher#file!` which asserts that a file is attached (@janko)
76
+
77
+ * `core` – Change `Shrine.uploaded_file` to raise `ArgumentError` on invalid input (@janko)
78
+
79
+ * `module_include` – Deprecate plugin over overriding core classes directly (@janko)
80
+
81
+ * `core` – Add `Attacher#cache_key` and `Attacher#store_key` which return storage identifiers (@janko)
82
+
83
+ * `linter` – Call `Storage#open` with options as second argument (@janko)
84
+
85
+ * `core` – Allow data hash passed to `UploadedFile.new` to have symbol keys (@janko)
86
+
87
+ * `core` – Change how `Shrine::UploadedFile` sets its state from the given data hash (@janko)
88
+
89
+ * `core` – Deprecate `Storage#open` not accepting additional options (@janko)
90
+
91
+ * `refresh_metadata` – Add `Attacher#refresh_metadata!` method which integrates with `model` plugin (@janko)
92
+
93
+ * `instrumentation` – Instrument any `Storage#open` calls in a new `open.shrine` event (@janko)
94
+
95
+ * `restore_cached_data` – Forward options passed to `Attacher#attach_cached` to metadata extraction (@janko)
96
+
97
+ * `attacher_options` – Add new plugin for setting default attacher operation options (@janko)
98
+
99
+ * `validation` – Add `Attacher#validate_options` for registering default validation options (@janko)
100
+
101
+ * `validation` – Allow skipping validations on attaching by passing `validate: false` (@janko)
102
+
103
+ * `validation` – Add `:validate` option to `Attacher#assign` or `Attacher#attach` for passing options to validation block (@janko)
104
+
105
+ * `validation` – Extract validation functionality into the new plugin (@janko)
106
+
107
+ * `upload_options` – Upload options from the block are now merged with passed options instead of replaced (@janko)
108
+
109
+ * `upload_endpoint` – Stop passing `Rack::Request` object to the uploader (@janko)
110
+
111
+ * `remote_url` – Require custom downlodaers to raise `Shrine::Plugins::RemoteUrl::DownloadError` for conversion into a validation error (@janko)
112
+
113
+ * `remote_url` – Remove `Attacher#remote_url=` and `Attacher#remote_url` (@janko)
114
+
115
+ * `infer_extension` – Fix compatibility with the `pretty_location` plugin (@janko)
116
+
117
+ * `presign_endpoint` – Remove deprecated `Shrine::Plugins::PresignEndpoint::App` constant (@janko)
118
+
119
+ * `keep_files` – Remove the ability to choose whether to keep only destroyed or only replaced files (@janko)
120
+
121
+ * `infer_extension` – Remove `Shrine#infer_extension` method (@janko)
122
+
123
+ * `default_url_options` – Allow overriding passed URL options by deleting them inside the block (@janko)
124
+
125
+ * `data_uri` – Remove `Attacher#data_uri=` and `Attacher#data_uri` methods (@janko)
126
+
127
+ * `cached_attachment_data` – Rename `Attacher#read_cached` to `Attacher#cached_data` (@janko)
128
+
129
+ * `sequel` – Add `Attacher#atomic_promote` and `Attacher#atomic_persist` (@janko)
130
+
131
+ * `sequel` – Remove adding persistence to `Attacher#promote` (@janko)
132
+
133
+ * `activerecord` – Add `Attacher#atomic_promote` and `Attacher#atomic_persist` (@janko)
134
+
135
+ * `activerecord` – Remove adding persistence to `Attacher#promote` (@janko)
136
+
137
+ * `atomic_helpers` – Add new plugin with helper methods for atomic promotion and persistence (@janko)
138
+
139
+ * `backgrounding` – Add `Attacher#promote_block` & `Attacher#destroy_block` for overriding class level blocks (@janko)
140
+
141
+ * `backgrounding` – Add `Attacher.promote_block` & `Attacher.destroy_block` on class level (@janko)
142
+
143
+ * `backgrounding` – Remove overriding `Attacher#swap` with atomic promotion (@janko)
144
+
145
+ * `backgrounding` – Remove `Attacher.promote`, `Attacher.delete`, `Attacher.dump`, `Attacher#dump`, `Attacher.load`, `Attacher.load_record` (@janko)
146
+
147
+ * `model` – Allow disabling caching to temporary storage on assignment (@janko)
148
+
149
+ * `model` – Add `Attacher.from_model`, `Attacher#write` (@janko)
150
+
151
+ * `model` – Add new plugin for integrating with mutable structs (@janko)
152
+
153
+ * `entity` – Add `Attacher.from_entity`, `Attacher#reload`, `Attacher#column_values`, `Attacher#attribute` (@janko)
154
+
155
+ * `entity` – Add new plugin for integrating with immutable structs (@janko)
156
+
157
+ * `column` – Allow changing column serializer from default `JSON` library (@janko)
158
+
159
+ * `column` – Add `Attacher#column_data` and `Attacher.from_column` methods (@janko)
160
+
161
+ * `column` – Add new plugin for (de)serializing attacher data (@janko)
162
+
163
+ * `attachment` – Removed any default attachment methods (@janko)
164
+
165
+ * `core` – Require context hash passed as second argument to `Shrine#upload` to have symbol keys (@janko)
166
+
167
+ * `core` – Change `Shrine.uploaded_file` not to yield files anymore (@janko)
168
+
169
+ * `core` – Allow `Shrine.uploaded_file` to accept file data hashes with symbol keys (@janko)
170
+
171
+ * `core` – Remove `Shrine#uploaded?`
172
+
173
+ * `core` – Remove `Shrine#delete`, `Shrine#_delete`, `Shrine#remove` (@janko)
174
+
175
+ * `core` – Remove `Shrine#store`, `Shrine#_store`, `Shrine#put`, `Shrine#copy` (@janko)
176
+
177
+ * `core` – Remove `Shrine#processed`, `Shrine#process` (@janko)
178
+
179
+ * `core` – Don't pass `:phase` anymore on uploads (@janko)
180
+
181
+ * `core` – Read attachment from the record attribute only on initialization (@janko)
182
+
183
+ * `core` – Don't require a temporary storage (@janko)
184
+
185
+ * `core` – Add `Attacher#data` and `Attacher.from_data` for dumping to and loading from a Hash (@janko)
186
+
187
+ * `core` – Enable `Attacher#assign` to accept cached file data as a Hash (@janko)
188
+
189
+ * `core` – Add `Attacher#file` alias for `Attacher#get` (@janko)
190
+
191
+ * `core` – Change `Attacher#attached?` to return whether a file is attached (@janko)
192
+
193
+ * `core` – Change `Attacher#promote` to always only save promoted file in memory (@janko)
194
+
195
+ * `core` – Rename `Attacher#replace` to `Attacher#destroy_previous` (@janko)
196
+
197
+ * `core` – Remove `Attacher#_promote` and `Attacher#_delete`, add `Attacher#promote_cached` and `Attacher#destroy_attached` (@janko)
198
+
199
+ * `core` – Rename `Attacher#set` and `Attacher#_set` to `Attacher#change` and `Attacher#set` (@janko)
200
+
201
+ * `core` – Remove `Attacher#cache!` and `Attacher#store!`, add `Attacher#upload` (@janko)
202
+
203
+ * `core` – Rename `Attacher#validate_block` to `Attacher#_validate` (@janko)
204
+
205
+ * `core` – Add `Attacher#attach`, `Attacher#attach_cached`, extracted from `Attacher#assign` (@janko)
206
+
207
+ * `core` – Remove `Attacher#swap`, `Attacher#update`, `Attacher#read`, `Attacher#write`, `Attacher#data_attribute`, `Attacher#convert_to_data`, `Attacher#convert_before_write`, and `Attacher#convert_after_read` (@janko)
208
+
209
+ * `core` – Change `Attacher.new` to not accept a model anymore (@janko)
210
+
211
+ * `delete_promoted` – Remove plugin (@janko)
212
+
213
+ * `parsed_json` – Remove plugin (@janko)
214
+
215
+ * `parallelize` – Remove plugin (@janko)
216
+
217
+ * `hooks` – Remove plugin (@janko)
218
+
219
+ * `s3` – Replace source object metadata when copying a file from S3 (@janko)
220
+
221
+ * `core` – Change `UploadedFile#storage_key` to return a Symbol instead of a String (@janko)
222
+
223
+ * `infer_extension` – Make `:mini_mime` the default analyzer (@janko)
224
+
225
+ * Bring back Ruby 2.3 support (@janko)
226
+
227
+ * `versions` – Remove deprecated `:version_names`, `Shrine.version_names` and `Shrine.version?` (@janko)
228
+
229
+ * `validation_helpers` – Remove support for regexes in MIME type or extension validations (@janko)
230
+
231
+ * `validation_helpers` – Don't require `#width` and `#height` methods to be defined on `UploadedFile` (@janko)
232
+
233
+ * `validation_helpers` – Fail dimensions validations when `width` or `height` metadata is missing (@janko)
234
+
235
+ * `upload_endpoint` – Remove deprecated `Shrine::Plugins::UploadEndpoint::App` constant (@janko)
236
+
237
+ * `determine_mime_type` – Remove `Shrine#mime_type_analyzers` method (@janko)
238
+
239
+ * `store_dimensions` – Remove `Shrine#extract_dimensions` and `Shrine#dimensions_analyzers` methods (@janko)
240
+
241
+ * `rack_file` – Remove deprecated `Shrine::Plugins::RackFile::UploadedFile` constant (@janko)
242
+
243
+ * `rack_file` – Drop support for passing file hash to `Shrine#upload` and `Shrine#store` (@janko)
244
+
245
+ * `download_endpoint` – Move `Shrine::Plugins::DownloadEndpoint::App` into `Shrine::DownloadEndpoint` (@janko)
246
+
247
+ * `download_endpoint` – Remove deprecated `Shrine::DownloadEndpoint` constant (@janko)
248
+
249
+ * `download_endpoint` – Remove deprecated `:storages` option (@janko)
250
+
251
+ * `determine_mime_type` – Remove deprecated `:default` analyzer alias (@janko)
252
+
253
+ * `default_url` – Remove deprecated block argument when loading the plugin (@janko)
254
+
255
+ * `data_uri` – Remove deprecated `Shrine::Plugins::DataUri::DataFile` constant (@janko)
256
+
257
+ * `data_uri` – Remove deprecated `:filename` plugin option (@janko)
258
+
259
+ * `cached_attachment_data` – Remove deprecated model setter (@janko)
260
+
261
+ * `file_system` – Remove deprecated `:older_than` option in `FileSystem#clear!` (@janko)
262
+
263
+ * `file_system` – Don't accept a block anymore in `FileSystem#open` (@janko)
264
+
265
+ * `file_system` – Remove deprecated `FileSystem#download` method (@janko)
266
+
267
+ * `file_system` – Make `FileSystem#movable?` and `FileSystem#move` methods private (@janko)
268
+
269
+ * `file_system` – Remove deprecation warning on unrecognized options in `FileSystem#upload` (@janko)
270
+
271
+ * `file_system` – Remove deprecated `:host` option for `FileSystem#initialize` (@janko)
272
+
273
+ * `moving` – Remove deprecated plugin (@janko)
274
+
275
+ * `multi_delete` – Remove deprecated plugin (@janko)
276
+
277
+ * `direct_upload` – Remove deprecated plugin (@janko)
278
+
279
+ * `backup` – Remove deprecated plugin (@janko)
280
+
281
+ * `background_helpers` – Remove deprecated plugin (@janko)
282
+
283
+ * `migration_helpers` – Remove deprecated plugin (@janko)
284
+
285
+ * `copy` – Remove deprecated plugin (@janko)
286
+
287
+ * `logging` – Remove deprecated plugin (@janko)
288
+
289
+ * `s3` – Remove deprecated `S3#download` method (@janko)
290
+
291
+ * `s3` – Remove deprecated `S3#stream` method (@janko)
292
+
293
+ * `presign_endpoint` – Drop support for presign objects that don't respond to `#to_h` (@janko)
294
+
295
+ * `s3` – Return a Hash in `S3#presign` when method is POST (@janko)
296
+
297
+ * `s3` – Remove `:download` option in `S3#url` (@janko)
298
+
299
+ * `s3` – Remove support for non URI-escaped content disposition values (@janko)
300
+
301
+ * `s3` – Remove `S3#s3` method (@janko)
302
+
303
+ * `s3` – Remove support for specifying `:multipart_threshold` as an integer (@janko)
304
+
305
+ * `s3` – Remove `:host` option on `S3#initialize` (@janko)
306
+
307
+ * `s3` – Drop support for `aws-sdk-s3` versions lower than 1.14 (@janko)
308
+
309
+ * `s3` – Drop support for `aws-sdk` 2.x (@janko)
22
310
 
23
311
  ## 2.19.0 (2019-07-18)
24
312
 
data/README.md CHANGED
@@ -639,7 +639,7 @@ Now we can generate URLs from attached files that will perform the desired
639
639
  processing:
640
640
 
641
641
  ```rb
642
- photo.image.derivation_url(:thumbnail, "600", "400")
642
+ photo.image.derivation_url(:thumbnail, 600, 400)
643
643
  #=> "/derivations/image/thumbnail/600/400/eyJpZCI6ImZvbyIsInN0b3JhZ2UiOiJzdG9yZSJ9?signature=..."
644
644
  ```
645
645
 
@@ -933,13 +933,19 @@ Some plugins add their own instrumentation as well when they detect that the
933
933
  | `data_uri` | instruments data URI parsing |
934
934
 
935
935
  For instrumentation, warnings, and other logging, Shrine uses its internal
936
- logger. You can tell Shrine to use a different logger, for example if you're
937
- using Rails:
936
+ logger. You can tell Shrine to use a different logger. For example, if you're
937
+ using Rails, you might want to tell it to use the Rails logger:
938
938
 
939
939
  ```rb
940
940
  Shrine.logger = Rails.logger
941
941
  ```
942
942
 
943
+ In tests you might want to tell Shrine to log only warnings:
944
+
945
+ ```rb
946
+ Shrine.logger.level = Logger::WARN
947
+ ```
948
+
943
949
  ## Inspiration
944
950
 
945
951
  Shrine was heavily inspired by [Refile] and [Roda]. From Refile it borrows the
data/doc/advantages.md CHANGED
@@ -196,7 +196,7 @@ class ImageUploader < Shrine
196
196
  end
197
197
  ```
198
198
  ```rb
199
- photo.image.derivation_url(:thumbnail, "600", "400")
199
+ photo.image.derivation_url(:thumbnail, 600, 400)
200
200
  #=> ".../thumbnail/600/400/eyJpZCI6ImZvbyIsInN0b3JhZ2UiOiJzdG9yZSJ9?signature=..."
201
201
  ```
202
202
 
data/doc/carrierwave.md CHANGED
@@ -684,7 +684,7 @@ Shrine::Storage::S3.new(
684
684
  The object data can be configured via the `:upload_options` hash:
685
685
 
686
686
  ```rb
687
- Shrine::Storage::S3.new(upload_options: {content_disposition: "attachment"}, **options)
687
+ Shrine::Storage::S3.new(upload_options: { content_disposition: "attachment" }, **options)
688
688
  ```
689
689
 
690
690
  #### `:fog_public`
@@ -692,16 +692,16 @@ Shrine::Storage::S3.new(upload_options: {content_disposition: "attachment"}, **o
692
692
  The object permissions can be configured with the `:acl` upload option:
693
693
 
694
694
  ```rb
695
- Shrine::Storage::S3.new(upload_options: {acl: "private"}, **options)
695
+ Shrine::Storage::S3.new(upload_options: { acl: "private" }, **options)
696
696
  ```
697
697
 
698
698
  #### `:fog_authenticated_url_expiration`
699
699
 
700
700
  The `#url` method accepts the `:expires_in` option, you can set the default
701
- expiration with the `default_url_options` plugin:
701
+ expiration with the `url_options` plugin:
702
702
 
703
703
  ```rb
704
- plugin :default_url_options, store: {expires_in: 600}
704
+ plugin :url_options, store: { expires_in: 600 }
705
705
  ```
706
706
 
707
707
  #### `:fog_use_ssl_for_aws`, `:fog_aws_accelerate`
@@ -0,0 +1,172 @@
1
+ # Writing an Persistence Plugin
2
+
3
+ This guide explains some conventions for writing Shrine plugins that integrate
4
+ with persistence libraries such as Active Record, Sequel, ROM and Mongoid. It
5
+ assumes you've read the [Writing a Plugin] guide.
6
+
7
+ Let's say we're writing a plugin for a persistence library called "Raptor":
8
+
9
+ ```rb
10
+ # lib/shrine/plugins/raptor.rb
11
+
12
+ require "raptor"
13
+
14
+ class Shrine
15
+ module Plugins
16
+ module Raptor
17
+ # ...
18
+ end
19
+
20
+ register_plugin(:raptor, Raptor)
21
+ end
22
+ end
23
+ ```
24
+
25
+ ## Attachment
26
+
27
+ If your database library uses the [Active Record pattern], it's recommended to
28
+ load the [`model`][model] plugin as a dependency.
29
+
30
+ ```rb
31
+ module Shrine::Plugins::Raptor
32
+ def self.load_dependencies(uploader, **)
33
+ uploader.plugin :model # for Active Record pattern
34
+ end
35
+ # ...
36
+ end
37
+ ```
38
+
39
+ Otherwise if it uses the [Repository pattern], you can load the
40
+ [`entity`][entity] plugin as a dependency.
41
+
42
+ ```rb
43
+ module Shrine::Plugins::Raptor
44
+ def self.load_dependencies(uploader, **)
45
+ uploader.plugin :entity # for Repository pattern
46
+ end
47
+ # ...
48
+ end
49
+ ```
50
+
51
+ If you want to add library-specific integration when `Shrine::Attachment` is
52
+ included into a model/entity, it's recommended to do this in the `included`
53
+ hook, so that you can perform this logic only for models/entities that belong
54
+ to that persistence library.
55
+
56
+ ```rb
57
+ module Shrine::Plugins::Raptor
58
+ # ...
59
+ module AttachmentMethods
60
+ def included(klass)
61
+ super
62
+
63
+ return unless klass < ::Raptor::Model
64
+
65
+ # library specific integration
66
+ end
67
+ end
68
+ # ...
69
+ end
70
+ ```
71
+
72
+ ## Attacher
73
+
74
+ ### Persistence
75
+
76
+ It's recommended to implement an `Attacher#persist` method which persists
77
+ the attached file to the record.
78
+
79
+ ```rb
80
+ module Shrine::Plugins::Raptor
81
+ # ...
82
+ module AttacherMethods
83
+ # ...
84
+ def persist(...)
85
+ # persist attachment data
86
+ end
87
+ # ...
88
+ end
89
+ # ...
90
+ end
91
+ ```
92
+
93
+ This way other 3rd-party plugins can use `Attacher#persist` and know it will do
94
+ the right thing regardless of which persistence plugin is used.
95
+
96
+ ### Atomic promotion & persistence
97
+
98
+ When using [`backgrounding`][backgrounding] plugin, it's useful to be able to
99
+ make promotion/persistence atomic. The [`atomic_helpers`][atomic_helpers]
100
+ plugin provides the abstract interface, and in your persistence plugin you can
101
+ provide wrappers.
102
+
103
+ ```rb
104
+ module Shrine::Plugins::Raptor
105
+ def self.load_dependencies(uploader, **)
106
+ # ...
107
+ uploader.plugin :atomic_helpers
108
+ end
109
+ # ...
110
+ module AttacherMethods
111
+ # ...
112
+ def atomic_promote(...)
113
+ # call #abstract_atomic_promote from atomic_helpers plugin
114
+ end
115
+
116
+ def atomic_persist(...)
117
+ # call #abstract_atomic_persist from atomic_helpers plugin
118
+ end
119
+ # ...
120
+ end
121
+ # ...
122
+ end
123
+ ```
124
+
125
+ See the [`activerecord`][activerecord]/[`sequel`][sequel] plugin source code on
126
+ how this integration should look like.
127
+
128
+ ### With other persistence plugins
129
+
130
+ It's recommended to prefix each of the above methods with the name of the
131
+ database library, and make non-prefixed versions aliases.
132
+
133
+ ```rb
134
+ module Shrine::Plugins::Raptor
135
+ # ...
136
+ module AttacherMethods
137
+ # ...
138
+ def raptor_atomic_promote(...)
139
+ # ...
140
+ end
141
+ alias atomic_promote raptor_atomic_promote
142
+
143
+ def raptor_atomic_persist(...)
144
+ # ...
145
+ end
146
+ alias atomic_persist raptor_atomic_persist
147
+
148
+ def raptor_persist(...)
149
+ # ...
150
+ end
151
+ alias persist raptor_persist
152
+ # ...
153
+ end
154
+ # ...
155
+ end
156
+ ```
157
+
158
+ That way the user can always specify from which persistence plugin they're
159
+ calling a certain method, even when multiple persistence plugins are loaded
160
+ simultaneously. The latter can be the case if the user is using multiple
161
+ database libraries in a single application, or if they're transitioning from
162
+ one library to another.
163
+
164
+ [Writing a Plugin]: /doc/creating_plugins.md#readme
165
+ [Active Record pattern]: https://www.martinfowler.com/eaaCatalog/activeRecord.html
166
+ [model]: /doc/plugins/model.md#readme
167
+ [entity]: /doc/plugins/entity.md#readme
168
+ [Repository pattern]: https://martinfowler.com/eaaCatalog/repository.html
169
+ [backgrounding]: /doc/plugins/backgrounding.md#readme
170
+ [atomic_helpers]: /doc/plugins/atomic_helpers.md#readme
171
+ [activerecord]: /lib/shrine/plugins/activerecord.rb
172
+ [sequel]: /lib/shrine/plugins/sequel.rb