carrierwave 1.3.2 → 3.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 carrierwave might be problematic. Click here for more details.

Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +235 -91
  3. data/lib/carrierwave/compatibility/paperclip.rb +4 -2
  4. data/lib/carrierwave/downloader/base.rb +101 -0
  5. data/lib/carrierwave/downloader/remote_file.rb +68 -0
  6. data/lib/carrierwave/locale/en.yml +9 -6
  7. data/lib/carrierwave/mount.rb +48 -61
  8. data/lib/carrierwave/mounter.rb +165 -77
  9. data/lib/carrierwave/orm/activerecord.rb +13 -55
  10. data/lib/carrierwave/processing/mini_magick.rb +108 -123
  11. data/lib/carrierwave/processing/rmagick.rb +11 -15
  12. data/lib/carrierwave/processing/vips.rb +284 -0
  13. data/lib/carrierwave/processing.rb +1 -0
  14. data/lib/carrierwave/sanitized_file.rb +60 -66
  15. data/lib/carrierwave/storage/abstract.rb +5 -5
  16. data/lib/carrierwave/storage/file.rb +6 -5
  17. data/lib/carrierwave/storage/fog.rb +101 -62
  18. data/lib/carrierwave/storage.rb +1 -0
  19. data/lib/carrierwave/test/matchers.rb +11 -7
  20. data/lib/carrierwave/uploader/cache.rb +40 -24
  21. data/lib/carrierwave/uploader/callbacks.rb +1 -1
  22. data/lib/carrierwave/uploader/configuration.rb +38 -19
  23. data/lib/carrierwave/uploader/content_type_allowlist.rb +62 -0
  24. data/lib/carrierwave/uploader/content_type_denylist.rb +62 -0
  25. data/lib/carrierwave/uploader/dimension.rb +66 -0
  26. data/lib/carrierwave/uploader/download.rb +2 -123
  27. data/lib/carrierwave/uploader/extension_allowlist.rb +63 -0
  28. data/lib/carrierwave/uploader/extension_denylist.rb +64 -0
  29. data/lib/carrierwave/uploader/file_size.rb +2 -2
  30. data/lib/carrierwave/uploader/mountable.rb +6 -0
  31. data/lib/carrierwave/uploader/processing.rb +42 -7
  32. data/lib/carrierwave/uploader/proxy.rb +17 -4
  33. data/lib/carrierwave/uploader/serialization.rb +1 -1
  34. data/lib/carrierwave/uploader/store.rb +46 -7
  35. data/lib/carrierwave/uploader/url.rb +7 -4
  36. data/lib/carrierwave/uploader/versions.rb +140 -105
  37. data/lib/carrierwave/uploader.rb +10 -17
  38. data/lib/carrierwave/utilities/file_name.rb +47 -0
  39. data/lib/carrierwave/utilities/uri.rb +14 -11
  40. data/lib/carrierwave/utilities.rb +1 -0
  41. data/lib/carrierwave/validations/active_model.rb +7 -9
  42. data/lib/carrierwave/version.rb +1 -1
  43. data/lib/carrierwave.rb +13 -17
  44. data/lib/generators/templates/{uploader.rb → uploader.rb.erb} +2 -2
  45. data/lib/generators/uploader_generator.rb +3 -3
  46. metadata +100 -33
  47. data/lib/carrierwave/uploader/content_type_blacklist.rb +0 -48
  48. data/lib/carrierwave/uploader/content_type_whitelist.rb +0 -48
  49. data/lib/carrierwave/uploader/extension_blacklist.rb +0 -51
  50. data/lib/carrierwave/uploader/extension_whitelist.rb +0 -52
@@ -1,6 +1,76 @@
1
1
  module CarrierWave
2
2
  module Uploader
3
3
  module Versions
4
+ class Builder
5
+ def initialize(name)
6
+ @name = name
7
+ @options = {}
8
+ @blocks = []
9
+ @klass = nil
10
+ end
11
+
12
+ def configure(options, &block)
13
+ @options.merge!(options)
14
+ @blocks << block if block
15
+ @klass = nil
16
+ end
17
+
18
+ def build(superclass)
19
+ return @klass if @klass
20
+ @klass = Class.new(superclass)
21
+ superclass.const_set("#{@name.to_s.camelize}VersionUploader", @klass)
22
+
23
+ @klass.version_names += [@name]
24
+ @klass.versions = {}
25
+ @klass.processors = []
26
+ @klass.version_options = @options
27
+ @klass.class_eval <<-RUBY, __FILE__, __LINE__ + 1
28
+ # Regardless of what is set in the parent uploader, do not enforce the
29
+ # move_to_cache config option on versions because it moves the original
30
+ # file to the version's target file.
31
+ #
32
+ # If you want to enforce this setting on versions, override this method
33
+ # in each version:
34
+ #
35
+ # version :thumb do
36
+ # def move_to_cache
37
+ # true
38
+ # end
39
+ # end
40
+ #
41
+ def move_to_cache
42
+ false
43
+ end
44
+
45
+ # Need to rely on the parent version's identifier, as versions don't have its own one.
46
+ def identifier
47
+ parent_version.identifier
48
+ end
49
+ RUBY
50
+ @blocks.each { |block| @klass.class_eval(&block) }
51
+ @klass
52
+ end
53
+
54
+ def deep_dup
55
+ other = dup
56
+ other.instance_variable_set(:@blocks, @blocks.dup)
57
+ other
58
+ end
59
+
60
+ def method_missing(name, *args)
61
+ super
62
+ rescue NoMethodError => e
63
+ raise e.exception <<~ERROR
64
+ #{e.message}
65
+ If you're trying to configure a version, do it inside a block like `version(:thumb) { self.#{name} #{args.map(&:inspect).join(', ')} }`.
66
+ ERROR
67
+ end
68
+
69
+ def respond_to_missing?(*)
70
+ super
71
+ end
72
+ end
73
+
4
74
  extend ActiveSupport::Concern
5
75
 
6
76
  include CarrierWave::Uploader::Callbacks
@@ -11,9 +81,8 @@ module CarrierWave
11
81
  self.versions = {}
12
82
  self.version_names = []
13
83
 
14
- attr_accessor :parent_cache_id, :parent_version
84
+ attr_accessor :parent_version
15
85
 
16
- after :cache, :assign_parent_cache_id
17
86
  after :cache, :cache_versions!
18
87
  after :store, :store_versions!
19
88
  after :remove, :remove_versions!
@@ -51,80 +120,33 @@ module CarrierWave
51
120
  # process :scale => [200, 200]
52
121
  # end
53
122
  #
123
+ # version :square, :unless => :invalid_image_type? do
124
+ # process :scale => [100, 100]
125
+ # end
126
+ #
54
127
  # end
55
128
  #
56
129
  def version(name, options = {}, &block)
57
130
  name = name.to_sym
58
- build_version(name, options)
131
+ versions[name] ||= Builder.new(name)
132
+ versions[name].configure(options, &block)
59
133
 
60
- versions[name].class_eval(&block) if block
61
- versions[name]
62
- end
134
+ class_eval <<-RUBY, __FILE__, __LINE__ + 1
135
+ def #{name}
136
+ versions[:#{name}]
137
+ end
138
+ RUBY
63
139
 
64
- def recursively_apply_block_to_versions(&block)
65
- versions.each do |name, version|
66
- version.class_eval(&block)
67
- version.recursively_apply_block_to_versions(&block)
68
- end
140
+ versions[name]
69
141
  end
70
142
 
71
143
  private
72
144
 
73
- def build_version(name, options)
74
- if !versions.has_key?(name)
75
- uploader = Class.new(self)
76
- const_set("Uploader#{uploader.object_id}".tr('-', '_'), uploader)
77
- uploader.version_names += [name]
78
- uploader.versions = {}
79
- uploader.processors = []
80
- uploader.version_options = options
81
-
82
- uploader.class_eval <<-RUBY, __FILE__, __LINE__ + 1
83
- # Define the enable_processing method for versions so they get the
84
- # value from the parent class unless explicitly overwritten
85
- def self.enable_processing(value=nil)
86
- self.enable_processing = value if value
87
- if defined?(@enable_processing) && !@enable_processing.nil?
88
- @enable_processing
89
- else
90
- superclass.enable_processing
91
- end
92
- end
93
-
94
- # Regardless of what is set in the parent uploader, do not enforce the
95
- # move_to_cache config option on versions because it moves the original
96
- # file to the version's target file.
97
- #
98
- # If you want to enforce this setting on versions, override this method
99
- # in each version:
100
- #
101
- # version :thumb do
102
- # def move_to_cache
103
- # true
104
- # end
105
- # end
106
- #
107
- def move_to_cache
108
- false
109
- end
110
- RUBY
111
-
112
- class_eval <<-RUBY, __FILE__, __LINE__ + 1
113
- def #{name}
114
- versions[:#{name}]
115
- end
116
- RUBY
117
- else
118
- uploader = Class.new(versions[name])
119
- const_set("Uploader#{uploader.object_id}".tr('-', '_'), uploader)
120
- uploader.processors = []
121
- uploader.version_options = uploader.version_options.merge(options)
122
- end
123
-
124
- # Add the current version hash to class attribute :versions
125
- self.versions = versions.merge(name => uploader)
145
+ def inherited(subclass)
146
+ # To prevent subclass version changes affecting superclass versions
147
+ subclass.versions = versions.deep_dup
148
+ super
126
149
  end
127
-
128
150
  end # ClassMethods
129
151
 
130
152
  ##
@@ -138,7 +160,7 @@ module CarrierWave
138
160
  return @versions if @versions
139
161
  @versions = {}
140
162
  self.class.versions.each do |name, version|
141
- @versions[name] = version.new(model, mounted_as)
163
+ @versions[name] = version.build(self.class).new(model, mounted_as)
142
164
  @versions[name].parent_version = self
143
165
  end
144
166
  @versions
@@ -161,25 +183,44 @@ module CarrierWave
161
183
  #
162
184
  # === Returns
163
185
  #
164
- # [Boolean] True when the version exists according to its :if condition
186
+ # [Boolean] True when the version exists according to its :if or :unless condition
165
187
  #
166
188
  def version_exists?(name)
167
189
  name = name.to_sym
168
190
 
169
- return false unless self.class.versions.has_key?(name)
191
+ return false unless versions.has_key?(name)
170
192
 
171
- condition = self.class.versions[name].version_options[:if]
172
- if(condition)
173
- if(condition.respond_to?(:call))
174
- condition.call(self, :version => name, :file => file)
193
+ if_condition = versions[name].class.version_options[:if]
194
+ unless_condition = versions[name].class.version_options[:unless]
195
+
196
+ if if_condition
197
+ if if_condition.respond_to?(:call)
198
+ if_condition.call(self, :version => name, :file => file)
199
+ else
200
+ send(if_condition, file)
201
+ end
202
+ elsif unless_condition
203
+ if unless_condition.respond_to?(:call)
204
+ !unless_condition.call(self, :version => name, :file => file)
175
205
  else
176
- send(condition, file)
206
+ !send(unless_condition, file)
177
207
  end
178
208
  else
179
209
  true
180
210
  end
181
211
  end
182
212
 
213
+ ##
214
+ # Copies the parent's cache_id when caching a version file.
215
+ # This behavior is not essential but it makes easier to understand
216
+ # that the cached files are generated by the single upload attempt.
217
+ #
218
+ def cache!(*args)
219
+ self.cache_id = parent_version.cache_id if parent_version
220
+
221
+ super
222
+ end
223
+
183
224
  ##
184
225
  # When given a version name as a parameter, will return the url for that version
185
226
  # This also works with nested versions.
@@ -220,26 +261,26 @@ module CarrierWave
220
261
  # Recreate versions and reprocess them. This can be used to recreate
221
262
  # versions if their parameters somehow have changed.
222
263
  #
223
- def recreate_versions!(*versions)
224
- # Some files could possibly not be stored on the local disk. This
225
- # doesn't play nicely with processing. Make sure that we're only
226
- # processing a cached file
227
- #
228
- # The call to store! will trigger the necessary callbacks to both
229
- # process this version and all sub-versions
230
- if versions.any?
231
- file = sanitized_file if !cached?
232
- store_versions!(file, versions)
233
- else
234
- cache! if !cached?
235
- store!
264
+ def recreate_versions!(*names)
265
+ # As well as specified versions, we need to reprocess versions
266
+ # that are the source of another version.
267
+
268
+ self.cache_id = CarrierWave.generate_cache_id
269
+ derived_versions.each do |name, v|
270
+ v.cache!(file) if names.empty? || !(v.descendant_version_names & names).empty?
236
271
  end
272
+ active_versions.each do |name, v|
273
+ v.store! if names.empty? || names.include?(name)
274
+ end
275
+ ensure
276
+ @cache_id = nil
237
277
  end
238
278
 
239
- private
240
- def assign_parent_cache_id(file)
241
- active_versions.each do |name, uploader|
242
- uploader.parent_cache_id = @cache_id
279
+ protected
280
+
281
+ def descendant_version_names
282
+ [version_name] + derived_versions.flat_map do |name, version|
283
+ version.descendant_version_names
243
284
  end
244
285
  end
245
286
 
@@ -249,16 +290,18 @@ module CarrierWave
249
290
  end
250
291
  end
251
292
 
252
- def dependent_versions
293
+ private
294
+
295
+ def derived_versions
253
296
  active_versions.reject do |name, v|
254
297
  v.class.version_options[:from_version]
255
- end.to_a + sibling_versions.select do |name, v|
298
+ end.to_a + active_sibling_versions.select do |name, v|
256
299
  v.class.version_options[:from_version] == self.class.version_names.last
257
300
  end.to_a
258
301
  end
259
302
 
260
- def sibling_versions
261
- parent_version.try(:versions) || []
303
+ def active_sibling_versions
304
+ parent_version&.active_versions || []
262
305
  end
263
306
 
264
307
  def full_filename(for_file)
@@ -270,19 +313,11 @@ module CarrierWave
270
313
  end
271
314
 
272
315
  def cache_versions!(new_file)
273
- dependent_versions.each do |name, v|
274
- v.send(:cache_id=, @cache_id)
275
- v.cache!(new_file)
276
- end
316
+ derived_versions.each { |name, v| v.cache!(new_file) }
277
317
  end
278
318
 
279
- def store_versions!(new_file, versions=nil)
280
- if versions
281
- active = Hash[active_versions]
282
- versions.each { |v| active[v].try(:store!, new_file) } unless active.empty?
283
- else
284
- active_versions.each { |name, v| v.store!(new_file) }
285
- end
319
+ def store_versions!(new_file)
320
+ active_versions.each { |name, v| v.store!(new_file) }
286
321
  end
287
322
 
288
323
  def remove_versions!
@@ -7,11 +7,12 @@ require "carrierwave/uploader/cache"
7
7
  require "carrierwave/uploader/store"
8
8
  require "carrierwave/uploader/download"
9
9
  require "carrierwave/uploader/remove"
10
- require "carrierwave/uploader/extension_whitelist"
11
- require "carrierwave/uploader/extension_blacklist"
12
- require "carrierwave/uploader/content_type_whitelist"
13
- require "carrierwave/uploader/content_type_blacklist"
10
+ require "carrierwave/uploader/extension_allowlist"
11
+ require "carrierwave/uploader/extension_denylist"
12
+ require "carrierwave/uploader/content_type_allowlist"
13
+ require "carrierwave/uploader/content_type_denylist"
14
14
  require "carrierwave/uploader/file_size"
15
+ require "carrierwave/uploader/dimension"
15
16
  require "carrierwave/uploader/processing"
16
17
  require "carrierwave/uploader/versions"
17
18
  require "carrierwave/uploader/default_url"
@@ -43,15 +44,6 @@ module CarrierWave
43
44
  class Base
44
45
  attr_reader :file
45
46
 
46
- ##
47
- # Workaround for class_attribute malfunction when used with Module#prepend
48
- #
49
- if RUBY_VERSION < '2.1.0'
50
- def self.singleton_class?
51
- !ancestors.include? self
52
- end
53
- end
54
-
55
47
  include CarrierWave::Uploader::Configuration
56
48
  include CarrierWave::Uploader::Callbacks
57
49
  include CarrierWave::Uploader::Proxy
@@ -61,11 +53,12 @@ module CarrierWave
61
53
  include CarrierWave::Uploader::Store
62
54
  include CarrierWave::Uploader::Download
63
55
  include CarrierWave::Uploader::Remove
64
- include CarrierWave::Uploader::ExtensionWhitelist
65
- include CarrierWave::Uploader::ExtensionBlacklist
66
- include CarrierWave::Uploader::ContentTypeWhitelist
67
- include CarrierWave::Uploader::ContentTypeBlacklist
56
+ include CarrierWave::Uploader::ExtensionAllowlist
57
+ include CarrierWave::Uploader::ExtensionDenylist
58
+ include CarrierWave::Uploader::ContentTypeAllowlist
59
+ include CarrierWave::Uploader::ContentTypeDenylist
68
60
  include CarrierWave::Uploader::FileSize
61
+ include CarrierWave::Uploader::Dimension
69
62
  include CarrierWave::Uploader::Processing
70
63
  include CarrierWave::Uploader::Versions
71
64
  include CarrierWave::Uploader::DefaultUrl
@@ -0,0 +1,47 @@
1
+ module CarrierWave
2
+ module Utilities
3
+ module FileName
4
+
5
+ ##
6
+ # Returns the part of the filename before the extension. So if a file is called 'test.jpeg'
7
+ # this would return 'test'
8
+ #
9
+ # === Returns
10
+ #
11
+ # [String] the first part of the filename
12
+ #
13
+ def basename
14
+ split_extension(filename)[0] if filename
15
+ end
16
+
17
+ ##
18
+ # Returns the file extension
19
+ #
20
+ # === Returns
21
+ #
22
+ # [String] extension of file or "" if the file has no extension
23
+ #
24
+ def extension
25
+ split_extension(filename)[1] if filename
26
+ end
27
+
28
+ private
29
+
30
+ def split_extension(filename)
31
+ # regular expressions to try for identifying extensions
32
+ extension_matchers = [
33
+ /\A(.+)\.(tar\.([glx]?z|bz2))\z/, # matches "something.tar.gz"
34
+ /\A(.+)\.([^\.]+)\z/ # matches "something.jpg"
35
+ ]
36
+
37
+ extension_matchers.each do |regexp|
38
+ if filename =~ regexp
39
+ return $1, $2
40
+ end
41
+ end
42
+
43
+ [filename, ""] # In case we weren't able to split the extension
44
+ end
45
+ end # FileName
46
+ end # Utilities
47
+ end # CarrierWave
@@ -3,20 +3,23 @@ require 'uri'
3
3
  module CarrierWave
4
4
  module Utilities
5
5
  module Uri
6
- # based on Ruby < 2.0's URI.encode
7
- SAFE_STRING = URI::REGEXP::PATTERN::UNRESERVED + '\/'
8
- UNSAFE = Regexp.new("[^#{SAFE_STRING}]", false)
6
+ # based on Ruby < 2.0's URI.encode
7
+ PATH_SAFE = URI::REGEXP::PATTERN::UNRESERVED + '\/'
8
+ PATH_UNSAFE = Regexp.new("[^#{PATH_SAFE}]", false)
9
+ NON_ASCII = /[^[:ascii:]]/.freeze
9
10
 
10
11
  private
12
+
11
13
  def encode_path(path)
12
- path.to_s.gsub(UNSAFE) do
13
- us = $&
14
- tmp = ''
15
- us.each_byte do |uc|
16
- tmp << sprintf('%%%02X', uc)
17
- end
18
- tmp
19
- end
14
+ URI::DEFAULT_PARSER.escape(path, PATH_UNSAFE)
15
+ end
16
+
17
+ def encode_non_ascii(str)
18
+ URI::DEFAULT_PARSER.escape(str, NON_ASCII)
19
+ end
20
+
21
+ def decode_uri(str)
22
+ URI::DEFAULT_PARSER.unescape(str)
20
23
  end
21
24
  end # Uri
22
25
  end # Utilities
@@ -1,4 +1,5 @@
1
1
  require 'carrierwave/utilities/uri'
2
+ require 'carrierwave/utilities/file_name'
2
3
 
3
4
  module CarrierWave
4
5
  module Utilities
@@ -11,9 +11,8 @@ module CarrierWave
11
11
  class ProcessingValidator < ::ActiveModel::EachValidator
12
12
 
13
13
  def validate_each(record, attribute, value)
14
- if e = record.__send__("#{attribute}_processing_error")
15
- message = (e.message == e.class.to_s) ? :carrierwave_processing_error : e.message
16
- record.errors.add(attribute, message)
14
+ record.__send__("#{attribute}_processing_errors").each do |e|
15
+ record.errors.add(attribute, :carrierwave_processing_error, message: (e.message != e.class.to_s) && e.message)
17
16
  end
18
17
  end
19
18
  end
@@ -21,9 +20,8 @@ module CarrierWave
21
20
  class IntegrityValidator < ::ActiveModel::EachValidator
22
21
 
23
22
  def validate_each(record, attribute, value)
24
- if e = record.__send__("#{attribute}_integrity_error")
25
- message = (e.message == e.class.to_s) ? :carrierwave_integrity_error : e.message
26
- record.errors.add(attribute, message)
23
+ record.__send__("#{attribute}_integrity_errors").each do |e|
24
+ record.errors.add(attribute, :carrierwave_integrity_error, message: (e.message != e.class.to_s) && e.message)
27
25
  end
28
26
  end
29
27
  end
@@ -31,9 +29,8 @@ module CarrierWave
31
29
  class DownloadValidator < ::ActiveModel::EachValidator
32
30
 
33
31
  def validate_each(record, attribute, value)
34
- if e = record.__send__("#{attribute}_download_error")
35
- message = (e.message == e.class.to_s) ? :carrierwave_download_error : e.message
36
- record.errors.add(attribute, message)
32
+ record.__send__("#{attribute}_download_errors").each do |e|
33
+ record.errors.add(attribute, :carrierwave_download_error, message: (e.message != e.class.to_s) && e.message)
37
34
  end
38
35
  end
39
36
  end
@@ -58,6 +55,7 @@ module CarrierWave
58
55
  def validates_processing_of(*attr_names)
59
56
  validates_with ProcessingValidator, _merge_attributes(attr_names)
60
57
  end
58
+
61
59
  #
62
60
  ##
63
61
  # Makes the record invalid if the remote file couldn't be downloaded
@@ -1,3 +1,3 @@
1
1
  module CarrierWave
2
- VERSION = "1.3.2"
2
+ VERSION = "3.0.0".freeze
3
3
  end
data/lib/carrierwave.rb CHANGED
@@ -25,16 +25,7 @@ module CarrierWave
25
25
 
26
26
  end
27
27
 
28
- if defined?(Merb)
29
-
30
- CarrierWave.root = Merb.dir_for(:public)
31
- Merb::BootLoader.before_app_loads do
32
- # Setup path for uploaders and load all of them before classes are loaded
33
- Merb.push_path(:uploaders, Merb.root / 'app' / 'uploaders', '*.rb')
34
- Dir.glob(File.join(Merb.load_paths[:uploaders])).each {|f| require f }
35
- end
36
-
37
- elsif defined?(Jets)
28
+ if defined?(Jets)
38
29
 
39
30
  module CarrierWave
40
31
  class Turbine < Jets::Turbine
@@ -72,6 +63,10 @@ elsif defined?(Rails)
72
63
  require 'carrierwave/orm/activerecord'
73
64
  end
74
65
  end
66
+
67
+ config.before_eager_load do
68
+ CarrierWave::Storage::Fog.eager_load
69
+ end
75
70
  end
76
71
  end
77
72
 
@@ -80,13 +75,14 @@ elsif defined?(Sinatra)
80
75
  CarrierWave.root = File.join(PADRINO_ROOT, "public")
81
76
  else
82
77
 
83
- CarrierWave.root = if Sinatra::Application.respond_to?(:public_folder)
84
- # Sinatra >= 1.3
85
- Sinatra::Application.public_folder
86
- else
87
- # Sinatra < 1.3
88
- Sinatra::Application.public
89
- end
78
+ CarrierWave.root =
79
+ if Sinatra::Application.respond_to?(:public_folder)
80
+ # Sinatra >= 1.3
81
+ Sinatra::Application.public_folder
82
+ else
83
+ # Sinatra < 1.3
84
+ Sinatra::Application.public
85
+ end
90
86
  end
91
87
  end
92
88
 
@@ -33,9 +33,9 @@ class <%= class_name %>Uploader < CarrierWave::Uploader::Base
33
33
  # process resize_to_fit: [50, 50]
34
34
  # end
35
35
 
36
- # Add a white list of extensions which are allowed to be uploaded.
36
+ # Add an allowlist of extensions which are allowed to be uploaded.
37
37
  # For images you might use something like this:
38
- # def extension_whitelist
38
+ # def extension_allowlist
39
39
  # %w(jpg jpeg gif png)
40
40
  # end
41
41
 
@@ -1,7 +1,7 @@
1
1
  class UploaderGenerator < Rails::Generators::NamedBase
2
- source_root File.expand_path("../templates", __FILE__)
2
+ source_root File.expand_path('templates', __dir__)
3
3
 
4
4
  def create_uploader_file
5
- template "uploader.rb", File.join('app/uploaders', class_path, "#{file_name}_uploader.rb")
5
+ template "uploader.rb.erb", File.join('app/uploaders', class_path, "#{file_name}_uploader.rb")
6
6
  end
7
- end
7
+ end