Module: Jack::Tasks::Locking
- Included in:
- Jack::Tasks
- Defined in:
- lib/jack/tasks/locking.rb
Instance Method Summary collapse
Instance Method Details
#lock(*args) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/jack/tasks/locking.rb', line 4 def lock(*args) require 'lockfile' unless Object.const_defined?(:Lockfile) = args.last.is_a?(Hash) ? args.pop : {:retries => 0} lock_filename = args.shift || 'jack.lock' if block_given? lockfile = ::Lockfile.new(lock_filename, ) begin lockfile.lock yield ensure lockfile.unlock if lockfile.locked? end end end |