activestorage 5.2.7.1 → 6.1.4.6

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

Potentially problematic release.


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

Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +225 -93
  3. data/MIT-LICENSE +1 -1
  4. data/README.md +43 -8
  5. data/app/assets/javascripts/activestorage.js +5 -2
  6. data/app/controllers/active_storage/base_controller.rb +13 -4
  7. data/app/controllers/active_storage/blobs/proxy_controller.rb +14 -0
  8. data/app/controllers/active_storage/{blobs_controller.rb → blobs/redirect_controller.rb} +3 -3
  9. data/app/controllers/active_storage/direct_uploads_controller.rb +2 -2
  10. data/app/controllers/active_storage/disk_controller.rb +13 -22
  11. data/app/controllers/active_storage/representations/base_controller.rb +14 -0
  12. data/app/controllers/active_storage/representations/proxy_controller.rb +13 -0
  13. data/app/controllers/active_storage/{representations_controller.rb → representations/redirect_controller.rb} +3 -5
  14. data/app/controllers/concerns/active_storage/file_server.rb +18 -0
  15. data/app/controllers/concerns/active_storage/set_blob.rb +1 -1
  16. data/app/controllers/concerns/active_storage/set_current.rb +15 -0
  17. data/app/controllers/concerns/active_storage/set_headers.rb +12 -0
  18. data/app/javascript/activestorage/blob_record.js +7 -2
  19. data/app/jobs/active_storage/analyze_job.rb +5 -0
  20. data/app/jobs/active_storage/base_job.rb +0 -1
  21. data/app/jobs/active_storage/mirror_job.rb +15 -0
  22. data/app/jobs/active_storage/purge_job.rb +3 -0
  23. data/app/models/active_storage/attachment.rb +35 -16
  24. data/app/models/active_storage/blob/analyzable.rb +6 -2
  25. data/app/models/active_storage/blob/identifiable.rb +7 -6
  26. data/app/models/active_storage/blob/representable.rb +36 -6
  27. data/app/models/active_storage/blob.rb +186 -68
  28. data/app/models/active_storage/filename.rb +0 -6
  29. data/app/models/active_storage/preview.rb +37 -12
  30. data/app/models/active_storage/record.rb +7 -0
  31. data/app/models/active_storage/variant.rb +53 -67
  32. data/app/models/active_storage/variant_record.rb +8 -0
  33. data/app/models/active_storage/variant_with_record.rb +54 -0
  34. data/app/models/active_storage/variation.rb +30 -94
  35. data/config/routes.rb +66 -15
  36. data/db/migrate/20170806125915_create_active_storage_tables.rb +14 -5
  37. data/db/update_migrate/20190112182829_add_service_name_to_active_storage_blobs.rb +17 -0
  38. data/db/update_migrate/20191206030411_create_active_storage_variant_records.rb +11 -0
  39. data/lib/active_storage/analyzer/image_analyzer.rb +14 -4
  40. data/lib/active_storage/analyzer/null_analyzer.rb +4 -0
  41. data/lib/active_storage/analyzer/video_analyzer.rb +17 -8
  42. data/lib/active_storage/analyzer.rb +15 -4
  43. data/lib/active_storage/attached/changes/create_many.rb +47 -0
  44. data/lib/active_storage/attached/changes/create_one.rb +82 -0
  45. data/lib/active_storage/attached/changes/create_one_of_many.rb +10 -0
  46. data/lib/active_storage/attached/changes/delete_many.rb +27 -0
  47. data/lib/active_storage/attached/changes/delete_one.rb +19 -0
  48. data/lib/active_storage/attached/changes.rb +16 -0
  49. data/lib/active_storage/attached/many.rb +19 -12
  50. data/lib/active_storage/attached/model.rb +212 -0
  51. data/lib/active_storage/attached/one.rb +19 -21
  52. data/lib/active_storage/attached.rb +7 -22
  53. data/lib/active_storage/downloader.rb +43 -0
  54. data/lib/active_storage/engine.rb +60 -38
  55. data/lib/active_storage/errors.rb +25 -3
  56. data/lib/active_storage/gem_version.rb +4 -4
  57. data/lib/active_storage/log_subscriber.rb +6 -0
  58. data/lib/active_storage/previewer/mupdf_previewer.rb +3 -3
  59. data/lib/active_storage/previewer/poppler_pdf_previewer.rb +3 -3
  60. data/lib/active_storage/previewer/video_previewer.rb +17 -10
  61. data/lib/active_storage/previewer.rb +34 -14
  62. data/lib/active_storage/reflection.rb +64 -0
  63. data/lib/active_storage/service/azure_storage_service.rb +65 -44
  64. data/lib/active_storage/service/configurator.rb +6 -2
  65. data/lib/active_storage/service/disk_service.rb +57 -44
  66. data/lib/active_storage/service/gcs_service.rb +68 -64
  67. data/lib/active_storage/service/mirror_service.rb +31 -7
  68. data/lib/active_storage/service/registry.rb +32 -0
  69. data/lib/active_storage/service/s3_service.rb +56 -24
  70. data/lib/active_storage/service.rb +44 -12
  71. data/lib/active_storage/transformers/image_processing_transformer.rb +45 -0
  72. data/lib/active_storage/transformers/transformer.rb +39 -0
  73. data/lib/active_storage.rb +31 -296
  74. data/lib/tasks/activestorage.rake +11 -0
  75. metadata +82 -16
  76. data/app/models/active_storage/filename/parameters.rb +0 -36
  77. data/lib/active_storage/attached/macros.rb +0 -110
  78. data/lib/active_storage/downloading.rb +0 -39
metadata CHANGED
@@ -1,43 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activestorage
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.7.1
4
+ version: 6.1.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-26 00:00:00.000000000 Z
11
+ date: 2022-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 6.1.4.6
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 6.1.4.6
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: actionpack
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
31
  - - '='
18
32
  - !ruby/object:Gem::Version
19
- version: 5.2.7.1
33
+ version: 6.1.4.6
20
34
  type: :runtime
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
24
38
  - - '='
25
39
  - !ruby/object:Gem::Version
26
- version: 5.2.7.1
40
+ version: 6.1.4.6
41
+ - !ruby/object:Gem::Dependency
42
+ name: activejob
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 6.1.4.6
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 6.1.4.6
27
55
  - !ruby/object:Gem::Dependency
28
56
  name: activerecord
29
57
  requirement: !ruby/object:Gem::Requirement
30
58
  requirements:
31
59
  - - '='
32
60
  - !ruby/object:Gem::Version
33
- version: 5.2.7.1
61
+ version: 6.1.4.6
34
62
  type: :runtime
35
63
  prerelease: false
36
64
  version_requirements: !ruby/object:Gem::Requirement
37
65
  requirements:
38
66
  - - '='
39
67
  - !ruby/object:Gem::Version
40
- version: 5.2.7.1
68
+ version: 6.1.4.6
41
69
  - !ruby/object:Gem::Dependency
42
70
  name: marcel
43
71
  requirement: !ruby/object:Gem::Requirement
@@ -52,6 +80,20 @@ dependencies:
52
80
  - - "~>"
53
81
  - !ruby/object:Gem::Version
54
82
  version: 1.0.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: mini_mime
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 1.1.0
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 1.1.0
55
97
  description: Attach cloud and local files in Rails applications.
56
98
  email: david@loudthinking.com
57
99
  executables: []
@@ -63,11 +105,17 @@ files:
63
105
  - README.md
64
106
  - app/assets/javascripts/activestorage.js
65
107
  - app/controllers/active_storage/base_controller.rb
66
- - app/controllers/active_storage/blobs_controller.rb
108
+ - app/controllers/active_storage/blobs/proxy_controller.rb
109
+ - app/controllers/active_storage/blobs/redirect_controller.rb
67
110
  - app/controllers/active_storage/direct_uploads_controller.rb
68
111
  - app/controllers/active_storage/disk_controller.rb
69
- - app/controllers/active_storage/representations_controller.rb
112
+ - app/controllers/active_storage/representations/base_controller.rb
113
+ - app/controllers/active_storage/representations/proxy_controller.rb
114
+ - app/controllers/active_storage/representations/redirect_controller.rb
115
+ - app/controllers/concerns/active_storage/file_server.rb
70
116
  - app/controllers/concerns/active_storage/set_blob.rb
117
+ - app/controllers/concerns/active_storage/set_current.rb
118
+ - app/controllers/concerns/active_storage/set_headers.rb
71
119
  - app/javascript/activestorage/blob_record.js
72
120
  - app/javascript/activestorage/blob_upload.js
73
121
  - app/javascript/activestorage/direct_upload.js
@@ -79,6 +127,7 @@ files:
79
127
  - app/javascript/activestorage/ujs.js
80
128
  - app/jobs/active_storage/analyze_job.rb
81
129
  - app/jobs/active_storage/base_job.rb
130
+ - app/jobs/active_storage/mirror_job.rb
82
131
  - app/jobs/active_storage/purge_job.rb
83
132
  - app/models/active_storage/attachment.rb
84
133
  - app/models/active_storage/blob.rb
@@ -87,22 +136,32 @@ files:
87
136
  - app/models/active_storage/blob/representable.rb
88
137
  - app/models/active_storage/current.rb
89
138
  - app/models/active_storage/filename.rb
90
- - app/models/active_storage/filename/parameters.rb
91
139
  - app/models/active_storage/preview.rb
140
+ - app/models/active_storage/record.rb
92
141
  - app/models/active_storage/variant.rb
142
+ - app/models/active_storage/variant_record.rb
143
+ - app/models/active_storage/variant_with_record.rb
93
144
  - app/models/active_storage/variation.rb
94
145
  - config/routes.rb
95
146
  - db/migrate/20170806125915_create_active_storage_tables.rb
147
+ - db/update_migrate/20190112182829_add_service_name_to_active_storage_blobs.rb
148
+ - db/update_migrate/20191206030411_create_active_storage_variant_records.rb
96
149
  - lib/active_storage.rb
97
150
  - lib/active_storage/analyzer.rb
98
151
  - lib/active_storage/analyzer/image_analyzer.rb
99
152
  - lib/active_storage/analyzer/null_analyzer.rb
100
153
  - lib/active_storage/analyzer/video_analyzer.rb
101
154
  - lib/active_storage/attached.rb
102
- - lib/active_storage/attached/macros.rb
155
+ - lib/active_storage/attached/changes.rb
156
+ - lib/active_storage/attached/changes/create_many.rb
157
+ - lib/active_storage/attached/changes/create_one.rb
158
+ - lib/active_storage/attached/changes/create_one_of_many.rb
159
+ - lib/active_storage/attached/changes/delete_many.rb
160
+ - lib/active_storage/attached/changes/delete_one.rb
103
161
  - lib/active_storage/attached/many.rb
162
+ - lib/active_storage/attached/model.rb
104
163
  - lib/active_storage/attached/one.rb
105
- - lib/active_storage/downloading.rb
164
+ - lib/active_storage/downloader.rb
106
165
  - lib/active_storage/engine.rb
107
166
  - lib/active_storage/errors.rb
108
167
  - lib/active_storage/gem_version.rb
@@ -111,21 +170,28 @@ files:
111
170
  - lib/active_storage/previewer/mupdf_previewer.rb
112
171
  - lib/active_storage/previewer/poppler_pdf_previewer.rb
113
172
  - lib/active_storage/previewer/video_previewer.rb
173
+ - lib/active_storage/reflection.rb
114
174
  - lib/active_storage/service.rb
115
175
  - lib/active_storage/service/azure_storage_service.rb
116
176
  - lib/active_storage/service/configurator.rb
117
177
  - lib/active_storage/service/disk_service.rb
118
178
  - lib/active_storage/service/gcs_service.rb
119
179
  - lib/active_storage/service/mirror_service.rb
180
+ - lib/active_storage/service/registry.rb
120
181
  - lib/active_storage/service/s3_service.rb
182
+ - lib/active_storage/transformers/image_processing_transformer.rb
183
+ - lib/active_storage/transformers/transformer.rb
121
184
  - lib/active_storage/version.rb
122
185
  - lib/tasks/activestorage.rake
123
- homepage: http://rubyonrails.org
186
+ homepage: https://rubyonrails.org
124
187
  licenses:
125
188
  - MIT
126
189
  metadata:
127
- source_code_uri: https://github.com/rails/rails/tree/v5.2.7.1/activestorage
128
- changelog_uri: https://github.com/rails/rails/blob/v5.2.7.1/activestorage/CHANGELOG.md
190
+ bug_tracker_uri: https://github.com/rails/rails/issues
191
+ changelog_uri: https://github.com/rails/rails/blob/v6.1.4.6/activestorage/CHANGELOG.md
192
+ documentation_uri: https://api.rubyonrails.org/v6.1.4.6/
193
+ mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
194
+ source_code_uri: https://github.com/rails/rails/tree/v6.1.4.6/activestorage
129
195
  post_install_message:
130
196
  rdoc_options: []
131
197
  require_paths:
@@ -134,14 +200,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
134
200
  requirements:
135
201
  - - ">="
136
202
  - !ruby/object:Gem::Version
137
- version: 2.2.2
203
+ version: 2.5.0
138
204
  required_rubygems_version: !ruby/object:Gem::Requirement
139
205
  requirements:
140
206
  - - ">="
141
207
  - !ruby/object:Gem::Version
142
208
  version: '0'
143
209
  requirements: []
144
- rubygems_version: 3.1.6
210
+ rubygems_version: 3.2.22
145
211
  signing_key:
146
212
  specification_version: 4
147
213
  summary: Local and cloud file storage framework.
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class ActiveStorage::Filename::Parameters #:nodoc:
4
- attr_reader :filename
5
-
6
- def initialize(filename)
7
- @filename = filename
8
- end
9
-
10
- def combined
11
- "#{ascii}; #{utf8}"
12
- end
13
-
14
- TRADITIONAL_ESCAPED_CHAR = /[^ A-Za-z0-9!#$+.^_`|~-]/
15
-
16
- def ascii
17
- 'filename="' + percent_escape(I18n.transliterate(filename.sanitized), TRADITIONAL_ESCAPED_CHAR) + '"'
18
- end
19
-
20
- RFC_5987_ESCAPED_CHAR = /[^A-Za-z0-9!#$&+.^_`|~-]/
21
-
22
- def utf8
23
- "filename*=UTF-8''" + percent_escape(filename.sanitized, RFC_5987_ESCAPED_CHAR)
24
- end
25
-
26
- def to_s
27
- combined
28
- end
29
-
30
- private
31
- def percent_escape(string, pattern)
32
- string.gsub(pattern) do |char|
33
- char.bytes.map { |byte| "%%%02X" % byte }.join
34
- end
35
- end
36
- end
@@ -1,110 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ActiveStorage
4
- # Provides the class-level DSL for declaring that an Active Record model has attached blobs.
5
- module Attached::Macros
6
- # Specifies the relation between a single attachment and the model.
7
- #
8
- # class User < ActiveRecord::Base
9
- # has_one_attached :avatar
10
- # end
11
- #
12
- # There is no column defined on the model side, Active Storage takes
13
- # care of the mapping between your records and the attachment.
14
- #
15
- # To avoid N+1 queries, you can include the attached blobs in your query like so:
16
- #
17
- # User.with_attached_avatar
18
- #
19
- # Under the covers, this relationship is implemented as a +has_one+ association to a
20
- # ActiveStorage::Attachment record and a +has_one-through+ association to a
21
- # ActiveStorage::Blob record. These associations are available as +avatar_attachment+
22
- # and +avatar_blob+. But you shouldn't need to work with these associations directly in
23
- # most circumstances.
24
- #
25
- # The system has been designed to having you go through the ActiveStorage::Attached::One
26
- # proxy that provides the dynamic proxy to the associations and factory methods, like +attach+.
27
- #
28
- # If the +:dependent+ option isn't set, the attachment will be purged
29
- # (i.e. destroyed) whenever the record is destroyed.
30
- def has_one_attached(name, dependent: :purge_later)
31
- class_eval <<-CODE, __FILE__, __LINE__ + 1
32
- def #{name}
33
- @active_storage_attached_#{name} ||= ActiveStorage::Attached::One.new("#{name}", self, dependent: #{dependent == :purge_later ? ":purge_later" : "false"})
34
- end
35
-
36
- def #{name}=(attachable)
37
- #{name}.attach(attachable)
38
- end
39
- CODE
40
-
41
- has_one :"#{name}_attachment", -> { where(name: name) }, class_name: "ActiveStorage::Attachment", as: :record, inverse_of: :record, dependent: false
42
- has_one :"#{name}_blob", through: :"#{name}_attachment", class_name: "ActiveStorage::Blob", source: :blob
43
-
44
- scope :"with_attached_#{name}", -> { includes("#{name}_attachment": :blob) }
45
-
46
- if dependent == :purge_later
47
- after_destroy_commit { public_send(name).purge_later }
48
- else
49
- before_destroy { public_send(name).detach }
50
- end
51
- end
52
-
53
- # Specifies the relation between multiple attachments and the model.
54
- #
55
- # class Gallery < ActiveRecord::Base
56
- # has_many_attached :photos
57
- # end
58
- #
59
- # There are no columns defined on the model side, Active Storage takes
60
- # care of the mapping between your records and the attachments.
61
- #
62
- # To avoid N+1 queries, you can include the attached blobs in your query like so:
63
- #
64
- # Gallery.where(user: Current.user).with_attached_photos
65
- #
66
- # Under the covers, this relationship is implemented as a +has_many+ association to a
67
- # ActiveStorage::Attachment record and a +has_many-through+ association to a
68
- # ActiveStorage::Blob record. These associations are available as +photos_attachments+
69
- # and +photos_blobs+. But you shouldn't need to work with these associations directly in
70
- # most circumstances.
71
- #
72
- # The system has been designed to having you go through the ActiveStorage::Attached::Many
73
- # proxy that provides the dynamic proxy to the associations and factory methods, like +#attach+.
74
- #
75
- # If the +:dependent+ option isn't set, all the attachments will be purged
76
- # (i.e. destroyed) whenever the record is destroyed.
77
- def has_many_attached(name, dependent: :purge_later)
78
- class_eval <<-CODE, __FILE__, __LINE__ + 1
79
- def #{name}
80
- @active_storage_attached_#{name} ||= ActiveStorage::Attached::Many.new("#{name}", self, dependent: #{dependent == :purge_later ? ":purge_later" : "false"})
81
- end
82
-
83
- def #{name}=(attachables)
84
- #{name}.attach(attachables)
85
- end
86
- CODE
87
-
88
- has_many :"#{name}_attachments", -> { where(name: name) }, as: :record, class_name: "ActiveStorage::Attachment", inverse_of: :record, dependent: false do
89
- def purge
90
- each(&:purge)
91
- reset
92
- end
93
-
94
- def purge_later
95
- each(&:purge_later)
96
- reset
97
- end
98
- end
99
- has_many :"#{name}_blobs", through: :"#{name}_attachments", class_name: "ActiveStorage::Blob", source: :blob
100
-
101
- scope :"with_attached_#{name}", -> { includes("#{name}_attachments": :blob) }
102
-
103
- if dependent == :purge_later
104
- after_destroy_commit { public_send(name).purge_later }
105
- else
106
- before_destroy { public_send(name).detach }
107
- end
108
- end
109
- end
110
- end
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "tmpdir"
4
-
5
- module ActiveStorage
6
- module Downloading
7
- private
8
- # Opens a new tempfile in #tempdir and copies blob data into it. Yields the tempfile.
9
- def download_blob_to_tempfile #:doc:
10
- open_tempfile_for_blob do |file|
11
- download_blob_to file
12
- yield file
13
- end
14
- end
15
-
16
- def open_tempfile_for_blob
17
- tempfile = Tempfile.open([ "ActiveStorage", blob.filename.extension_with_delimiter ], tempdir)
18
-
19
- begin
20
- yield tempfile
21
- ensure
22
- tempfile.close!
23
- end
24
- end
25
-
26
- # Efficiently downloads blob data into the given file.
27
- def download_blob_to(file) #:doc:
28
- file.binmode
29
- blob.download { |chunk| file.write(chunk) }
30
- file.flush
31
- file.rewind
32
- end
33
-
34
- # Returns the directory in which tempfiles should be opened. Defaults to +Dir.tmpdir+.
35
- def tempdir #:doc:
36
- Dir.tmpdir
37
- end
38
- end
39
- end