Class: PuppetLibrary::Util::TempDir
- Inherits:
-
Object
- Object
- PuppetLibrary::Util::TempDir
- Defined in:
- lib/puppet_library/util/temp_dir.rb
Defined Under Namespace
Classes: Remover
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name) ⇒ TempDir
constructor
A new instance of TempDir.
Constructor Details
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
22 23 24 |
# File 'lib/puppet_library/util/temp_dir.rb', line 22 def path @path end |
Class Method Details
.cd(name, &block) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/puppet_library/util/temp_dir.rb', line 31 def self.cd(name, &block) path = create(name) Dir.chdir(path, &block) ensure FileUtils.rm_rf path end |
.create(name) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/puppet_library/util/temp_dir.rb', line 38 def self.create(name) file = Tempfile.new(name) path = file.path file.unlink FileUtils.mkdir path path end |
.use(name) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/puppet_library/util/temp_dir.rb', line 24 def self.use(name) path = create(name) yield(path) ensure FileUtils.rm_rf path end |