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.1"
Class Method Summary collapse
-
.basedir ⇒ Pathname
Return base directory of paths created by Temppath.
-
.basename ⇒ Object
Return base name of paths created by Temppath.
-
.basename=(name) ⇒ Object
Set the base name.
-
.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 for 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.
229 230 231 |
# File 'lib/temppath.rb', line 229 def basedir @generator.basedir end |
.basename ⇒ Object
Return base name of paths created by Temppath.
234 235 236 |
# File 'lib/temppath.rb', line 234 def basename @generator.basename end |
.basename=(name) ⇒ Object
Set the base name.
239 240 241 |
# File 'lib/temppath.rb', line 239 def basename=(name) @generator.basename = name end |
.create(option = {}) ⇒ Object
Create a temporary path. This method creates no files.
266 267 268 |
# File 'lib/temppath.rb', line 266 def create(option={}) @generator.create(option) end |
.create_basedir ⇒ Pathname
Create a new base directory.
215 216 217 |
# File 'lib/temppath.rb', line 215 def create_basedir Pathname.new(Dir.mktmpdir("ruby-temppath-")) end |
.mkdir(option = {}) ⇒ Object
Create a temporary directory.
279 280 281 |
# File 'lib/temppath.rb', line 279 def mkdir(option={}) @generator.mkdir(option) end |
.remove_basedir ⇒ void
This method returns an undefined value.
Remove current temporary directory.
304 305 306 |
# File 'lib/temppath.rb', line 304 def remove_basedir @generator.remove_basedir end |
.touch(option = {}) ⇒ Object
Create a empty file.
284 285 286 |
# File 'lib/temppath.rb', line 284 def touch(option={}) @generator.touch(option) end |
.unlink ⇒ Boolean
Return true if unlink mode is enabled.
247 248 249 |
# File 'lib/temppath.rb', line 247 def unlink @generator.unlink end |
.unlink=(b) ⇒ Object
Set true or false for unlink mode.
255 256 257 |
# File 'lib/temppath.rb', line 255 def unlink=(b) @generator.unlink = b end |
.update_basedir(basedir = nil) ⇒ Pathname
Remove current base directory and change to use a new base directory.
294 295 296 297 298 299 |
# File 'lib/temppath.rb', line 294 def update_basedir(basedir=nil) @generator.remove_basedir _basedir = basedir || create_basedir @generator = Generator.new(_basedir) return _basedir end |