Sha256: 4e094e21134fccfc424c6797eb5256a87c9d5e0517ffef221a7464d11de2e2fd
Contents?: true
Size: 954 Bytes
Versions: 3
Compression:
Stored size: 954 Bytes
Contents
require "digest" module Bdsync module Utils # Examples: # # puts Utils.timestamp # > 2019-12-11.16-15-57 # # puts Utils.timestamp[0...10].delete("-") # > 20191211 # def self.timestamp ts = Time.now.to_s[0..18] ts[10] = "." ts[13] = ts[16] = "-" ts end def self.md5(s) Digest::MD5.hexdigest(s) end def self.file_md5 file_path Digest::MD5.file(file_path).hexdigest end def self.caller_info level info = caller[level].match(%r{([^/]+):(\d+):in `(.+)'}) "#{info.captures[0]}:#{info.captures[1]} - #{info.captures[2]}" end def self.try_lock &block File.open(__FILE__, 'r') { |f| return if !f.flock(File::LOCK_EX | File::LOCK_NB) yield } end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
bdsync-2.3.1 | lib/bdsync/utils.rb |
bdsync-2.3.0 | lib/bdsync/utils.rb |
bdsync-2.2.0 | lib/bdsync/utils.rb |