Sha256: a0c89d5313cd9b733c9a08d6feceed07869d4c4fe3427391213b5280063be60f

Contents?: true

Size: 552 Bytes

Versions: 8

Compression:

Stored size: 552 Bytes

Contents

require 'tmpdir'
require 'tempfile'
module RBatch
  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

  class DoubleRunCheckException < Exception ; end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rbatch-2.1.6 lib/rbatch/double_run_checker.rb
rbatch-2.1.5 lib/rbatch/double_run_checker.rb
rbatch-2.1.4 lib/rbatch/double_run_checker.rb
rbatch-2.1.3 lib/rbatch/double_run_checker.rb
rbatch-2.1.2 lib/rbatch/double_run_checker.rb
rbatch-2.1.1 lib/rbatch/double_run_checker.rb
rbatch-2.1.0 lib/rbatch/double_run_checker.rb
rbatch-2.0.0 lib/rbatch/double_run_checker.rb