nochmal 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/nochmal/adapters/base.rb +1 -1
- data/lib/nochmal/adapters/carrierwave_analyze.rb +31 -13
- data/lib/nochmal/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f9b976eb7a45473b64deeeffcef948ddca95452100b674f5cffaefbb6ff5ede
|
4
|
+
data.tar.gz: 2c1817332f6361fd60b3a7238c49e69b1d9c9bf8a2bde854c773ca1de76087d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6df5eedb1f79563e6d1fc5931f8e3b07f079ac10e0be06e51c4ef64a7f76c7a22c8ae4c4e51a63e16a00baad22cd2f440e5bdc434683eb6fe6be2668c475b3ca
|
7
|
+
data.tar.gz: bd88f5d4a586dc31223c4ec180b6f4f024a179fc950d85b5c8d1bb8e5c51f1bc7d9c47721a0cdca6cad02e2b1c2ec58870bbee497dd5c45156202657db9dca75
|
@@ -11,10 +11,14 @@ module Nochmal
|
|
11
11
|
@variants_present = false
|
12
12
|
end
|
13
13
|
|
14
|
+
def to_storage_service(to = @to)
|
15
|
+
@to_storage_service ||= ActiveStorage.new(from: :unused, to: to).to_storage_service
|
16
|
+
end
|
17
|
+
|
14
18
|
def attachment_types_for(model)
|
15
19
|
@types[model] ||= model.uploaders.map do |uploader, uploader_class|
|
16
20
|
@uploaders[model] = { uploader => uploader_class }
|
17
|
-
model.has_one_attached prefixed(uploader), service:
|
21
|
+
model.has_one_attached prefixed(uploader), service: to_storage_service.name
|
18
22
|
|
19
23
|
uploader
|
20
24
|
end
|
@@ -35,7 +39,8 @@ module Nochmal
|
|
35
39
|
def general_notes
|
36
40
|
[
|
37
41
|
display_helper_notes,
|
38
|
-
gemfile_additions
|
42
|
+
gemfile_additions,
|
43
|
+
final_thank_you
|
39
44
|
].join("\n")
|
40
45
|
end
|
41
46
|
|
@@ -149,8 +154,8 @@ module Nochmal
|
|
149
154
|
pic
|
150
155
|
end
|
151
156
|
end
|
152
|
-
elsif model.respond_to?(:"carrierwave_
|
153
|
-
model.send(:"carrierwave_
|
157
|
+
elsif model.respond_to?(:"carrierwave_\#{name}") && model.send(:"carrierwave_\#{name}")
|
158
|
+
model.send(:"carrierwave_\#{name}_url")
|
154
159
|
else
|
155
160
|
upload_default(default)
|
156
161
|
end
|
@@ -160,16 +165,16 @@ module Nochmal
|
|
160
165
|
def upload_name(model, name)
|
161
166
|
if model.send(name.to_sym).attached?
|
162
167
|
model.send(name.to_sym).filename.to_s
|
163
|
-
elsif model.respond_to?(:"carrierwave_
|
164
|
-
model.send(:"carrierwave_
|
168
|
+
elsif model.respond_to?(:"carrierwave_\#{name}_identifier")
|
169
|
+
model.send(:"carrierwave_\#{name}_identifier")
|
165
170
|
end
|
166
171
|
end
|
167
172
|
|
168
173
|
def upload_exists?(model, name)
|
169
174
|
return true if model.send(name.to_sym).attached?
|
170
175
|
|
171
|
-
if model.respond_to?(:"carrierwave_
|
172
|
-
model.send(:"carrierwave_
|
176
|
+
if model.respond_to?(:"carrierwave_\#{name}")
|
177
|
+
model.send(:"carrierwave_\#{name}").present?
|
173
178
|
else
|
174
179
|
false
|
175
180
|
end
|
@@ -180,15 +185,15 @@ module Nochmal
|
|
180
185
|
def upload_variant(model, name, variant, default: model.name.underscore)
|
181
186
|
if model.send(name.to_sym).attached?
|
182
187
|
model.send(name.to_sym).variant(variant.to_sym)
|
183
|
-
elsif model.respond_to?(:"carrierwave_
|
184
|
-
model.send(:"carrierwave_
|
188
|
+
elsif model.respond_to?(:"carrierwave_\#{name}")
|
189
|
+
model.send(:"carrierwave_\#{name}").send(variant.to_sym).url
|
185
190
|
else
|
186
191
|
upload_default([default, variant].compact.map(&:to_s).join('_'))
|
187
192
|
end
|
188
193
|
end
|
189
194
|
|
190
195
|
def upload_default(png_name = 'profil')
|
191
|
-
ActionController::Base.helpers.asset_pack_path("media/images
|
196
|
+
ActionController::Base.helpers.asset_pack_path("media/images/\#{png_name}.png")
|
192
197
|
end
|
193
198
|
|
194
199
|
def extract_image_dimensions(width_x_height)
|
@@ -201,15 +206,16 @@ module Nochmal
|
|
201
206
|
end
|
202
207
|
|
203
208
|
def gemfile_additions
|
204
|
-
variants_dependencies = <<~TEXT
|
209
|
+
variants_dependencies = <<~TEXT.chomp
|
205
210
|
gem 'active_storage_variant' # provides person.avatar.variant(:thumb) for Rails < 7
|
206
211
|
TEXT
|
207
212
|
|
208
|
-
validation_dependencies = <<~TEXT
|
213
|
+
validation_dependencies = <<~TEXT.chomp
|
209
214
|
gem 'active_storage_validations' # validate filesize, dimensions and content-type
|
210
215
|
TEXT
|
211
216
|
|
212
217
|
<<~TEXT
|
218
|
+
---------------------------------------------------------
|
213
219
|
The following gems are suggested to have in your Gemfile:
|
214
220
|
|
215
221
|
gem 'nochmal' # only needed until the migration to the desired ActiveStorage-Backend is complete
|
@@ -217,6 +223,18 @@ module Nochmal
|
|
217
223
|
#{validation_dependencies}
|
218
224
|
TEXT
|
219
225
|
end
|
226
|
+
|
227
|
+
def final_thank_you
|
228
|
+
<<~TEXT
|
229
|
+
|
230
|
+
---------------------------------------------------------
|
231
|
+
Thank you for using "nochmal" today.
|
232
|
+
|
233
|
+
If this is the first thing you read, please read again
|
234
|
+
from the top. :-)
|
235
|
+
---------------------------------------------------------
|
236
|
+
TEXT
|
237
|
+
end
|
220
238
|
end
|
221
239
|
end
|
222
240
|
end
|
data/lib/nochmal/version.rb
CHANGED