Class: Slightish::Sandbox
- Inherits:
-
Object
- Object
- Slightish::Sandbox
- Defined in:
- lib/slightish/sandbox.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #delete ⇒ Object
-
#initialize(template_dir: nil, prefix: 'slightish') ⇒ Sandbox
constructor
A new instance of Sandbox.
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
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/slightish/sandbox.rb', line 5 def path @path end |
Instance Method Details
#delete ⇒ Object
15 16 17 |
# File 'lib/slightish/sandbox.rb', line 15 def delete FileUtils.remove_entry_secure(@path) end |