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

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

Overview

Author:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ Clean

Returns a new instance of Clean.



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

def initialize(app, env)
  @app = app
  @shelf = Berkshelf::Vagrant.shelf_for(env)
end

Instance Attribute Details

#shelfObject (readonly)

Returns the value of attribute shelf.



6
7
8
# File 'lib/berkshelf/vagrant/action/clean.rb', line 6

def shelf
  @shelf
end

Instance Method Details

#call(env) ⇒ Object



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

def call(env)
  if Berkshelf::Vagrant.chef_solo?(env[:vm].config) && self.shelf
    Berkshelf.formatter.msg "cleaning Vagrant's shelf"
    FileUtils.remove_dir(self.shelf, fore: true)
  end

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