class ChefRake::Task::Clean

Public Class Methods

new() click to toggle source
Calls superclass method
# File lib/chef/raketasks/clean.rb, line 23
def initialize
  super

  namespace :clean do
    desc 'Removes cache dirs from any local chef installation'
    task :chefcache do
      cachedirs = [
        File.join(ENV['HOME'], '.chef/cache'),
        File.join(ENV['HOME'], '.chefdk/cache'),
        File.join(ENV['HOME'], '.chef-workstation/cache')
      ]
      cachedirs.each { |f| FileUtils.rm_rf(Dir.glob(f)) }
    end

    desc 'Removes any temporary files from a cookbook'
    task :cookbook do
      %w[
        Berksfile.lock
        .bundle
        .cache
        coverage
        doc/
        Gemfile.lock
        .kitchen
        metadata.json
        pkg/
        policies/*.lock.json
        *.lock.json
        reports/
        rspec.xml
        vendor
        .yardoc
        .DS_Store
      ].each { |f| FileUtils.rm_rf(Dir.glob(f)) }
    end

    desc 'Removes any temporary files from an InSpec profile'
    task :inspec do
      %w[
        inspec.lock
        coverage
        doc/
        Gemfile.lock
        pkg/
        reports/
        rspec.xml
        vendor
        .yardoc
        .DS_Store
      ].each { |f| FileUtils.rm_rf(Dir.glob(f)) }
    end
  end

  task clean: :'clean:cookbook'

end