activestorage 6.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 activestorage might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/CHANGELOG.md +198 -0
- data/MIT-LICENSE +20 -0
- data/README.md +162 -0
- data/app/assets/javascripts/activestorage.js +942 -0
- data/app/controllers/active_storage/base_controller.rb +8 -0
- data/app/controllers/active_storage/blobs_controller.rb +14 -0
- data/app/controllers/active_storage/direct_uploads_controller.rb +23 -0
- data/app/controllers/active_storage/disk_controller.rb +66 -0
- data/app/controllers/active_storage/representations_controller.rb +14 -0
- data/app/controllers/concerns/active_storage/set_blob.rb +16 -0
- data/app/controllers/concerns/active_storage/set_current.rb +15 -0
- data/app/javascript/activestorage/blob_record.js +73 -0
- data/app/javascript/activestorage/blob_upload.js +35 -0
- data/app/javascript/activestorage/direct_upload.js +48 -0
- data/app/javascript/activestorage/direct_upload_controller.js +67 -0
- data/app/javascript/activestorage/direct_uploads_controller.js +50 -0
- data/app/javascript/activestorage/file_checksum.js +53 -0
- data/app/javascript/activestorage/helpers.js +51 -0
- data/app/javascript/activestorage/index.js +11 -0
- data/app/javascript/activestorage/ujs.js +86 -0
- data/app/jobs/active_storage/analyze_job.rb +12 -0
- data/app/jobs/active_storage/base_job.rb +4 -0
- data/app/jobs/active_storage/purge_job.rb +13 -0
- data/app/models/active_storage/attachment.rb +50 -0
- data/app/models/active_storage/blob.rb +278 -0
- data/app/models/active_storage/blob/analyzable.rb +57 -0
- data/app/models/active_storage/blob/identifiable.rb +31 -0
- data/app/models/active_storage/blob/representable.rb +93 -0
- data/app/models/active_storage/current.rb +5 -0
- data/app/models/active_storage/filename.rb +77 -0
- data/app/models/active_storage/preview.rb +89 -0
- data/app/models/active_storage/variant.rb +131 -0
- data/app/models/active_storage/variation.rb +80 -0
- data/config/routes.rb +32 -0
- data/db/migrate/20170806125915_create_active_storage_tables.rb +26 -0
- data/db/update_migrate/20180723000244_add_foreign_key_constraint_to_active_storage_attachments_for_blob_id.rb +9 -0
- data/lib/active_storage.rb +73 -0
- data/lib/active_storage/analyzer.rb +38 -0
- data/lib/active_storage/analyzer/image_analyzer.rb +52 -0
- data/lib/active_storage/analyzer/null_analyzer.rb +13 -0
- data/lib/active_storage/analyzer/video_analyzer.rb +118 -0
- data/lib/active_storage/attached.rb +25 -0
- data/lib/active_storage/attached/changes.rb +16 -0
- data/lib/active_storage/attached/changes/create_many.rb +46 -0
- data/lib/active_storage/attached/changes/create_one.rb +69 -0
- data/lib/active_storage/attached/changes/create_one_of_many.rb +10 -0
- data/lib/active_storage/attached/changes/delete_many.rb +27 -0
- data/lib/active_storage/attached/changes/delete_one.rb +19 -0
- data/lib/active_storage/attached/many.rb +65 -0
- data/lib/active_storage/attached/model.rb +147 -0
- data/lib/active_storage/attached/one.rb +79 -0
- data/lib/active_storage/downloader.rb +43 -0
- data/lib/active_storage/downloading.rb +47 -0
- data/lib/active_storage/engine.rb +149 -0
- data/lib/active_storage/errors.rb +26 -0
- data/lib/active_storage/gem_version.rb +17 -0
- data/lib/active_storage/log_subscriber.rb +58 -0
- data/lib/active_storage/previewer.rb +84 -0
- data/lib/active_storage/previewer/mupdf_previewer.rb +36 -0
- data/lib/active_storage/previewer/poppler_pdf_previewer.rb +35 -0
- data/lib/active_storage/previewer/video_previewer.rb +26 -0
- data/lib/active_storage/reflection.rb +64 -0
- data/lib/active_storage/service.rb +141 -0
- data/lib/active_storage/service/azure_storage_service.rb +165 -0
- data/lib/active_storage/service/configurator.rb +34 -0
- data/lib/active_storage/service/disk_service.rb +166 -0
- data/lib/active_storage/service/gcs_service.rb +141 -0
- data/lib/active_storage/service/mirror_service.rb +55 -0
- data/lib/active_storage/service/s3_service.rb +116 -0
- data/lib/active_storage/transformers/image_processing_transformer.rb +39 -0
- data/lib/active_storage/transformers/mini_magick_transformer.rb +38 -0
- data/lib/active_storage/transformers/transformer.rb +42 -0
- data/lib/active_storage/version.rb +10 -0
- data/lib/tasks/activestorage.rake +22 -0
- metadata +174 -0
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "image_processing"
|
4
|
+
|
5
|
+
module ActiveStorage
|
6
|
+
module Transformers
|
7
|
+
class ImageProcessingTransformer < Transformer
|
8
|
+
private
|
9
|
+
def process(file, format:)
|
10
|
+
processor.
|
11
|
+
source(file).
|
12
|
+
loader(page: 0).
|
13
|
+
convert(format).
|
14
|
+
apply(operations).
|
15
|
+
call
|
16
|
+
end
|
17
|
+
|
18
|
+
def processor
|
19
|
+
ImageProcessing.const_get(ActiveStorage.variant_processor.to_s.camelize)
|
20
|
+
end
|
21
|
+
|
22
|
+
def operations
|
23
|
+
transformations.each_with_object([]) do |(name, argument), list|
|
24
|
+
if name.to_s == "combine_options"
|
25
|
+
ActiveSupport::Deprecation.warn <<~WARNING.squish
|
26
|
+
Active Storage's ImageProcessing transformer doesn't support :combine_options,
|
27
|
+
as it always generates a single ImageMagick command. Passing :combine_options will
|
28
|
+
not be supported in Rails 6.1.
|
29
|
+
WARNING
|
30
|
+
|
31
|
+
list.concat argument.keep_if { |key, value| value.present? }.to_a
|
32
|
+
elsif argument.present?
|
33
|
+
list << [ name, argument ]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "mini_magick"
|
4
|
+
|
5
|
+
module ActiveStorage
|
6
|
+
module Transformers
|
7
|
+
class MiniMagickTransformer < Transformer
|
8
|
+
private
|
9
|
+
def process(file, format:)
|
10
|
+
image = MiniMagick::Image.new(file.path, file)
|
11
|
+
|
12
|
+
transformations.each do |name, argument_or_subtransformations|
|
13
|
+
image.mogrify do |command|
|
14
|
+
if name.to_s == "combine_options"
|
15
|
+
argument_or_subtransformations.each do |subtransformation_name, subtransformation_argument|
|
16
|
+
pass_transform_argument(command, subtransformation_name, subtransformation_argument)
|
17
|
+
end
|
18
|
+
else
|
19
|
+
pass_transform_argument(command, name, argument_or_subtransformations)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
image.format(format) if format
|
25
|
+
|
26
|
+
image.tempfile.tap(&:open)
|
27
|
+
end
|
28
|
+
|
29
|
+
def pass_transform_argument(command, method, argument)
|
30
|
+
if argument == true
|
31
|
+
command.public_send(method)
|
32
|
+
elsif argument.present?
|
33
|
+
command.public_send(method, argument)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActiveStorage
|
4
|
+
module Transformers
|
5
|
+
# A Transformer applies a set of transformations to an image.
|
6
|
+
#
|
7
|
+
# The following concrete subclasses are included in Active Storage:
|
8
|
+
#
|
9
|
+
# * ActiveStorage::Transformers::ImageProcessingTransformer:
|
10
|
+
# backed by ImageProcessing, a common interface for MiniMagick and ruby-vips
|
11
|
+
#
|
12
|
+
# * ActiveStorage::Transformers::MiniMagickTransformer:
|
13
|
+
# backed by MiniMagick, a wrapper around the ImageMagick CLI
|
14
|
+
class Transformer
|
15
|
+
attr_reader :transformations
|
16
|
+
|
17
|
+
def initialize(transformations)
|
18
|
+
@transformations = transformations
|
19
|
+
end
|
20
|
+
|
21
|
+
# Applies the transformations to the source image in +file+, producing a target image in the
|
22
|
+
# specified +format+. Yields an open Tempfile containing the target image. Closes and unlinks
|
23
|
+
# the output tempfile after yielding to the given block. Returns the result of the block.
|
24
|
+
def transform(file, format:)
|
25
|
+
output = process(file, format: format)
|
26
|
+
|
27
|
+
begin
|
28
|
+
yield output
|
29
|
+
ensure
|
30
|
+
output.close!
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
# Returns an open Tempfile containing a transformed image in the given +format+.
|
36
|
+
# All subclasses implement this method.
|
37
|
+
def process(file, format:) #:doc:
|
38
|
+
raise NotImplementedError
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
namespace :active_storage do
|
4
|
+
# Prevent migration installation task from showing up twice.
|
5
|
+
Rake::Task["install:migrations"].clear_comments
|
6
|
+
|
7
|
+
desc "Copy over the migration needed to the application"
|
8
|
+
task install: :environment do
|
9
|
+
if Rake::Task.task_defined?("active_storage:install:migrations")
|
10
|
+
Rake::Task["active_storage:install:migrations"].invoke
|
11
|
+
else
|
12
|
+
Rake::Task["app:active_storage:install:migrations"].invoke
|
13
|
+
end
|
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
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,174 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: activestorage
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 6.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- David Heinemeier Hansson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-08-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: actionpack
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 6.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 6.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activejob
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 6.0.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 6.0.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: activerecord
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 6.0.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 6.0.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: marcel
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.3.1
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.3.1
|
69
|
+
description: Attach cloud and local files in Rails applications.
|
70
|
+
email: david@loudthinking.com
|
71
|
+
executables: []
|
72
|
+
extensions: []
|
73
|
+
extra_rdoc_files: []
|
74
|
+
files:
|
75
|
+
- CHANGELOG.md
|
76
|
+
- MIT-LICENSE
|
77
|
+
- README.md
|
78
|
+
- app/assets/javascripts/activestorage.js
|
79
|
+
- app/controllers/active_storage/base_controller.rb
|
80
|
+
- app/controllers/active_storage/blobs_controller.rb
|
81
|
+
- app/controllers/active_storage/direct_uploads_controller.rb
|
82
|
+
- app/controllers/active_storage/disk_controller.rb
|
83
|
+
- app/controllers/active_storage/representations_controller.rb
|
84
|
+
- app/controllers/concerns/active_storage/set_blob.rb
|
85
|
+
- app/controllers/concerns/active_storage/set_current.rb
|
86
|
+
- app/javascript/activestorage/blob_record.js
|
87
|
+
- app/javascript/activestorage/blob_upload.js
|
88
|
+
- app/javascript/activestorage/direct_upload.js
|
89
|
+
- app/javascript/activestorage/direct_upload_controller.js
|
90
|
+
- app/javascript/activestorage/direct_uploads_controller.js
|
91
|
+
- app/javascript/activestorage/file_checksum.js
|
92
|
+
- app/javascript/activestorage/helpers.js
|
93
|
+
- app/javascript/activestorage/index.js
|
94
|
+
- app/javascript/activestorage/ujs.js
|
95
|
+
- app/jobs/active_storage/analyze_job.rb
|
96
|
+
- app/jobs/active_storage/base_job.rb
|
97
|
+
- app/jobs/active_storage/purge_job.rb
|
98
|
+
- app/models/active_storage/attachment.rb
|
99
|
+
- app/models/active_storage/blob.rb
|
100
|
+
- app/models/active_storage/blob/analyzable.rb
|
101
|
+
- app/models/active_storage/blob/identifiable.rb
|
102
|
+
- app/models/active_storage/blob/representable.rb
|
103
|
+
- app/models/active_storage/current.rb
|
104
|
+
- app/models/active_storage/filename.rb
|
105
|
+
- app/models/active_storage/preview.rb
|
106
|
+
- app/models/active_storage/variant.rb
|
107
|
+
- app/models/active_storage/variation.rb
|
108
|
+
- config/routes.rb
|
109
|
+
- db/migrate/20170806125915_create_active_storage_tables.rb
|
110
|
+
- db/update_migrate/20180723000244_add_foreign_key_constraint_to_active_storage_attachments_for_blob_id.rb
|
111
|
+
- lib/active_storage.rb
|
112
|
+
- lib/active_storage/analyzer.rb
|
113
|
+
- lib/active_storage/analyzer/image_analyzer.rb
|
114
|
+
- lib/active_storage/analyzer/null_analyzer.rb
|
115
|
+
- lib/active_storage/analyzer/video_analyzer.rb
|
116
|
+
- lib/active_storage/attached.rb
|
117
|
+
- lib/active_storage/attached/changes.rb
|
118
|
+
- lib/active_storage/attached/changes/create_many.rb
|
119
|
+
- lib/active_storage/attached/changes/create_one.rb
|
120
|
+
- lib/active_storage/attached/changes/create_one_of_many.rb
|
121
|
+
- lib/active_storage/attached/changes/delete_many.rb
|
122
|
+
- lib/active_storage/attached/changes/delete_one.rb
|
123
|
+
- lib/active_storage/attached/many.rb
|
124
|
+
- lib/active_storage/attached/model.rb
|
125
|
+
- lib/active_storage/attached/one.rb
|
126
|
+
- lib/active_storage/downloader.rb
|
127
|
+
- lib/active_storage/downloading.rb
|
128
|
+
- lib/active_storage/engine.rb
|
129
|
+
- lib/active_storage/errors.rb
|
130
|
+
- lib/active_storage/gem_version.rb
|
131
|
+
- lib/active_storage/log_subscriber.rb
|
132
|
+
- lib/active_storage/previewer.rb
|
133
|
+
- lib/active_storage/previewer/mupdf_previewer.rb
|
134
|
+
- lib/active_storage/previewer/poppler_pdf_previewer.rb
|
135
|
+
- lib/active_storage/previewer/video_previewer.rb
|
136
|
+
- lib/active_storage/reflection.rb
|
137
|
+
- lib/active_storage/service.rb
|
138
|
+
- lib/active_storage/service/azure_storage_service.rb
|
139
|
+
- lib/active_storage/service/configurator.rb
|
140
|
+
- lib/active_storage/service/disk_service.rb
|
141
|
+
- lib/active_storage/service/gcs_service.rb
|
142
|
+
- lib/active_storage/service/mirror_service.rb
|
143
|
+
- lib/active_storage/service/s3_service.rb
|
144
|
+
- lib/active_storage/transformers/image_processing_transformer.rb
|
145
|
+
- lib/active_storage/transformers/mini_magick_transformer.rb
|
146
|
+
- lib/active_storage/transformers/transformer.rb
|
147
|
+
- lib/active_storage/version.rb
|
148
|
+
- lib/tasks/activestorage.rake
|
149
|
+
homepage: https://rubyonrails.org
|
150
|
+
licenses:
|
151
|
+
- MIT
|
152
|
+
metadata:
|
153
|
+
source_code_uri: https://github.com/rails/rails/tree/v6.0.0/activestorage
|
154
|
+
changelog_uri: https://github.com/rails/rails/blob/v6.0.0/activestorage/CHANGELOG.md
|
155
|
+
post_install_message:
|
156
|
+
rdoc_options: []
|
157
|
+
require_paths:
|
158
|
+
- lib
|
159
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
160
|
+
requirements:
|
161
|
+
- - ">="
|
162
|
+
- !ruby/object:Gem::Version
|
163
|
+
version: 2.5.0
|
164
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
165
|
+
requirements:
|
166
|
+
- - ">="
|
167
|
+
- !ruby/object:Gem::Version
|
168
|
+
version: '0'
|
169
|
+
requirements: []
|
170
|
+
rubygems_version: 3.0.1
|
171
|
+
signing_key:
|
172
|
+
specification_version: 4
|
173
|
+
summary: Local and cloud file storage framework.
|
174
|
+
test_files: []
|