Module: Fontist::Utils::Locking
- Included in:
 - SystemIndex, Cache
 
- Defined in:
 - lib/fontist/utils/locking.rb
 
Instance Method Summary collapse
Instance Method Details
#lock(lock_path) ⇒ Object
      4 5 6 7 8 9 10 11 12 13 14 15  | 
    
      # File 'lib/fontist/utils/locking.rb', line 4 def lock(lock_path) File.dirname(lock_path).tap do |dir| FileUtils.mkdir_p(dir) unless File.exist?(dir) end f = File.open(lock_path, File::CREAT) f.flock(File::LOCK_EX) yield ensure f.flock(File::LOCK_UN) f.close end  |