Class: Berkshelf::Vagrant::Action::Clean

Inherits:
Object
  • Object
show all
Includes:
EnvHelpers
Defined in:
lib/berkshelf/vagrant/action/clean.rb

Overview

Author:

Instance Method Summary collapse

Methods included from EnvHelpers

#berkshelf_enabled?, #cache_file, #chef_client?, #chef_solo?, #provision_disabled?, #provisioners

Constructor Details

#initialize(app, env) ⇒ Clean

Returns a new instance of Clean.



8
9
10
# File 'lib/berkshelf/vagrant/action/clean.rb', line 8

def initialize(app, env)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/berkshelf/vagrant/action/clean.rb', line 12

def call(env)
  if env[:berkshelf].shelf && File.exist?(env[:berkshelf].shelf)
    env[:berkshelf].ui.info "Cleaning Vagrant's berkshelf"

    FileUtils.remove_dir(env[:berkshelf].shelf, force: true)
    FileUtils.rm_f(cache_file(env))
    env[:berkshelf].shelf = nil
  end

  @app.call(env)
rescue Berkshelf::BerkshelfError => e
  raise Berkshelf::VagrantWrapperError.new(e)
end