Class: ChefRake::Task::Clean

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/chef/raketasks/clean.rb

Instance Method Summary collapse

Constructor Details

#initializeClean

Returns a new instance of Clean.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# 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