activestorage 5.2.4.4 → 6.0.0.beta1

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 (59) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +103 -81
  3. data/MIT-LICENSE +1 -1
  4. data/README.md +6 -5
  5. data/app/assets/javascripts/activestorage.js +4 -1
  6. data/app/controllers/active_storage/base_controller.rb +3 -5
  7. data/app/controllers/active_storage/blobs_controller.rb +1 -1
  8. data/app/controllers/active_storage/disk_controller.rb +4 -1
  9. data/app/controllers/active_storage/representations_controller.rb +1 -1
  10. data/app/controllers/concerns/active_storage/set_current.rb +15 -0
  11. data/app/javascript/activestorage/blob_record.js +6 -1
  12. data/app/jobs/active_storage/analyze_job.rb +4 -0
  13. data/app/jobs/active_storage/base_job.rb +0 -1
  14. data/app/jobs/active_storage/purge_job.rb +3 -0
  15. data/app/models/active_storage/attachment.rb +18 -9
  16. data/app/models/active_storage/blob.rb +63 -22
  17. data/app/models/active_storage/blob/representable.rb +5 -5
  18. data/app/models/active_storage/filename.rb +0 -6
  19. data/app/models/active_storage/preview.rb +3 -3
  20. data/app/models/active_storage/variant.rb +51 -52
  21. data/app/models/active_storage/variation.rb +23 -32
  22. data/config/routes.rb +13 -12
  23. data/db/update_migrate/20180723000244_add_foreign_key_constraint_to_active_storage_attachments_for_blob_id.rb +7 -0
  24. data/lib/active_storage.rb +13 -2
  25. data/lib/active_storage/analyzer.rb +9 -4
  26. data/lib/active_storage/analyzer/video_analyzer.rb +2 -4
  27. data/lib/active_storage/attached.rb +7 -22
  28. data/lib/active_storage/attached/changes.rb +16 -0
  29. data/lib/active_storage/attached/changes/create_many.rb +46 -0
  30. data/lib/active_storage/attached/changes/create_one.rb +68 -0
  31. data/lib/active_storage/attached/changes/create_one_of_many.rb +10 -0
  32. data/lib/active_storage/attached/changes/delete_many.rb +23 -0
  33. data/lib/active_storage/attached/changes/delete_one.rb +19 -0
  34. data/lib/active_storage/attached/many.rb +16 -10
  35. data/lib/active_storage/attached/model.rb +140 -0
  36. data/lib/active_storage/attached/one.rb +16 -19
  37. data/lib/active_storage/downloader.rb +44 -0
  38. data/lib/active_storage/downloading.rb +8 -0
  39. data/lib/active_storage/engine.rb +35 -6
  40. data/lib/active_storage/errors.rb +22 -3
  41. data/lib/active_storage/gem_version.rb +4 -4
  42. data/lib/active_storage/previewer.rb +21 -11
  43. data/lib/active_storage/previewer/poppler_pdf_previewer.rb +1 -1
  44. data/lib/active_storage/previewer/video_previewer.rb +2 -3
  45. data/lib/active_storage/reflection.rb +64 -0
  46. data/lib/active_storage/service.rb +5 -6
  47. data/lib/active_storage/service/azure_storage_service.rb +28 -12
  48. data/lib/active_storage/service/configurator.rb +3 -1
  49. data/lib/active_storage/service/disk_service.rb +20 -16
  50. data/lib/active_storage/service/gcs_service.rb +48 -46
  51. data/lib/active_storage/service/mirror_service.rb +1 -1
  52. data/lib/active_storage/service/s3_service.rb +10 -7
  53. data/lib/active_storage/transformers/image_processing_transformer.rb +39 -0
  54. data/lib/active_storage/transformers/mini_magick_transformer.rb +38 -0
  55. data/lib/active_storage/transformers/transformer.rb +42 -0
  56. data/lib/tasks/activestorage.rake +7 -0
  57. metadata +26 -14
  58. data/app/models/active_storage/filename/parameters.rb +0 -36
  59. data/lib/active_storage/attached/macros.rb +0 -110
@@ -12,4 +12,11 @@ namespace :active_storage do
12
12
  Rake::Task["app:active_storage:install:migrations"].invoke
13
13
  end
14
14
  end
15
+
16
+ # desc "Copy over the migrations needed to the application upgrading"
17
+ task update: :environment do
18
+ ENV["MIGRATIONS_PATH"] = "db/update_migrate"
19
+
20
+ Rake::Task["active_storage:install"].invoke
21
+ end
15
22
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activestorage
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.4.4
4
+ version: 6.0.0.beta1
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: 2020-09-09 00:00:00.000000000 Z
11
+ date: 2019-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 5.2.4.4
19
+ version: 6.0.0.beta1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 5.2.4.4
26
+ version: 6.0.0.beta1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activerecord
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 5.2.4.4
33
+ version: 6.0.0.beta1
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 5.2.4.4
40
+ version: 6.0.0.beta1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: marcel
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -68,6 +68,7 @@ files:
68
68
  - app/controllers/active_storage/disk_controller.rb
69
69
  - app/controllers/active_storage/representations_controller.rb
70
70
  - app/controllers/concerns/active_storage/set_blob.rb
71
+ - app/controllers/concerns/active_storage/set_current.rb
71
72
  - app/javascript/activestorage/blob_record.js
72
73
  - app/javascript/activestorage/blob_upload.js
73
74
  - app/javascript/activestorage/direct_upload.js
@@ -87,21 +88,28 @@ files:
87
88
  - app/models/active_storage/blob/representable.rb
88
89
  - app/models/active_storage/current.rb
89
90
  - app/models/active_storage/filename.rb
90
- - app/models/active_storage/filename/parameters.rb
91
91
  - app/models/active_storage/preview.rb
92
92
  - app/models/active_storage/variant.rb
93
93
  - app/models/active_storage/variation.rb
94
94
  - config/routes.rb
95
95
  - db/migrate/20170806125915_create_active_storage_tables.rb
96
+ - db/update_migrate/20180723000244_add_foreign_key_constraint_to_active_storage_attachments_for_blob_id.rb
96
97
  - lib/active_storage.rb
97
98
  - lib/active_storage/analyzer.rb
98
99
  - lib/active_storage/analyzer/image_analyzer.rb
99
100
  - lib/active_storage/analyzer/null_analyzer.rb
100
101
  - lib/active_storage/analyzer/video_analyzer.rb
101
102
  - lib/active_storage/attached.rb
102
- - lib/active_storage/attached/macros.rb
103
+ - lib/active_storage/attached/changes.rb
104
+ - lib/active_storage/attached/changes/create_many.rb
105
+ - lib/active_storage/attached/changes/create_one.rb
106
+ - lib/active_storage/attached/changes/create_one_of_many.rb
107
+ - lib/active_storage/attached/changes/delete_many.rb
108
+ - lib/active_storage/attached/changes/delete_one.rb
103
109
  - lib/active_storage/attached/many.rb
110
+ - lib/active_storage/attached/model.rb
104
111
  - lib/active_storage/attached/one.rb
112
+ - lib/active_storage/downloader.rb
105
113
  - lib/active_storage/downloading.rb
106
114
  - lib/active_storage/engine.rb
107
115
  - lib/active_storage/errors.rb
@@ -111,6 +119,7 @@ files:
111
119
  - lib/active_storage/previewer/mupdf_previewer.rb
112
120
  - lib/active_storage/previewer/poppler_pdf_previewer.rb
113
121
  - lib/active_storage/previewer/video_previewer.rb
122
+ - lib/active_storage/reflection.rb
114
123
  - lib/active_storage/service.rb
115
124
  - lib/active_storage/service/azure_storage_service.rb
116
125
  - lib/active_storage/service/configurator.rb
@@ -118,14 +127,17 @@ files:
118
127
  - lib/active_storage/service/gcs_service.rb
119
128
  - lib/active_storage/service/mirror_service.rb
120
129
  - lib/active_storage/service/s3_service.rb
130
+ - lib/active_storage/transformers/image_processing_transformer.rb
131
+ - lib/active_storage/transformers/mini_magick_transformer.rb
132
+ - lib/active_storage/transformers/transformer.rb
121
133
  - lib/active_storage/version.rb
122
134
  - lib/tasks/activestorage.rake
123
135
  homepage: http://rubyonrails.org
124
136
  licenses:
125
137
  - MIT
126
138
  metadata:
127
- source_code_uri: https://github.com/rails/rails/tree/v5.2.4.4/activestorage
128
- changelog_uri: https://github.com/rails/rails/blob/v5.2.4.4/activestorage/CHANGELOG.md
139
+ source_code_uri: https://github.com/rails/rails/tree/v6.0.0.beta1/activestorage
140
+ changelog_uri: https://github.com/rails/rails/blob/v6.0.0.beta1/activestorage/CHANGELOG.md
129
141
  post_install_message:
130
142
  rdoc_options: []
131
143
  require_paths:
@@ -134,14 +146,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
134
146
  requirements:
135
147
  - - ">="
136
148
  - !ruby/object:Gem::Version
137
- version: 2.2.2
149
+ version: 2.5.0
138
150
  required_rubygems_version: !ruby/object:Gem::Requirement
139
151
  requirements:
140
- - - ">="
152
+ - - ">"
141
153
  - !ruby/object:Gem::Version
142
- version: '0'
154
+ version: 1.3.1
143
155
  requirements: []
144
- rubygems_version: 3.1.2
156
+ rubygems_version: 3.0.1
145
157
  signing_key:
146
158
  specification_version: 4
147
159
  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