New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

path-temp

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

path-temp

  • 1.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

path-temp

File.path_temp defines a temporary file path. It does not create the file. If, after the do block, a file exists at that path then the file is deleted.

#!/usr/bin/ruby -w
require 'file/path-temp'

# call File.path_temp
File.path_temp() do |path|
  # defines a path in current directory with a bunch of random numbers as
  # the name e.g. ./18168068873296828
  puts path 
  
  # file is *not* automatically created
  puts File.exist?(path) # => false
  
  # write to the path
  File.write path, 'whatever'
  
  # file now exists
  puts File.exist?(path) # => true
end

# at this point, the file no longer exists

root

To put the path somewhere besides the current directory, use the root option:

File.path_temp('root'=>'/tmp') do |path|
  puts path # => e,g, /tmp/458577463617317
end

extension

To give the path an extension, use the ext option:

File.path_temp('ext'=>'txt') do |path|
  puts path # => e,g, ./5314921893963471.txt
end

Installation

The usual:

sudo gem install path-temp

Or however you like to install gems. It's just a single file.

License

Open source, MIT license.

Author

Mike O'Sullivan mike@idocs.com

History

versiondatenotes
1.0Jun 29, 2023Initial upload.

FAQs

Package last updated on 29 Jun 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc