Sha256: 740188dc590c84a2b4486e941e1f02d42c13e93ebdf2f02bd7509e7bcbb840fb

Contents?: true

Size: 364 Bytes

Versions: 3

Compression:

Stored size: 364 Bytes

Contents

require 'fileutils'

# Create Lock

module MassiveSitemap
  LOCK_FILE = 'generator.lock'

  def lock!(&block)
    if block
      raise Errno::EACCES if ::File.exists?(LOCK_FILE)
      ::File.open(LOCK_FILE, 'w', ::File::EXCL)
      begin
        block.call
      ensure
        FileUtils.rm(LOCK_FILE) #unlock!
      end
    end
  end
  module_function :lock!
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
massive_sitemap-2.0.0.rc6 lib/massive_sitemap/lock.rb
massive_sitemap-2.0.0.rc5 lib/massive_sitemap/lock.rb
massive_sitemap-2.0.0.rc4 lib/massive_sitemap/lock.rb