shrine 3.0.0.rc → 3.0.0

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 (167) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +10 -66
  3. data/README.md +39 -1061
  4. data/doc/advantages.md +151 -148
  5. data/doc/attacher.md +12 -30
  6. data/doc/carrierwave.md +150 -115
  7. data/doc/changing_derivatives.md +5 -11
  8. data/doc/changing_location.md +8 -5
  9. data/doc/changing_storage.md +5 -2
  10. data/doc/creating_persistence_plugins.md +9 -6
  11. data/doc/creating_plugins.md +42 -22
  12. data/doc/creating_storages.md +4 -1
  13. data/doc/design.md +7 -5
  14. data/doc/direct_s3.md +9 -4
  15. data/doc/external/articles.md +50 -0
  16. data/doc/external/extensions.md +46 -0
  17. data/doc/external/misc.md +17 -0
  18. data/doc/getting_started.md +1038 -0
  19. data/doc/metadata.md +5 -3
  20. data/doc/multiple_files.md +55 -29
  21. data/doc/paperclip.md +206 -163
  22. data/doc/plugins/activerecord.md +26 -6
  23. data/doc/plugins/add_metadata.md +4 -2
  24. data/doc/plugins/atomic_helpers.md +4 -2
  25. data/doc/plugins/backgrounding.md +83 -44
  26. data/doc/plugins/cached_attachment_data.md +4 -2
  27. data/doc/plugins/column.md +4 -2
  28. data/doc/plugins/data_uri.md +10 -6
  29. data/doc/plugins/default_storage.md +5 -3
  30. data/doc/plugins/default_url.md +4 -2
  31. data/doc/plugins/delete_raw.md +4 -2
  32. data/doc/plugins/derivation_endpoint.md +63 -39
  33. data/doc/plugins/derivatives.md +13 -50
  34. data/doc/plugins/determine_mime_type.md +6 -4
  35. data/doc/plugins/download_endpoint.md +6 -3
  36. data/doc/plugins/dynamic_storage.md +4 -2
  37. data/doc/plugins/entity.md +6 -4
  38. data/doc/plugins/form_assign.md +4 -2
  39. data/doc/plugins/included.md +4 -2
  40. data/doc/plugins/infer_extension.md +6 -4
  41. data/doc/plugins/instrumentation.md +5 -3
  42. data/doc/plugins/keep_files.md +9 -2
  43. data/doc/plugins/metadata_attributes.md +5 -3
  44. data/doc/plugins/mirroring.md +4 -2
  45. data/doc/plugins/model.md +6 -4
  46. data/doc/plugins/module_include.md +4 -2
  47. data/doc/plugins/multi_cache.md +4 -2
  48. data/doc/plugins/persistence.md +5 -3
  49. data/doc/plugins/presign_endpoint.md +6 -2
  50. data/doc/plugins/pretty_location.md +5 -3
  51. data/doc/plugins/processing.md +4 -2
  52. data/doc/plugins/rack_file.md +8 -2
  53. data/doc/plugins/rack_response.md +6 -2
  54. data/doc/plugins/recache.md +4 -2
  55. data/doc/plugins/refresh_metadata.md +5 -3
  56. data/doc/plugins/remote_url.md +26 -5
  57. data/doc/plugins/remove_attachment.md +4 -2
  58. data/doc/plugins/remove_invalid.md +10 -2
  59. data/doc/plugins/restore_cached_data.md +9 -3
  60. data/doc/plugins/sequel.md +26 -6
  61. data/doc/plugins/signature.md +6 -4
  62. data/doc/plugins/store_dimensions.md +6 -4
  63. data/doc/plugins/tempfile.md +4 -2
  64. data/doc/plugins/upload_endpoint.md +6 -2
  65. data/doc/plugins/upload_options.md +6 -4
  66. data/doc/plugins/url_options.md +4 -2
  67. data/doc/plugins/validation.md +7 -3
  68. data/doc/plugins/validation_helpers.md +13 -10
  69. data/doc/plugins/versions.md +4 -8
  70. data/doc/processing.md +27 -9
  71. data/doc/refile.md +119 -127
  72. data/doc/release_notes/1.0.0.md +4 -0
  73. data/doc/release_notes/1.1.0.md +4 -0
  74. data/doc/release_notes/1.2.0.md +4 -0
  75. data/doc/release_notes/1.3.0.md +4 -0
  76. data/doc/release_notes/1.4.0.md +4 -0
  77. data/doc/release_notes/1.4.1.md +4 -0
  78. data/doc/release_notes/1.4.2.md +4 -0
  79. data/doc/release_notes/2.0.0.md +4 -0
  80. data/doc/release_notes/2.0.1.md +4 -0
  81. data/doc/release_notes/2.1.0.md +4 -0
  82. data/doc/release_notes/2.1.1.md +4 -0
  83. data/doc/release_notes/2.10.0.md +4 -0
  84. data/doc/release_notes/2.10.1.md +4 -0
  85. data/doc/release_notes/2.11.0.md +4 -0
  86. data/doc/release_notes/2.12.0.md +4 -0
  87. data/doc/release_notes/2.13.0.md +4 -0
  88. data/doc/release_notes/2.14.0.md +5 -1
  89. data/doc/release_notes/2.15.0.md +10 -6
  90. data/doc/release_notes/2.16.0.md +4 -0
  91. data/doc/release_notes/2.17.0.md +4 -0
  92. data/doc/release_notes/2.18.0.md +4 -0
  93. data/doc/release_notes/2.19.0.md +7 -4
  94. data/doc/release_notes/2.2.0.md +4 -0
  95. data/doc/release_notes/2.3.0.md +4 -0
  96. data/doc/release_notes/2.3.1.md +4 -0
  97. data/doc/release_notes/2.4.0.md +4 -0
  98. data/doc/release_notes/2.4.1.md +4 -0
  99. data/doc/release_notes/2.5.0.md +4 -0
  100. data/doc/release_notes/2.6.0.md +4 -0
  101. data/doc/release_notes/2.6.1.md +4 -0
  102. data/doc/release_notes/2.7.0.md +4 -0
  103. data/doc/release_notes/2.8.0.md +4 -0
  104. data/doc/release_notes/2.9.0.md +4 -0
  105. data/doc/release_notes/3.0.0.md +120 -38
  106. data/doc/retrieving_uploads.md +4 -1
  107. data/doc/securing_uploads.md +4 -1
  108. data/doc/storage/file_system.md +12 -4
  109. data/doc/storage/s3.md +4 -2
  110. data/doc/testing.md +27 -41
  111. data/doc/upgrading_to_3.md +105 -26
  112. data/doc/validation.md +8 -6
  113. data/lib/shrine/attacher.rb +2 -2
  114. data/lib/shrine/attachment.rb +7 -10
  115. data/lib/shrine/plugins/activerecord.rb +10 -10
  116. data/lib/shrine/plugins/add_metadata.rb +1 -3
  117. data/lib/shrine/plugins/atomic_helpers.rb +6 -8
  118. data/lib/shrine/plugins/backgrounding.rb +4 -6
  119. data/lib/shrine/plugins/cached_attachment_data.rb +1 -3
  120. data/lib/shrine/plugins/column.rb +2 -4
  121. data/lib/shrine/plugins/data_uri.rb +1 -3
  122. data/lib/shrine/plugins/default_storage.rb +1 -3
  123. data/lib/shrine/plugins/default_url.rb +1 -3
  124. data/lib/shrine/plugins/delete_raw.rb +1 -3
  125. data/lib/shrine/plugins/derivation_endpoint.rb +3 -4
  126. data/lib/shrine/plugins/derivatives.rb +2 -4
  127. data/lib/shrine/plugins/determine_mime_type.rb +1 -3
  128. data/lib/shrine/plugins/download_endpoint.rb +1 -3
  129. data/lib/shrine/plugins/dynamic_storage.rb +1 -3
  130. data/lib/shrine/plugins/entity.rb +25 -9
  131. data/lib/shrine/plugins/form_assign.rb +1 -3
  132. data/lib/shrine/plugins/included.rb +1 -3
  133. data/lib/shrine/plugins/infer_extension.rb +1 -3
  134. data/lib/shrine/plugins/instrumentation.rb +1 -3
  135. data/lib/shrine/plugins/keep_files.rb +1 -3
  136. data/lib/shrine/plugins/metadata_attributes.rb +1 -3
  137. data/lib/shrine/plugins/mirroring.rb +2 -1
  138. data/lib/shrine/plugins/model.rb +2 -4
  139. data/lib/shrine/plugins/module_include.rb +1 -3
  140. data/lib/shrine/plugins/multi_cache.rb +3 -3
  141. data/lib/shrine/plugins/presign_endpoint.rb +1 -3
  142. data/lib/shrine/plugins/pretty_location.rb +1 -3
  143. data/lib/shrine/plugins/processing.rb +1 -3
  144. data/lib/shrine/plugins/rack_file.rb +1 -3
  145. data/lib/shrine/plugins/rack_response.rb +1 -3
  146. data/lib/shrine/plugins/recache.rb +1 -3
  147. data/lib/shrine/plugins/refresh_metadata.rb +1 -3
  148. data/lib/shrine/plugins/remote_url.rb +1 -3
  149. data/lib/shrine/plugins/remove_attachment.rb +1 -3
  150. data/lib/shrine/plugins/remove_invalid.rb +1 -3
  151. data/lib/shrine/plugins/restore_cached_data.rb +1 -3
  152. data/lib/shrine/plugins/sequel.rb +10 -12
  153. data/lib/shrine/plugins/signature.rb +1 -3
  154. data/lib/shrine/plugins/store_dimensions.rb +1 -3
  155. data/lib/shrine/plugins/tempfile.rb +1 -3
  156. data/lib/shrine/plugins/upload_endpoint.rb +1 -3
  157. data/lib/shrine/plugins/upload_options.rb +1 -3
  158. data/lib/shrine/plugins/url_options.rb +1 -3
  159. data/lib/shrine/plugins/validation.rb +1 -3
  160. data/lib/shrine/plugins/validation_helpers.rb +1 -3
  161. data/lib/shrine/plugins/versions.rb +1 -3
  162. data/lib/shrine/storage/file_system.rb +1 -1
  163. data/lib/shrine/storage/linter.rb +1 -1
  164. data/lib/shrine/storage/memory.rb +2 -1
  165. data/lib/shrine/storage/s3.rb +3 -3
  166. data/lib/shrine/version.rb +1 -1
  167. metadata +8 -4
@@ -2,9 +2,7 @@
2
2
 
3
3
  class Shrine
4
4
  module Plugins
5
- # Documentation lives in [doc/plugins/model.md] on GitHub.
6
- #
7
- # [doc/plugins/model.md]: https://github.com/shrinerb/shrine/blob/master/doc/plugins/model.md
5
+ # Documentation can be found on https://shrinerb.com/docs/plugins/model
8
6
  module Model
9
7
  def self.load_dependencies(uploader, **)
10
8
  uploader.plugin :entity
@@ -61,7 +59,7 @@ class Shrine
61
59
  return super unless model?
62
60
 
63
61
  if !record.instance_variable_get(:"@#{@name}_attacher") || options.any?
64
- attacher = record.class.send(:"#{@name}_attacher", options)
62
+ attacher = class_attacher(options)
65
63
  attacher.load_model(record, @name)
66
64
 
67
65
  record.instance_variable_set(:"@#{@name}_attacher", attacher)
@@ -4,9 +4,7 @@ Shrine.deprecation("The module_include plugin is deprecated and will be removed
4
4
 
5
5
  class Shrine
6
6
  module Plugins
7
- # Documentation lives in [doc/plugins/module_include.md] on GitHub.
8
- #
9
- # [doc/plugins/module_include.md]: https://github.com/shrinerb/shrine/blob/master/doc/plugins/module_include.md
7
+ # Documentation can be found on https://shrinerb.com/docs/plugins/module_include
10
8
  module ModuleInclude
11
9
  module ClassMethods
12
10
  def attachment_module(mod = nil, &block)
@@ -1,8 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Shrine
2
4
  module Plugins
3
- # Documentation lives in [doc/plugins/multi_cache.md] on GitHub.
4
- #
5
- # [doc/plugins/multi_cache.md]: https://github.com/shrinerb/shrine/blob/master/doc/plugins/multi_cache.md
5
+ # Documentation can be found on https://shrinerb.com/docs/plugins/multi_cache
6
6
  module MultiCache
7
7
  def self.configure(uploader, **opts)
8
8
  uploader.opts[:multi_cache] ||= {}
@@ -6,9 +6,7 @@ require "json"
6
6
 
7
7
  class Shrine
8
8
  module Plugins
9
- # Documentation lives in [doc/plugins/presign_endpoint.md] on GitHub.
10
- #
11
- # [doc/plugins/presign_endpoint.md]: https://github.com/shrinerb/shrine/blob/master/doc/plugins/presign_endpoint.md
9
+ # Documentation can be found on https://shrinerb.com/docs/plugins/presign_endpoint
12
10
  module PresignEndpoint
13
11
  def self.configure(uploader, opts = {})
14
12
  uploader.opts[:presign_endpoint] ||= {}
@@ -2,9 +2,7 @@
2
2
 
3
3
  class Shrine
4
4
  module Plugins
5
- # Documentation lives in [doc/plugins/pretty_location.md] on GitHub.
6
- #
7
- # [doc/plugins/pretty_location.md]: https://github.com/shrinerb/shrine/blob/master/doc/plugins/pretty_location.md
5
+ # Documentation can be found on https://shrinerb.com/docs/plugins/pretty_location
8
6
  module PrettyLocation
9
7
  def self.configure(uploader, **opts)
10
8
  uploader.opts[:pretty_location] ||= { identifier: :id }
@@ -4,9 +4,7 @@ Shrine.deprecation("The processing plugin is deprecated and will be removed in S
4
4
 
5
5
  class Shrine
6
6
  module Plugins
7
- # Documentation lives in [doc/plugins/processing.md] on GitHub.
8
- #
9
- # [doc/plugins/processing.md]: https://github.com/shrinerb/shrine/blob/master/doc/plugins/processing.md
7
+ # Documentation can be found on https://shrinerb.com/docs/plugins/processing
10
8
  module Processing
11
9
  def self.configure(uploader)
12
10
  uploader.opts[:processing] ||= {}
@@ -4,9 +4,7 @@ require "forwardable"
4
4
 
5
5
  class Shrine
6
6
  module Plugins
7
- # Documentation lives in [doc/plugins/rack_file.md] on GitHub.
8
- #
9
- # [doc/plugins/rack_file.md]: https://github.com/shrinerb/shrine/blob/master/doc/plugins/rack_file.md
7
+ # Documentation can be found on https://shrinerb.com/docs/plugins/rack_file
10
8
  module RackFile
11
9
  module ClassMethods
12
10
  # Accepts a Rack uploaded file hash and wraps it in an IO object.
@@ -6,9 +6,7 @@ require "digest"
6
6
 
7
7
  class Shrine
8
8
  module Plugins
9
- # Documentation lives in [doc/plugins/rack_response.md] on GitHub.
10
- #
11
- # [doc/plugins/rack_response.md]: https://github.com/shrinerb/shrine/blob/master/doc/plugins/rack_response.md
9
+ # Documentation can be found on https://shrinerb.com/docs/plugins/rack_response
12
10
  module RackResponse
13
11
  module FileMethods
14
12
  # Returns a Rack response triple for the uploaded file.
@@ -4,9 +4,7 @@ Shrine.deprecation("The recache plugin is deprecated and will be removed in Shri
4
4
 
5
5
  class Shrine
6
6
  module Plugins
7
- # Documentation lives in [doc/plugins/recache.md] on GitHub.
8
- #
9
- # [doc/plugins/recache.md]: https://github.com/shrinerb/shrine/blob/master/doc/plugins/recache.md
7
+ # Documentation can be found on https://shrinerb.com/docs/plugins/recache
10
8
  module Recache
11
9
  module AttacherMethods
12
10
  def save
@@ -2,9 +2,7 @@
2
2
 
3
3
  class Shrine
4
4
  module Plugins
5
- # Documentation lives in [doc/plugins/refresh_metadata.md] on GitHub.
6
- #
7
- # [doc/plugins/refresh_metadata.md]: https://github.com/shrinerb/shrine/blob/master/doc/plugins/refresh_metadata.md
5
+ # Documentation can be found on https://shrinerb.com/docs/plugins/refresh_metadata
8
6
  module RefreshMetadata
9
7
  module AttacherMethods
10
8
  def refresh_metadata!(**options)
@@ -4,9 +4,7 @@ require "down"
4
4
 
5
5
  class Shrine
6
6
  module Plugins
7
- # Documentation lives in [doc/plugins/remote_url.md] on GitHub.
8
- #
9
- # [doc/plugins/remote_url.md]: https://github.com/shrinerb/shrine/blob/master/doc/plugins/remote_url.md
7
+ # Documentation can be found on https://shrinerb.com/docs/plugins/remote_url
10
8
  module RemoteUrl
11
9
  class DownloadError < Error; end
12
10
 
@@ -2,9 +2,7 @@
2
2
 
3
3
  class Shrine
4
4
  module Plugins
5
- # Documentation lives in [doc/plugins/remove_attachment.md] on GitHub.
6
- #
7
- # [doc/plugins/remove_attachment.md]: https://github.com/shrinerb/shrine/blob/master/doc/plugins/remove_attachment.md
5
+ # Documentation can be found on https://shrinerb.com/docs/plugins/remove_attachment
8
6
  module RemoveAttachment
9
7
  module AttachmentMethods
10
8
  def define_model_methods(name)
@@ -2,9 +2,7 @@
2
2
 
3
3
  class Shrine
4
4
  module Plugins
5
- # Documentation lives in [doc/plugins/remove_invalid.md] on GitHub.
6
- #
7
- # [doc/plugins/remove_invalid.md]: https://github.com/shrinerb/shrine/blob/master/doc/plugins/remove_invalid.md
5
+ # Documentation can be found on https://shrinerb.com/docs/plugins/remove_invalid
8
6
  module RemoveInvalid
9
7
  def self.load_dependencies(uploader)
10
8
  uploader.plugin :validation
@@ -2,9 +2,7 @@
2
2
 
3
3
  class Shrine
4
4
  module Plugins
5
- # Documentation lives in [doc/plugins/restore_cached_data.md] on GitHub.
6
- #
7
- # [doc/plugins/restore_cached_data.md]: https://github.com/shrinerb/shrine/blob/master/doc/plugins/restore_cached_data.md
5
+ # Documentation can be found on https://shrinerb.com/docs/plugins/restore_cached_data
8
6
  module RestoreCachedData
9
7
  def self.load_dependencies(uploader)
10
8
  uploader.plugin :refresh_metadata
@@ -4,9 +4,7 @@ require "sequel"
4
4
 
5
5
  class Shrine
6
6
  module Plugins
7
- # Documentation lives in [doc/plugins/sequel.md] on GitHub.
8
- #
9
- # [doc/plugins/sequel.md]: https://github.com/shrinerb/shrine/blob/master/doc/plugins/sequel.md
7
+ # Documentation can be found on https://shrinerb.com/docs/plugins/sequel
10
8
  module Sequel
11
9
  def self.load_dependencies(uploader, **)
12
10
  uploader.plugin :model
@@ -41,17 +39,23 @@ class Shrine
41
39
  if shrine_class.opts[:sequel][:hooks]
42
40
  define_method :before_save do
43
41
  super()
44
- send(:"#{name}_attacher").send(:sequel_before_save)
42
+ if send(:"#{name}_attacher").changed?
43
+ send(:"#{name}_attacher").send(:sequel_before_save)
44
+ end
45
45
  end
46
46
 
47
47
  define_method :after_save do
48
48
  super()
49
- send(:"#{name}_attacher").send(:sequel_after_save)
49
+ if send(:"#{name}_attacher").changed?
50
+ send(:"#{name}_attacher").send(:sequel_after_save)
51
+ end
50
52
  end
51
53
 
52
54
  define_method :after_destroy do
53
55
  super()
54
- send(:"#{name}_attacher").send(:sequel_after_destroy)
56
+ if send(:"#{name}_attacher").attached?
57
+ send(:"#{name}_attacher").send(:sequel_after_destroy)
58
+ end
55
59
  end
56
60
  end
57
61
 
@@ -85,15 +89,11 @@ class Shrine
85
89
 
86
90
  # Calls Attacher#save. Called before model save.
87
91
  def sequel_before_save
88
- return unless changed?
89
-
90
92
  save
91
93
  end
92
94
 
93
95
  # Finalizes attachment and persists changes. Called after model save.
94
96
  def sequel_after_save
95
- return unless changed?
96
-
97
97
  record.db.after_commit do
98
98
  finalize
99
99
  persist
@@ -102,8 +102,6 @@ class Shrine
102
102
 
103
103
  # Deletes attached files. Called after model destroy.
104
104
  def sequel_after_destroy
105
- return unless attached?
106
-
107
105
  record.db.after_commit do
108
106
  destroy_attached
109
107
  end
@@ -2,9 +2,7 @@
2
2
 
3
3
  class Shrine
4
4
  module Plugins
5
- # Documentation lives in [doc/plugins/signature.md] on GitHub.
6
- #
7
- # [doc/plugins/signature.md]: https://github.com/shrinerb/shrine/blob/master/doc/plugins/signature.md
5
+ # Documentation can be found on https://shrinerb.com/docs/plugins/signature
8
6
  module Signature
9
7
  LOG_SUBSCRIBER = -> (event) do
10
8
  Shrine.logger.info "Signature (#{event.duration}ms) – #{{
@@ -2,9 +2,7 @@
2
2
 
3
3
  class Shrine
4
4
  module Plugins
5
- # Documentation lives in [doc/plugins/store_dimensions.md] on GitHub.
6
- #
7
- # [doc/plugins/store_dimensions.md]: https://github.com/shrinerb/shrine/blob/master/doc/plugins/store_dimensions.md
5
+ # Documentation can be found on https://shrinerb.com/docs/plugins/store_dimensions
8
6
  module StoreDimensions
9
7
  LOG_SUBSCRIBER = -> (event) do
10
8
  Shrine.logger.info "Image Dimensions (#{event.duration}ms) – #{{
@@ -2,9 +2,7 @@
2
2
 
3
3
  class Shrine
4
4
  module Plugins
5
- # Documentation lives in [doc/plugins/tempfile.md] on GitHub.
6
- #
7
- # [doc/plugins/tempfile.md]: https://github.com/shrinerb/shrine/blob/master/doc/plugins/tempfile.md
5
+ # Documentation can be found on https://shrinerb.com/docs/plugins/tempfile
8
6
  module Tempfile
9
7
  module ClassMethods
10
8
  def with_file(io)
@@ -7,9 +7,7 @@ require "digest"
7
7
 
8
8
  class Shrine
9
9
  module Plugins
10
- # Documentation lives in [doc/plugins/upload_endpoint.md] on GitHub.
11
- #
12
- # [doc/plugins/upload_endpoint.md]: https://github.com/shrinerb/shrine/blob/master/doc/plugins/upload_endpoint.md
10
+ # Documentation can be found on https://shrinerb.com/docs/plugins/upload_endpoint
13
11
  module UploadEndpoint
14
12
  def self.load_dependencies(uploader, opts = {})
15
13
  uploader.plugin :rack_file
@@ -2,9 +2,7 @@
2
2
 
3
3
  class Shrine
4
4
  module Plugins
5
- # Documentation lives in [doc/plugins/upload_options.md] on GitHub.
6
- #
7
- # [doc/plugins/upload_options.md]: https://github.com/shrinerb/shrine/blob/master/doc/plugins/upload_options.md
5
+ # Documentation can be found on https://shrinerb.com/docs/plugins/upload_options
8
6
  module UploadOptions
9
7
  def self.configure(uploader, options = {})
10
8
  uploader.opts[:upload_options] ||= {}
@@ -2,9 +2,7 @@
2
2
 
3
3
  class Shrine
4
4
  module Plugins
5
- # Documentation lives in [doc/plugins/url_options.md] on GitHub.
6
- #
7
- # [doc/plugins/url_options.md]: https://github.com/shrinerb/shrine/blob/master/doc/plugins/url_options.md
5
+ # Documentation can be found on https://shrinerb.com/docs/plugins/url_options
8
6
  module UrlOptions
9
7
  def self.configure(uploader, **options)
10
8
  uploader.opts[:url_options] ||= {}
@@ -2,9 +2,7 @@
2
2
 
3
3
  class Shrine
4
4
  module Plugins
5
- # Documentation lives in [doc/plugins/validation.md] on GitHub.
6
- #
7
- # [doc/plugins/validation.md]: https://github.com/shrinerb/shrine/blob/master/doc/plugins/validation.md
5
+ # Documentation can be found on https://shrinerb.com/docs/plugins/validation
8
6
  module Validation
9
7
  module AttacherClassMethods
10
8
  # Block that is executed in context of Shrine::Attacher during
@@ -2,9 +2,7 @@
2
2
 
3
3
  class Shrine
4
4
  module Plugins
5
- # Documentation lives in [doc/plugins/validation_helpers.md] on GitHub.
6
- #
7
- # [doc/plugins/validation_helpers.md]: https://github.com/shrinerb/shrine/blob/master/doc/plugins/validation_helpers.md
5
+ # Documentation can be found on https://shrinerb.com/docs/plugins/validation_helpers
8
6
  module ValidationHelpers
9
7
  DEFAULT_MESSAGES = {
10
8
  max_size: -> (max) { "size must not be greater than #{PRETTY_FILESIZE.call(max)}" },
@@ -4,9 +4,7 @@ Shrine.deprecation("The versions plugin is deprecated and will be removed in Shr
4
4
 
5
5
  class Shrine
6
6
  module Plugins
7
- # Documentation lives in [doc/plugins/versions.md] on GitHub.
8
- #
9
- # [doc/plugins/versions.md]: https://github.com/shrinerb/shrine/blob/master/doc/plugins/versions.md
7
+ # Documentation can be found on https://shrinerb.com/docs/plugins/versions
10
8
  module Versions
11
9
  def self.load_dependencies(uploader, **)
12
10
  uploader.plugin :processing
@@ -91,7 +91,7 @@ class Shrine
91
91
 
92
92
  # Deletes the specified directory on the filesystem.
93
93
  #
94
- # file_system.delete_prefixed("somekey/derivatives")
94
+ # file_system.delete_prefixed("somekey/derivatives/")
95
95
  def delete_prefixed(delete_prefix)
96
96
  FileUtils.rm_rf directory.join(delete_prefix)
97
97
  end
@@ -47,7 +47,7 @@ class Shrine
47
47
  storage.upload(io_factory.call, id2 = "a/a/b")
48
48
  storage.upload(io_factory.call, id3 = "a/aaa/a")
49
49
 
50
- lint_delete_prefixed(prefix: "a/a",
50
+ lint_delete_prefixed(prefix: "a/a/",
51
51
  expect_deleted: [id1, id2],
52
52
  expect_remaining: [id3])
53
53
 
@@ -35,7 +35,8 @@ class Shrine
35
35
  end
36
36
 
37
37
  def delete_prefixed(delete_prefix)
38
- store.delete_if { |k, _v| k.start_with?(delete_prefix + "/") }
38
+ delete_prefix = delete_prefix.chomp("/") + "/"
39
+ store.delete_if { |key, _value| key.start_with?(delete_prefix) }
39
40
  end
40
41
 
41
42
  def clear!
@@ -207,12 +207,12 @@ class Shrine
207
207
 
208
208
  # Deletes objects at keys starting with the specified prefix.
209
209
  #
210
- # s3.delete_prefixed("somekey/derivatives")
210
+ # s3.delete_prefixed("somekey/derivatives/")
211
211
  def delete_prefixed(delete_prefix)
212
212
  # We need to make sure to combine with storage prefix, and
213
213
  # that it ends in '/' cause S3 can be squirrely about matching interior.
214
- absolute_prefix = [*prefix, delete_prefix + "/"].join("/")
215
- bucket.objects(prefix: absolute_prefix).batch_delete!
214
+ delete_prefix = delete_prefix.chomp("/") + "/"
215
+ bucket.objects(prefix: [*prefix, delete_prefix].join("/")).batch_delete!
216
216
  end
217
217
 
218
218
  # If block is given, deletes all objects from the storage for which the
@@ -9,7 +9,7 @@ class Shrine
9
9
  MAJOR = 3
10
10
  MINOR = 0
11
11
  TINY = 0
12
- PRE = "rc"
12
+ PRE = nil
13
13
 
14
14
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
15
15
  end
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.0.rc
4
+ version: 3.0.0
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-09-28 00:00:00.000000000 Z
11
+ date: 2019-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: down
@@ -375,6 +375,10 @@ files:
375
375
  - doc/creating_storages.md
376
376
  - doc/design.md
377
377
  - doc/direct_s3.md
378
+ - doc/external/articles.md
379
+ - doc/external/extensions.md
380
+ - doc/external/misc.md
381
+ - doc/getting_started.md
378
382
  - doc/metadata.md
379
383
  - doc/multiple_files.md
380
384
  - doc/paperclip.md
@@ -550,9 +554,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
550
554
  version: '2.3'
551
555
  required_rubygems_version: !ruby/object:Gem::Requirement
552
556
  requirements:
553
- - - ">"
557
+ - - ">="
554
558
  - !ruby/object:Gem::Version
555
- version: 1.3.1
559
+ version: '0'
556
560
  requirements: []
557
561
  rubygems_version: 3.0.3
558
562
  signing_key: