Sha256: 3481d575857c9fc32ac83b03b4454ff006c1b415f266ab199acd4a4653bb97ac

Contents?: true

Size: 353 Bytes

Versions: 11

Compression:

Stored size: 353 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)
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
fontist-1.8.13 lib/fontist/utils/locking.rb
fontist-1.8.12 lib/fontist/utils/locking.rb
fontist-1.8.11 lib/fontist/utils/locking.rb
fontist-1.8.10 lib/fontist/utils/locking.rb
fontist-1.8.9 lib/fontist/utils/locking.rb
fontist-1.8.8 lib/fontist/utils/locking.rb
fontist-1.8.7 lib/fontist/utils/locking.rb
fontist-1.8.6 lib/fontist/utils/locking.rb
fontist-1.8.5 lib/fontist/utils/locking.rb
fontist-1.8.4 lib/fontist/utils/locking.rb
fontist-1.8.3 lib/fontist/utils/locking.rb