Method: Garcon::ChefHelpers#with_tmp_dir

Defined in:
lib/garcon/chef/chef_helpers.rb

#with_tmp_dir {|Proc| ... } ⇒ Object

Creates a temp directory executing the block provided. When done the temp directory and all it’s contents are garbage collected.

Yields:

  • (Proc)

    block A block that will be run

Returns:

  • (Object)

    Result of the block operation



316
317
318
319
320
# File 'lib/garcon/chef/chef_helpers.rb', line 316

def with_tmp_dir(&block)
  Dir.mktmpdir(SecureRandom.hex(3)) do |tmp_dir|
    Dir.chdir(tmp_dir, &block)
  end
end