Class: Slightish::Sandbox

Inherits:
Object
  • Object
show all
Defined in:
lib/slightish/sandbox.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(template_dir: nil, prefix: 'slightish') ⇒ Sandbox

Returns a new instance of Sandbox.



7
8
9
10
11
12
13
# File 'lib/slightish/sandbox.rb', line 7

def initialize(template_dir: nil, prefix: 'slightish')
  @path = Dir.mktmpdir(prefix)

  # The '.' prevents cp_r from making a new directory at the destination --
  # kind of the equivalent of '/*' in bash.
  FileUtils.cp_r(File.join(template_dir, '.'), @path) unless template_dir.nil?
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



5
6
7
# File 'lib/slightish/sandbox.rb', line 5

def path
  @path
end

Instance Method Details

#deleteObject



15
16
17
# File 'lib/slightish/sandbox.rb', line 15

def delete
  FileUtils.remove_entry_secure(@path)
end