module Aptly::TmpName

Helper to generate temporary names

Public Class Methods

dir(prefix) click to toggle source

Generate a random temporary directory name. @param prefix [String] arbitrary prefix string to start the name with @return [String] temporary directory name (only safe characters)

# File lib/aptly/tmpname.rb, line 24
def self.dir(prefix)
  format('%<prefix>s-%<time>s-%<pid>s-%<tid>s-%<rand>s',
         prefix: prefix,
         # rubocop:disable Style/FormatStringToken
         time: Time.now.strftime('%Y%m%d'),
         # rubocop:enable Style/FormatStringToken
         pid: $PROCESS_ID,
         tid: Thread.current.object_id,
         rand: rand(0x100000000).to_s(36))
end