Project

temppath

0.0
No commit activity in last 3 years
No release in over 3 years
temppath provides the method to create temporary path
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0
>= 0

Runtime

 Project Readme

Temppath

Temppath is a Ruby library for generating temporary file 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.

Gem Version Build Status Coverage Status Code Climate

Features

  • You can generate a path without file.
  • Temppath can generate files and directories as well. Therefore you are free from confusion which is correct tmpfile/tempfile or tmpdir/tempdir.
  • Generated paths are Pathname objects.

Installation

$ gem install temppath

Usage

Create a path

path = Temppath.create
#=> #<Pathname:/tmp/ruby-temppath-20130407-5775-w5k77l/f41bd6c5-fc99-4b7a-8f68-95b7ae4a6b22>
path.exist? #=> false
path.open("w")
"%o" % path.stat.mode #=> "100600" (default permission 0600)

Create a directory

path = Temppath.mkdir
path.exist?     #=> true
path.directory? #=> true
"%o" % path.stat.mode #=> "40700"

Create an empty file

path = Temppath.touch
path.exist? #=> true
path.file?  #=> true
"%o" % path.stat.mode #=> "100600"

Use temporary path generator

You can use Temppath::Generator when you want to use multiple base directory. Generated paths have same natures as paths from Tempath.create, mkdir, and touch.

# make a generator
temppath = Temppath::Generator.new("/tmp/other-dir")
 
path = temppath.create
path.exist? #=> false
path.open("w")
"%o" % path.stat.mode #=> "100600"
 
path = temppath.mkdir
path.exist?     #=> true
path.directory? #=> true
"%o" % path.stat.mode #=> "40700"
 
path = temppath.touch
path.exist? #=> true
path.file?  #=> true
"%o" % path.stat.mode #=> "100600"

Documentation

License

Temppath is free software distributed under MIT license.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request