Sha256: 2d1613996ae9ad401160e797e61cbc00a8635129d4b80b41ff2a95f0ec69d5e1

Contents?: true

Size: 594 Bytes

Versions: 2

Compression:

Stored size: 594 Bytes

Contents

# frozen_string_literal: true

namespace :assets do
  desc 'Refresh carrierwave assets versions by model (CLASS=)'
  task reprocess: :environment do
    require 'progressbar'

    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?

    pbar = ProgressBar.new(name, klass.count)
    pbar.bar_mark = '='

    index = 0

    klass.find_each do |item|
      item.data.recreate_versions!
      index += 1
      pbar.set(index)
    end

    pbar.finish
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sunrise-cms-1.1.1 lib/tasks/assets.rake
sunrise-cms-1.1.0 lib/tasks/assets.rake