Top Level Namespace
Defined Under Namespace
Modules: Hexx
Instance Method Summary collapse
-
#clear_sandbox ⇒ Object
Clears the temporary
tmp/sandbox. -
#prepare_sandbox ⇒ Object
Re-creates the temporary
tmp/sandbox. -
#read_in_sandbox(filename) ⇒ String
Reads file in sandbox and returns file content.
-
#sandbox ⇒ String
Returns the path to the temporary
tmp/sandbox. -
#try_in_sandbox ⇒ Object
Runs code from the temporary
tmp/sandbox.
Instance Method Details
#clear_sandbox ⇒ Object
Clears the temporary tmp/sandbox.
11 12 13 |
# File 'lib/hexx-rspec/initializers/sandbox/helpers.rb', line 11 def clear_sandbox FileUtils.rm_rf sandbox end |
#prepare_sandbox ⇒ Object
Re-creates the temporary tmp/sandbox.
16 17 18 19 |
# File 'lib/hexx-rspec/initializers/sandbox/helpers.rb', line 16 def prepare_sandbox clear_sandbox FileUtils.mkdir_p sandbox end |
#read_in_sandbox(filename) ⇒ String
Reads file in sandbox and returns file content. Returns a blank string when the file is absent.
29 30 31 32 |
# File 'lib/hexx-rspec/initializers/sandbox/helpers.rb', line 29 def read_in_sandbox(filename) file = Dir[File.join(sandbox, filename)].first file ? File.read(file) : "" end |
#sandbox ⇒ String
Returns the path to the temporary tmp/sandbox.
6 7 8 |
# File 'lib/hexx-rspec/initializers/sandbox/helpers.rb', line 6 def sandbox @sandbox ||= File. "tmp/sandbox" end |
#try_in_sandbox ⇒ Object
Runs code from the temporary tmp/sandbox.
22 23 24 |
# File 'lib/hexx-rspec/initializers/sandbox/helpers.rb', line 22 def try_in_sandbox FileUtils.cd(sandbox) { yield } end |