Class: RailsZero::CleanSiteJob

Inherits:
Object
  • Object
show all
Defined in:
app/jobs/rails_zero/clean_site_job.rb

Instance Method Summary collapse

Instance Method Details

#runObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'app/jobs/rails_zero/clean_site_job.rb', line 3

def run
  root = Rails.root.join('public').to_s
  Dir[File.join(root, '**', '*').to_s].each do |absolute_path|
    found_exclude = excluded_files.find do |excluded_path|
      if absolute_path.start_with?(excluded_path) && File.directory?(excluded_path)
        true
      else
        excluded_path == absolute_path
      end
    end
    is_excluded = found_exclude != nil
    FileUtils.rm_rf(absolute_path) unless is_excluded
  end
end