Sha256: e1257f2e5d1f299a1fff613b207d1fa9e13e25f800fb3170b9bebf7ca84b9223

Contents?: true

Size: 407 Bytes

Versions: 16

Compression:

Stored size: 407 Bytes

Contents

require 'dply/helper'
module Dply
  class Lock

    include Helper

    def initialize(dir)
      @dir = dir
    end

    def acquire
      logger.debug "acquiring lock"
      lock_acquired = lock_file.flock(File::LOCK_NB | File::LOCK_EX)
      error "exclusive lock not available" if not lock_acquired
    end

    def lock_file
      @lock_file ||= File.open("#{@dir}/.dply.lock", "a+")
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
dply-0.3.15 lib/dply/lock.rb
dply-0.3.14 lib/dply/lock.rb
dply-0.3.13 lib/dply/lock.rb
dply-0.3.12 lib/dply/lock.rb
dply-0.3.11 lib/dply/lock.rb
dply-0.3.10 lib/dply/lock.rb
dply-0.3.9 lib/dply/lock.rb
dply-0.3.8 lib/dply/lock.rb
dply-0.3.7 lib/dply/lock.rb
dply-0.3.6 lib/dply/lock.rb
dply-0.3.5 lib/dply/lock.rb
dply-0.3.4 lib/dply/lock.rb
dply-0.3.3 lib/dply/lock.rb
dply-0.3.2 lib/dply/lock.rb
dply-0.3.1 lib/dply/lock.rb
dply-0.3.0 lib/dply/lock.rb