Module: Tantiny::Helpers

Defined in:
lib/tantiny/helpers.rb

Class Method Summary collapse

Class Method Details

.timestamp(date) ⇒ Object



5
6
7
# File 'lib/tantiny/helpers.rb', line 5

def self.timestamp(date)
  date.to_datetime.iso8601
end

.with_lock(lockfile) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/tantiny/helpers.rb', line 9

def self.with_lock(lockfile)
  File.open(lockfile, File::CREAT) do |file|
    file.flock(File::LOCK_EX)

    yield

    file.flock(File::LOCK_UN)
  end
end