module Construct::Helpers

Public Instance Methods

create_construct(chdir=true) click to toggle source
# File lib/construct/helpers.rb, line 17
def create_construct(chdir=true)
  path = (Pathname(Construct.tmpdir) + 
    "#{CONTAINER_PREFIX}-#{$PROCESS_ID}-#{rand(1_000_000_000)}")
  path.mkpath
  path.extend(PathExtensions)
  path.construct__chdir_default = chdir
  path
end
within_construct(chdir=true) { |container| ... } click to toggle source
# File lib/construct/helpers.rb, line 8
def within_construct(chdir=true)
  container = create_construct(chdir)
  container.maybe_change_dir(chdir) do
    yield(container)
  end
ensure
  container.destroy!
end