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.21.2 lib/fontist/utils/locking.rb
fontist-1.21.1 lib/fontist/utils/locking.rb
fontist-1.20.0 lib/fontist/utils/locking.rb
fontist-1.19.0 lib/fontist/utils/locking.rb
fontist-1.18.2 lib/fontist/utils/locking.rb
fontist-1.17.1 lib/fontist/utils/locking.rb
fontist-1.17.0 lib/fontist/utils/locking.rb
fontist-1.16.0 lib/fontist/utils/locking.rb
fontist-1.15.2 lib/fontist/utils/locking.rb
fontist-1.15.1 lib/fontist/utils/locking.rb
fontist-1.15.0 lib/fontist/utils/locking.rb
fontist-1.14.6 lib/fontist/utils/locking.rb
fontist-1.14.5 lib/fontist/utils/locking.rb
fontist-1.14.4 lib/fontist/utils/locking.rb
fontist-1.14.3 lib/fontist/utils/locking.rb
fontist-1.14.2 lib/fontist/utils/locking.rb
fontist-1.14.1 lib/fontist/utils/locking.rb
fontist-1.14.0 lib/fontist/utils/locking.rb
fontist-1.13.2 lib/fontist/utils/locking.rb
fontist-1.13.1 lib/fontist/utils/locking.rb