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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b70999f48275f14acd8a9d6fe2e04b5cd0c5d7aec648a667456135b088fc65f2
4
- data.tar.gz: be84cc7695bc93daa47292eb0fafb57bffa774cef0b45228a3d33d1052754522
3
+ metadata.gz: 5f9b976eb7a45473b64deeeffcef948ddca95452100b674f5cffaefbb6ff5ede
4
+ data.tar.gz: 2c1817332f6361fd60b3a7238c49e69b1d9c9bf8a2bde854c773ca1de76087d2
5
5
  SHA512:
6
- metadata.gz: 9255a50d4a7b0fc7d9cd378eb2515bf5af52e84b7427c946cc1043cf70f61865b54d96d8e462784f32963b99c96992c903a98e9f1eae4a778c07cae9bed1a679
7
- data.tar.gz: 17977431f4aaa86a73e228be840cee3ffa4fa44e316acc13eb0745c0cfbbde83d1bc78a17527f940aea1783e34539af6206233d8a5664348f97ce0a3262e347b
6
+ metadata.gz: 6df5eedb1f79563e6d1fc5931f8e3b07f079ac10e0be06e51c4ef64a7f76c7a22c8ae4c4e51a63e16a00baad22cd2f440e5bdc434683eb6fe6be2668c475b3ca
7
+ data.tar.gz: bd88f5d4a586dc31223c4ec180b6f4f024a179fc950d85b5c8d1bb8e5c51f1bc7d9c47721a0cdca6cad02e2b1c2ec58870bbee497dd5c45156202657db9dca75
@@ -66,7 +66,7 @@ module Nochmal
66
66
  def type_completed(_model, _type); end
67
67
 
68
68
  # called after reuploading/listing/counting each record/attachment
69
- def item_completed(_item, _type); end
69
+ def item_completed(_item, _type, _status); end
70
70
 
71
71
  # actions
72
72
 
@@ -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: @to_storage_service.name
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_#{name}") && model.send(:"carrierwave_#{name}")
153
- model.send(:"carrierwave_#{name}_url")
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_#{name}_identifier")
164
- model.send(:"carrierwave_#{name}_identifier")
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_#{name}")
172
- model.send(:"carrierwave_#{name}").present?
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_#{name}")
184
- model.send(:"carrierwave_#{name}").send(variant.to_sym).url
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/#{png_name}.png")
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nochmal
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nochmal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Burkhalter