Module: Temppath
- Defined in:
- lib/temppath.rb,
lib/temppath/version.rb
Overview
Temppath creates temporary path. The differences from standard tempfile.rb are that this library generates Pathname objects with no files and filenames are based on UUID. Files in paths generated by this are deleted when Ruby exits.
Defined Under Namespace
Modules: OriginalMethodHolder, SecurePermissionMethods Classes: Generator
Constant Summary collapse
- VERSION =
version of temppath gem
"0.3.0"
Class Method Summary collapse
-
.basedir ⇒ Pathname
Return base directory of paths created by Temppath.
-
.create(option = {}) ⇒ Object
Create a temporary path.
-
.create_basedir ⇒ Pathname
Create a new base directory.
-
.mkdir(option = {}) ⇒ Object
Create a temporary directory.
-
.remove_basedir ⇒ void
Remove current temporary directory.
-
.touch(option = {}) ⇒ Object
Create a empty file.
-
.unlink ⇒ Boolean
Return true if unlink mode is enabled.
-
.unlink=(b) ⇒ Object
Set true or false unlink mode.
-
.update_basedir(basedir = nil) ⇒ Pathname
Remove current base directory and change to use a new base directory.
Class Method Details
.basedir ⇒ Pathname
Return base directory of paths created by Temppath.
218 219 220 |
# File 'lib/temppath.rb', line 218 def basedir @generator.basedir end |
.create(option = {}) ⇒ Object
Create a temporary path. This method creates no files.
245 246 247 |
# File 'lib/temppath.rb', line 245 def create(option={}) @generator.create(option) end |
.create_basedir ⇒ Pathname
Create a new base directory.
204 205 206 |
# File 'lib/temppath.rb', line 204 def create_basedir Pathname.new(Dir.mktmpdir("ruby-temppath-")) end |
.mkdir(option = {}) ⇒ Object
Create a temporary directory.
258 259 260 |
# File 'lib/temppath.rb', line 258 def mkdir(option={}) @generator.mkdir(option) end |
.remove_basedir ⇒ void
This method returns an undefined value.
Remove current temporary directory.
283 284 285 |
# File 'lib/temppath.rb', line 283 def remove_basedir @generator.remove_basedir end |
.touch(option = {}) ⇒ Object
Create a empty file.
263 264 265 |
# File 'lib/temppath.rb', line 263 def touch(option={}) @generator.touch(option) end |
.unlink ⇒ Boolean
Return true if unlink mode is enabled.
226 227 228 |
# File 'lib/temppath.rb', line 226 def unlink @generator.unlink end |
.unlink=(b) ⇒ Object
Set true or false unlink mode.
234 235 236 |
# File 'lib/temppath.rb', line 234 def unlink=(b) @generator.unlink = b end |
.update_basedir(basedir = nil) ⇒ Pathname
Remove current base directory and change to use a new base directory.
273 274 275 276 277 278 |
# File 'lib/temppath.rb', line 273 def update_basedir(basedir=nil) @generator.remove_basedir _basedir = basedir || create_basedir @generator = Generator.new(_basedir) return _basedir end |