Sha256: ffd2a04ef1784a5d75c81ffe5ed6fd7833d303e9b7c327be2f2dcd6c0d78a4ee
Contents?: true
Size: 460 Bytes
Versions: 1
Compression:
Stored size: 460 Bytes
Contents
require 'tmpdir' require 'sha1' class Sandbox class << self def play(&block) path = generate_path FileUtils.mkdir_p(path) begin yield path ensure FileUtils.rm_r(path) end end def generate_path File.join(Dir.tmpdir, sandbox_dir) end def sandbox_dir sha = Digest::SHA1.hexdigest("--#{rand(20000)}---#{Time.now}--") "sandbox-#{sha}" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bdimcheff-sandbox-0.0.1 | lib/sandbox.rb |