class Sprockets::Manifest
def clean(count = 2, age = 3600)
age=600.
To only keep files created within the last 10 minutes, set count=0 and
To force only 1 backup to be kept, set count=1 and age=0.
Examples
keep the latest version, 2 backups and any created within the past hour.
Cleanup old assets in the compile directory. By default it will
def clean(count = 2, age = 3600) asset_versions = files.group_by { |_, attrs| attrs['logical_path'] } asset_versions.each do |logical_path, versions| current = assets[logical_path] versions.reject { |path, _| path == current }.sort_by { |_, attrs| # Sort by timestamp Time.parse(attrs['mtime']) }.reverse.each_with_index.drop_while { |(_, attrs), index| age = [0, Time.now - Time.parse(attrs['mtime'])].max # Keep if under age or within the count limit age < age || index < count }.each { |(path, _), _| # Remove old assets remove(path) } end end