active_storage_variant 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.travis.yml +10 -0
- data/Appraisals +7 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +46 -0
- data/Rakefile +10 -0
- data/active_storage_variant.gemspec +32 -0
- data/gemfiles/.bundle/config +2 -0
- data/gemfiles/rails_6.0.gemfile +7 -0
- data/gemfiles/rails_6.0.gemfile.lock +171 -0
- data/gemfiles/rails_6.1.gemfile +7 -0
- data/gemfiles/rails_6.1.gemfile.lock +174 -0
- data/lib/active_storage_variant/attached.rb +19 -0
- data/lib/active_storage_variant/attachment.rb +21 -0
- data/lib/active_storage_variant/railtie.rb +23 -0
- data/lib/active_storage_variant/reflection.rb +11 -0
- data/lib/active_storage_variant/version.rb +3 -0
- data/lib/active_storage_variant.rb +5 -0
- metadata +162 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1db8766af8941bc1b5ba876be57ddc7c6aa293a190d9da4de36296ac9f3d0244
|
4
|
+
data.tar.gz: 59443960669c3c54d37672723e450a31e2270849e7a45f9342cd1cdee603d2f5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d90d6fcf219269d60cdb84bcff5f5469387118e598c8ef940fb601629f2b6f0c8e248add89b970325638bf21559eae975e38f1012d0b4fb0bfef098afe375758
|
7
|
+
data.tar.gz: fa6eb83f24a0bafc54751a71452fa9e15dabb516364bc0f473e8aa7bc1feb6714f0d4ea69fb2a07a025c50e08b77242e58d06e1e35a335e1b4c468dc2931f7a7
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Appraisals
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2019 Jonas Nicklas, Varvet AB
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# ActiveStorageVariant
|
2
|
+
|
3
|
+
[![Build Status](https://app.travis-ci.com/yfxie/active_storage_variantt.svg?branch=main)](https://app.travis-ci.com/yfxie/active_storage_variantt)
|
4
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/c5fc76fb8a53a1b14901/maintainability)](https://codeclimate.com/github/yfxie/active_storage_variantt/maintainability)
|
5
|
+
[![codecov](https://codecov.io/gh/yfxie/active_storage_variantt/branch/main/graph/badge.svg?token=GJ3JTFRLBI)](https://codecov.io/gh/yfxie/active_storage_variantt)
|
6
|
+
|
7
|
+
The [pre-defined variants feature](https://github.com/rails/rails/pull/39135) is a very convenient feature.
|
8
|
+
It's something like the styles option in Paperclip gem. Without it, it is a pain to use ActiveStorage as an alternative to Paperclip. Thanks to @fatkodima for the contribution.
|
9
|
+
|
10
|
+
The cool feature is introduced in Rails 7.
|
11
|
+
By using this gem, you can take the feature in advance for projects using Rails 6. All configurations are the same, which means when you upgrade to Rails 7 in the future, you can remove this plugin without any effect.
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem "active_storage_variant"
|
17
|
+
```
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
class User < ActiveRecord::Base
|
24
|
+
has_one_attached :avatar, variants: {
|
25
|
+
thumb: { resize: "100x100" },
|
26
|
+
medium: { resize: "300x300", monochrome: true }
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
class Gallery < ActiveRecord::Base
|
31
|
+
has_many_attached :photos, variants: {
|
32
|
+
thumb: { resize: "100x100" },
|
33
|
+
medium: { resize: "300x300", monochrome: true }
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
<%= image_tag user.avatar.variant(:thumb) %>
|
38
|
+
```
|
39
|
+
|
40
|
+
## Contributing
|
41
|
+
|
42
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/yfxie/active_storage_variant.
|
43
|
+
|
44
|
+
# License
|
45
|
+
|
46
|
+
MIT
|
data/Rakefile
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require_relative 'lib/active_storage_variant/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = "active_storage_variant"
|
5
|
+
s.version = ActiveStorageVariant::VERSION
|
6
|
+
s.authors = ["Yi Feng Xie"]
|
7
|
+
s.email = ["yfxie@me.com"]
|
8
|
+
|
9
|
+
s.summary = %q{Use the pre-defined variants feature in Rails 6 projects.}
|
10
|
+
s.description = %q{The pre-defined variants feature is introduced in Rails 7. Using this gem, take the feature in advance for projects using Rails 6.}
|
11
|
+
s.homepage = "https://github.com/yfxie/active_storage_variant/"
|
12
|
+
s.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
13
|
+
|
14
|
+
|
15
|
+
s.metadata["homepage_uri"] = s.homepage
|
16
|
+
s.metadata["source_code_uri"] = s.homepage
|
17
|
+
|
18
|
+
# Specify which files should be added to the gem when it is released.
|
19
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
20
|
+
s.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
21
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
22
|
+
end
|
23
|
+
s.require_paths = ["lib"]
|
24
|
+
|
25
|
+
s.add_dependency "rails", "~> 6.0"
|
26
|
+
s.add_development_dependency "sqlite3"
|
27
|
+
s.add_development_dependency "pry"
|
28
|
+
s.add_development_dependency "image_processing"
|
29
|
+
s.add_development_dependency "appraisal"
|
30
|
+
s.add_development_dependency "simplecov"
|
31
|
+
s.add_development_dependency "codecov"
|
32
|
+
end
|
@@ -0,0 +1,171 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
active_storage_variant (1.0.0)
|
5
|
+
rails (~> 6.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
actioncable (6.0.4.1)
|
11
|
+
actionpack (= 6.0.4.1)
|
12
|
+
nio4r (~> 2.0)
|
13
|
+
websocket-driver (>= 0.6.1)
|
14
|
+
actionmailbox (6.0.4.1)
|
15
|
+
actionpack (= 6.0.4.1)
|
16
|
+
activejob (= 6.0.4.1)
|
17
|
+
activerecord (= 6.0.4.1)
|
18
|
+
activestorage (= 6.0.4.1)
|
19
|
+
activesupport (= 6.0.4.1)
|
20
|
+
mail (>= 2.7.1)
|
21
|
+
actionmailer (6.0.4.1)
|
22
|
+
actionpack (= 6.0.4.1)
|
23
|
+
actionview (= 6.0.4.1)
|
24
|
+
activejob (= 6.0.4.1)
|
25
|
+
mail (~> 2.5, >= 2.5.4)
|
26
|
+
rails-dom-testing (~> 2.0)
|
27
|
+
actionpack (6.0.4.1)
|
28
|
+
actionview (= 6.0.4.1)
|
29
|
+
activesupport (= 6.0.4.1)
|
30
|
+
rack (~> 2.0, >= 2.0.8)
|
31
|
+
rack-test (>= 0.6.3)
|
32
|
+
rails-dom-testing (~> 2.0)
|
33
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
34
|
+
actiontext (6.0.4.1)
|
35
|
+
actionpack (= 6.0.4.1)
|
36
|
+
activerecord (= 6.0.4.1)
|
37
|
+
activestorage (= 6.0.4.1)
|
38
|
+
activesupport (= 6.0.4.1)
|
39
|
+
nokogiri (>= 1.8.5)
|
40
|
+
actionview (6.0.4.1)
|
41
|
+
activesupport (= 6.0.4.1)
|
42
|
+
builder (~> 3.1)
|
43
|
+
erubi (~> 1.4)
|
44
|
+
rails-dom-testing (~> 2.0)
|
45
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
46
|
+
activejob (6.0.4.1)
|
47
|
+
activesupport (= 6.0.4.1)
|
48
|
+
globalid (>= 0.3.6)
|
49
|
+
activemodel (6.0.4.1)
|
50
|
+
activesupport (= 6.0.4.1)
|
51
|
+
activerecord (6.0.4.1)
|
52
|
+
activemodel (= 6.0.4.1)
|
53
|
+
activesupport (= 6.0.4.1)
|
54
|
+
activestorage (6.0.4.1)
|
55
|
+
actionpack (= 6.0.4.1)
|
56
|
+
activejob (= 6.0.4.1)
|
57
|
+
activerecord (= 6.0.4.1)
|
58
|
+
marcel (~> 1.0.0)
|
59
|
+
activesupport (6.0.4.1)
|
60
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
61
|
+
i18n (>= 0.7, < 2)
|
62
|
+
minitest (~> 5.1)
|
63
|
+
tzinfo (~> 1.1)
|
64
|
+
zeitwerk (~> 2.2, >= 2.2.2)
|
65
|
+
appraisal (2.4.1)
|
66
|
+
bundler
|
67
|
+
rake
|
68
|
+
thor (>= 0.14.0)
|
69
|
+
builder (3.2.4)
|
70
|
+
codecov (0.6.0)
|
71
|
+
simplecov (>= 0.15, < 0.22)
|
72
|
+
coderay (1.1.3)
|
73
|
+
concurrent-ruby (1.1.9)
|
74
|
+
crass (1.0.6)
|
75
|
+
docile (1.4.0)
|
76
|
+
erubi (1.10.0)
|
77
|
+
ffi (1.15.4)
|
78
|
+
globalid (0.5.2)
|
79
|
+
activesupport (>= 5.0)
|
80
|
+
i18n (1.8.11)
|
81
|
+
concurrent-ruby (~> 1.0)
|
82
|
+
image_processing (1.12.1)
|
83
|
+
mini_magick (>= 4.9.5, < 5)
|
84
|
+
ruby-vips (>= 2.0.17, < 3)
|
85
|
+
loofah (2.12.0)
|
86
|
+
crass (~> 1.0.2)
|
87
|
+
nokogiri (>= 1.5.9)
|
88
|
+
mail (2.7.1)
|
89
|
+
mini_mime (>= 0.1.1)
|
90
|
+
marcel (1.0.2)
|
91
|
+
method_source (1.0.0)
|
92
|
+
mini_magick (4.11.0)
|
93
|
+
mini_mime (1.1.2)
|
94
|
+
minitest (5.14.4)
|
95
|
+
nio4r (2.5.8)
|
96
|
+
nokogiri (1.12.5-x86_64-darwin)
|
97
|
+
racc (~> 1.4)
|
98
|
+
pry (0.14.1)
|
99
|
+
coderay (~> 1.1)
|
100
|
+
method_source (~> 1.0)
|
101
|
+
racc (1.6.0)
|
102
|
+
rack (2.2.3)
|
103
|
+
rack-test (1.1.0)
|
104
|
+
rack (>= 1.0, < 3)
|
105
|
+
rails (6.0.4.1)
|
106
|
+
actioncable (= 6.0.4.1)
|
107
|
+
actionmailbox (= 6.0.4.1)
|
108
|
+
actionmailer (= 6.0.4.1)
|
109
|
+
actionpack (= 6.0.4.1)
|
110
|
+
actiontext (= 6.0.4.1)
|
111
|
+
actionview (= 6.0.4.1)
|
112
|
+
activejob (= 6.0.4.1)
|
113
|
+
activemodel (= 6.0.4.1)
|
114
|
+
activerecord (= 6.0.4.1)
|
115
|
+
activestorage (= 6.0.4.1)
|
116
|
+
activesupport (= 6.0.4.1)
|
117
|
+
bundler (>= 1.3.0)
|
118
|
+
railties (= 6.0.4.1)
|
119
|
+
sprockets-rails (>= 2.0.0)
|
120
|
+
rails-dom-testing (2.0.3)
|
121
|
+
activesupport (>= 4.2.0)
|
122
|
+
nokogiri (>= 1.6)
|
123
|
+
rails-html-sanitizer (1.4.2)
|
124
|
+
loofah (~> 2.3)
|
125
|
+
railties (6.0.4.1)
|
126
|
+
actionpack (= 6.0.4.1)
|
127
|
+
activesupport (= 6.0.4.1)
|
128
|
+
method_source
|
129
|
+
rake (>= 0.8.7)
|
130
|
+
thor (>= 0.20.3, < 2.0)
|
131
|
+
rake (13.0.6)
|
132
|
+
ruby-vips (2.0.17)
|
133
|
+
ffi (~> 1.9)
|
134
|
+
simplecov (0.21.2)
|
135
|
+
docile (~> 1.1)
|
136
|
+
simplecov-html (~> 0.11)
|
137
|
+
simplecov_json_formatter (~> 0.1)
|
138
|
+
simplecov-html (0.12.3)
|
139
|
+
simplecov_json_formatter (0.1.3)
|
140
|
+
sprockets (4.0.2)
|
141
|
+
concurrent-ruby (~> 1.0)
|
142
|
+
rack (> 1, < 3)
|
143
|
+
sprockets-rails (3.3.0)
|
144
|
+
actionpack (>= 5.2)
|
145
|
+
activesupport (>= 5.2)
|
146
|
+
sprockets (>= 3.0.0)
|
147
|
+
sqlite3 (1.4.2)
|
148
|
+
thor (1.1.0)
|
149
|
+
thread_safe (0.3.6)
|
150
|
+
tzinfo (1.2.9)
|
151
|
+
thread_safe (~> 0.1)
|
152
|
+
websocket-driver (0.7.5)
|
153
|
+
websocket-extensions (>= 0.1.0)
|
154
|
+
websocket-extensions (0.1.5)
|
155
|
+
zeitwerk (2.5.1)
|
156
|
+
|
157
|
+
PLATFORMS
|
158
|
+
ruby
|
159
|
+
|
160
|
+
DEPENDENCIES
|
161
|
+
active_storage_variant!
|
162
|
+
appraisal
|
163
|
+
codecov
|
164
|
+
image_processing
|
165
|
+
pry
|
166
|
+
rails (~> 6.0.0)
|
167
|
+
simplecov
|
168
|
+
sqlite3
|
169
|
+
|
170
|
+
BUNDLED WITH
|
171
|
+
2.1.4
|
@@ -0,0 +1,174 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
active_storage_variant (1.0.0)
|
5
|
+
rails (~> 6.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
actioncable (6.1.4.1)
|
11
|
+
actionpack (= 6.1.4.1)
|
12
|
+
activesupport (= 6.1.4.1)
|
13
|
+
nio4r (~> 2.0)
|
14
|
+
websocket-driver (>= 0.6.1)
|
15
|
+
actionmailbox (6.1.4.1)
|
16
|
+
actionpack (= 6.1.4.1)
|
17
|
+
activejob (= 6.1.4.1)
|
18
|
+
activerecord (= 6.1.4.1)
|
19
|
+
activestorage (= 6.1.4.1)
|
20
|
+
activesupport (= 6.1.4.1)
|
21
|
+
mail (>= 2.7.1)
|
22
|
+
actionmailer (6.1.4.1)
|
23
|
+
actionpack (= 6.1.4.1)
|
24
|
+
actionview (= 6.1.4.1)
|
25
|
+
activejob (= 6.1.4.1)
|
26
|
+
activesupport (= 6.1.4.1)
|
27
|
+
mail (~> 2.5, >= 2.5.4)
|
28
|
+
rails-dom-testing (~> 2.0)
|
29
|
+
actionpack (6.1.4.1)
|
30
|
+
actionview (= 6.1.4.1)
|
31
|
+
activesupport (= 6.1.4.1)
|
32
|
+
rack (~> 2.0, >= 2.0.9)
|
33
|
+
rack-test (>= 0.6.3)
|
34
|
+
rails-dom-testing (~> 2.0)
|
35
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
36
|
+
actiontext (6.1.4.1)
|
37
|
+
actionpack (= 6.1.4.1)
|
38
|
+
activerecord (= 6.1.4.1)
|
39
|
+
activestorage (= 6.1.4.1)
|
40
|
+
activesupport (= 6.1.4.1)
|
41
|
+
nokogiri (>= 1.8.5)
|
42
|
+
actionview (6.1.4.1)
|
43
|
+
activesupport (= 6.1.4.1)
|
44
|
+
builder (~> 3.1)
|
45
|
+
erubi (~> 1.4)
|
46
|
+
rails-dom-testing (~> 2.0)
|
47
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
48
|
+
activejob (6.1.4.1)
|
49
|
+
activesupport (= 6.1.4.1)
|
50
|
+
globalid (>= 0.3.6)
|
51
|
+
activemodel (6.1.4.1)
|
52
|
+
activesupport (= 6.1.4.1)
|
53
|
+
activerecord (6.1.4.1)
|
54
|
+
activemodel (= 6.1.4.1)
|
55
|
+
activesupport (= 6.1.4.1)
|
56
|
+
activestorage (6.1.4.1)
|
57
|
+
actionpack (= 6.1.4.1)
|
58
|
+
activejob (= 6.1.4.1)
|
59
|
+
activerecord (= 6.1.4.1)
|
60
|
+
activesupport (= 6.1.4.1)
|
61
|
+
marcel (~> 1.0.0)
|
62
|
+
mini_mime (>= 1.1.0)
|
63
|
+
activesupport (6.1.4.1)
|
64
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
65
|
+
i18n (>= 1.6, < 2)
|
66
|
+
minitest (>= 5.1)
|
67
|
+
tzinfo (~> 2.0)
|
68
|
+
zeitwerk (~> 2.3)
|
69
|
+
appraisal (2.4.1)
|
70
|
+
bundler
|
71
|
+
rake
|
72
|
+
thor (>= 0.14.0)
|
73
|
+
builder (3.2.4)
|
74
|
+
codecov (0.6.0)
|
75
|
+
simplecov (>= 0.15, < 0.22)
|
76
|
+
coderay (1.1.3)
|
77
|
+
concurrent-ruby (1.1.9)
|
78
|
+
crass (1.0.6)
|
79
|
+
docile (1.4.0)
|
80
|
+
erubi (1.10.0)
|
81
|
+
ffi (1.15.4)
|
82
|
+
globalid (0.5.2)
|
83
|
+
activesupport (>= 5.0)
|
84
|
+
i18n (1.8.11)
|
85
|
+
concurrent-ruby (~> 1.0)
|
86
|
+
image_processing (1.12.1)
|
87
|
+
mini_magick (>= 4.9.5, < 5)
|
88
|
+
ruby-vips (>= 2.0.17, < 3)
|
89
|
+
loofah (2.12.0)
|
90
|
+
crass (~> 1.0.2)
|
91
|
+
nokogiri (>= 1.5.9)
|
92
|
+
mail (2.7.1)
|
93
|
+
mini_mime (>= 0.1.1)
|
94
|
+
marcel (1.0.2)
|
95
|
+
method_source (1.0.0)
|
96
|
+
mini_magick (4.11.0)
|
97
|
+
mini_mime (1.1.2)
|
98
|
+
minitest (5.14.4)
|
99
|
+
nio4r (2.5.8)
|
100
|
+
nokogiri (1.12.5-x86_64-darwin)
|
101
|
+
racc (~> 1.4)
|
102
|
+
pry (0.14.1)
|
103
|
+
coderay (~> 1.1)
|
104
|
+
method_source (~> 1.0)
|
105
|
+
racc (1.6.0)
|
106
|
+
rack (2.2.3)
|
107
|
+
rack-test (1.1.0)
|
108
|
+
rack (>= 1.0, < 3)
|
109
|
+
rails (6.1.4.1)
|
110
|
+
actioncable (= 6.1.4.1)
|
111
|
+
actionmailbox (= 6.1.4.1)
|
112
|
+
actionmailer (= 6.1.4.1)
|
113
|
+
actionpack (= 6.1.4.1)
|
114
|
+
actiontext (= 6.1.4.1)
|
115
|
+
actionview (= 6.1.4.1)
|
116
|
+
activejob (= 6.1.4.1)
|
117
|
+
activemodel (= 6.1.4.1)
|
118
|
+
activerecord (= 6.1.4.1)
|
119
|
+
activestorage (= 6.1.4.1)
|
120
|
+
activesupport (= 6.1.4.1)
|
121
|
+
bundler (>= 1.15.0)
|
122
|
+
railties (= 6.1.4.1)
|
123
|
+
sprockets-rails (>= 2.0.0)
|
124
|
+
rails-dom-testing (2.0.3)
|
125
|
+
activesupport (>= 4.2.0)
|
126
|
+
nokogiri (>= 1.6)
|
127
|
+
rails-html-sanitizer (1.4.2)
|
128
|
+
loofah (~> 2.3)
|
129
|
+
railties (6.1.4.1)
|
130
|
+
actionpack (= 6.1.4.1)
|
131
|
+
activesupport (= 6.1.4.1)
|
132
|
+
method_source
|
133
|
+
rake (>= 0.13)
|
134
|
+
thor (~> 1.0)
|
135
|
+
rake (13.0.6)
|
136
|
+
ruby-vips (2.0.17)
|
137
|
+
ffi (~> 1.9)
|
138
|
+
simplecov (0.21.2)
|
139
|
+
docile (~> 1.1)
|
140
|
+
simplecov-html (~> 0.11)
|
141
|
+
simplecov_json_formatter (~> 0.1)
|
142
|
+
simplecov-html (0.12.3)
|
143
|
+
simplecov_json_formatter (0.1.3)
|
144
|
+
sprockets (4.0.2)
|
145
|
+
concurrent-ruby (~> 1.0)
|
146
|
+
rack (> 1, < 3)
|
147
|
+
sprockets-rails (3.3.0)
|
148
|
+
actionpack (>= 5.2)
|
149
|
+
activesupport (>= 5.2)
|
150
|
+
sprockets (>= 3.0.0)
|
151
|
+
sqlite3 (1.4.2)
|
152
|
+
thor (1.1.0)
|
153
|
+
tzinfo (2.0.4)
|
154
|
+
concurrent-ruby (~> 1.0)
|
155
|
+
websocket-driver (0.7.5)
|
156
|
+
websocket-extensions (>= 0.1.0)
|
157
|
+
websocket-extensions (0.1.5)
|
158
|
+
zeitwerk (2.5.1)
|
159
|
+
|
160
|
+
PLATFORMS
|
161
|
+
ruby
|
162
|
+
|
163
|
+
DEPENDENCIES
|
164
|
+
active_storage_variant!
|
165
|
+
appraisal
|
166
|
+
codecov
|
167
|
+
image_processing
|
168
|
+
pry
|
169
|
+
rails (~> 6.1.0)
|
170
|
+
simplecov
|
171
|
+
sqlite3
|
172
|
+
|
173
|
+
BUNDLED WITH
|
174
|
+
2.1.4
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module ActiveStorageVariant
|
2
|
+
module Attached
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
class_methods do
|
6
|
+
def has_one_attached(name, *arg)
|
7
|
+
super
|
8
|
+
reflection = self.reflect_on_attachment(name)
|
9
|
+
yield reflection if block_given?
|
10
|
+
end
|
11
|
+
|
12
|
+
def has_many_attached(name, *arg)
|
13
|
+
super
|
14
|
+
reflection = self.reflect_on_attachment(name)
|
15
|
+
yield reflection if block_given?
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module ActiveStorageVariant
|
2
|
+
module Attachment
|
3
|
+
def variant(transformations)
|
4
|
+
case transformations
|
5
|
+
when Symbol
|
6
|
+
variant_name = transformations
|
7
|
+
transformations = variants.fetch(variant_name) do
|
8
|
+
record_model_name = record.to_model.model_name.name
|
9
|
+
raise ArgumentError, "Cannot find variant :#{variant_name} for #{record_model_name}##{name}"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
super(transformations)
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
def variants
|
18
|
+
record.attachment_reflections[name]&.variants
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "rails/railtie"
|
2
|
+
|
3
|
+
module ActiveStorageVariant
|
4
|
+
class Railtie < ::Rails::Railtie
|
5
|
+
initializer "active_storage_variant.attached", after: "active_storage.attached" do
|
6
|
+
require "active_storage_variant/attached"
|
7
|
+
ActiveRecord::Base.include ActiveStorageVariant::Attached
|
8
|
+
end
|
9
|
+
|
10
|
+
initializer "active_storage_variant.reflection" do
|
11
|
+
require "active_storage_variant/reflection"
|
12
|
+
ActiveStorage::Reflection::HasManyAttachedReflection.include ActiveStorageVariant::Reflection
|
13
|
+
ActiveStorage::Reflection::HasOneAttachedReflection.include ActiveStorageVariant::Reflection
|
14
|
+
end
|
15
|
+
|
16
|
+
initializer "active_storage_variant.attachment" do
|
17
|
+
require "active_storage_variant/attachment"
|
18
|
+
ActiveSupport.on_load(:active_storage_attachment) do
|
19
|
+
include ActiveStorageVariant::Attachment
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,162 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: active_storage_variant
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yi Feng Xie
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-11-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '6.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'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sqlite3
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: image_processing
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: appraisal
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: simplecov
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: codecov
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: The pre-defined variants feature is introduced in Rails 7. Using this
|
112
|
+
gem, take the feature in advance for projects using Rails 6.
|
113
|
+
email:
|
114
|
+
- yfxie@me.com
|
115
|
+
executables: []
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files: []
|
118
|
+
files:
|
119
|
+
- ".gitignore"
|
120
|
+
- ".travis.yml"
|
121
|
+
- Appraisals
|
122
|
+
- Gemfile
|
123
|
+
- LICENSE.txt
|
124
|
+
- README.md
|
125
|
+
- Rakefile
|
126
|
+
- active_storage_variant.gemspec
|
127
|
+
- gemfiles/.bundle/config
|
128
|
+
- gemfiles/rails_6.0.gemfile
|
129
|
+
- gemfiles/rails_6.0.gemfile.lock
|
130
|
+
- gemfiles/rails_6.1.gemfile
|
131
|
+
- gemfiles/rails_6.1.gemfile.lock
|
132
|
+
- lib/active_storage_variant.rb
|
133
|
+
- lib/active_storage_variant/attached.rb
|
134
|
+
- lib/active_storage_variant/attachment.rb
|
135
|
+
- lib/active_storage_variant/railtie.rb
|
136
|
+
- lib/active_storage_variant/reflection.rb
|
137
|
+
- lib/active_storage_variant/version.rb
|
138
|
+
homepage: https://github.com/yfxie/active_storage_variant/
|
139
|
+
licenses: []
|
140
|
+
metadata:
|
141
|
+
homepage_uri: https://github.com/yfxie/active_storage_variant/
|
142
|
+
source_code_uri: https://github.com/yfxie/active_storage_variant/
|
143
|
+
post_install_message:
|
144
|
+
rdoc_options: []
|
145
|
+
require_paths:
|
146
|
+
- lib
|
147
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - ">="
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: 2.3.0
|
152
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
153
|
+
requirements:
|
154
|
+
- - ">="
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
version: '0'
|
157
|
+
requirements: []
|
158
|
+
rubygems_version: 3.0.8
|
159
|
+
signing_key:
|
160
|
+
specification_version: 4
|
161
|
+
summary: Use the pre-defined variants feature in Rails 6 projects.
|
162
|
+
test_files: []
|