Module: Construct::Helpers
Instance Attribute Summary
#construct__chdir_default
Instance Method Summary
collapse
#chdir, #destroy!, #directory, #file, #maybe_change_dir
Instance Method Details
#create_construct(chdir = true) ⇒ Object
17
18
19
20
21
22
23
24
|
# 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) ⇒ Object
8
9
10
11
12
13
14
15
|
# 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
|