Class: Dply::Lock
- Inherits:
-
Object
show all
- Includes:
- Helper
- Defined in:
- lib/dply/lock.rb
Instance Method Summary
collapse
Methods included from Helper
#cmd, #error, #git, #logger, #sh, #symlink
Constructor Details
#initialize(dir) ⇒ Lock
7
8
9
|
# File 'lib/dply/lock.rb', line 7
def initialize(dir)
@dir = dir
end
|
Instance Method Details
#acquire ⇒ Object
11
12
13
14
15
|
# File 'lib/dply/lock.rb', line 11
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
|
#lock_file ⇒ Object
17
18
19
|
# File 'lib/dply/lock.rb', line 17
def lock_file
@lock_file ||= File.open("#{@dir}/.dply.lock", "a+")
end
|