Sha256: 2551bc7f18a4e9312a80b7be1e55f245233ff2cdc19cfc82a603ca6f64524377

Contents?: true

Size: 369 Bytes

Versions: 34

Compression:

Stored size: 369 Bytes

Contents

module Fontist
  module Utils
    module Locking
      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
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
fontist-1.13.0 lib/fontist/utils/locking.rb
fontist-1.12.0 lib/fontist/utils/locking.rb
fontist-1.11.7 lib/fontist/utils/locking.rb
fontist-1.11.6 lib/fontist/utils/locking.rb
fontist-1.11.5 lib/fontist/utils/locking.rb
fontist-1.11.3 lib/fontist/utils/locking.rb
fontist-1.11.2 lib/fontist/utils/locking.rb
fontist-1.9.3 lib/fontist/utils/locking.rb
fontist-1.9.2 lib/fontist/utils/locking.rb
fontist-1.11.1 lib/fontist/utils/locking.rb
fontist-1.10.1 lib/fontist/utils/locking.rb
fontist-1.10.0 lib/fontist/utils/locking.rb
fontist-1.9.1 lib/fontist/utils/locking.rb
fontist-1.9.0 lib/fontist/utils/locking.rb