lib/tasks/assets.rake in ab_admin-0.9.0 vs lib/tasks/assets.rake in ab_admin-0.10.0

- old
+ new

@@ -4,17 +4,17 @@ # rake assets:reprocess CLASS=PostImage desc 'Refresh carrierwave assets versions by model (CLASS=)' task reprocess: :environment do name = (ENV['CLASS'] || ENV['class'] || 'Asset').to_s klass = name.safe_constantize + raise "Cannot find a constant with the #{name} specified in the argument string" if klass.nil? + versions = [] if ENV['VERSIONS'] - versions = ENV['VERSIONS'].split(',').map(&:to_sym) - else - versions = [] + all_versions = klass.uploaders[:data].versions.keys.map(&:to_s) + versions = ENV['VERSIONS'].split(',').flat_map{|v| all_versions.find_all {|vv| vv =~ Regexp.new("^#{v.gsub('*', '.*')}$") } }.map(&:to_sym).uniq end - - raise "Cannot find a constant with the #{name} specified in the argument string" if klass.nil? + puts "Model: #{klass.name}, versions: #{versions.presence || 'ALL'}" bar = ProgressBar.create(title: name, total: klass.count, format: '%c of %C - %a %e |%b>>%i| %p%% %t') bar.progress_mark = '=' klass.find_each do |item|