Sha256: c0b01ae3494604a720aea244bdaf1ea33f0f2c9c22a5788cd6fc24e889037c4c

Contents?: true

Size: 580 Bytes

Versions: 11

Compression:

Stored size: 580 Bytes

Contents

require 'tmpdir'
require 'tempfile'
module RBatch
  # @private
  module DoubleRunChecker
    module_function
    def lock_file_name(p)
      File.join("rbatch_lock_" + p)
    end

    def check(p)
      Dir::foreach(Dir.tmpdir) do |f|
        if Regexp.new(lock_file_name(p)) =~ f
          raise RBatch::DoubleRunCheckException, p + " is forbidden running doubly"
        end
      end
    end

    def make_lock_file(p)
      Tempfile::new(lock_file_name(p),Dir.tmpdir)
    end
  end

  # @private
  class DoubleRunCheckException < Exception ; end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
rbatch-2.6.1 lib/rbatch/double_run_checker.rb
rbatch-2.6.0 lib/rbatch/double_run_checker.rb
rbatch-2.5.1 lib/rbatch/double_run_checker.rb
rbatch-2.5.0 lib/rbatch/double_run_checker.rb
rbatch-2.4.0 lib/rbatch/double_run_checker.rb
rbatch-2.3.1 lib/rbatch/double_run_checker.rb
rbatch-2.3.0 lib/rbatch/double_run_checker.rb
rbatch-2.2.0 lib/rbatch/double_run_checker.rb
rbatch-2.1.9 lib/rbatch/double_run_checker.rb
rbatch-2.1.8 lib/rbatch/double_run_checker.rb
rbatch-2.1.7 lib/rbatch/double_run_checker.rb