Sha256: bcd87f28d5ff3672772a9679a6ec32ed8b877d8c70b2f29a20e0b86de5400a72
Contents?: true
Size: 1.55 KB
Versions: 3
Compression:
Stored size: 1.55 KB
Contents
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__))) require 'digest' module RBatch @@program_name = $PROGRAM_NAME module_function def program_name=(f) ; @@program_name = f ; end def program_name ; @@program_name ; end def tmp_dir case RUBY_PLATFORM when /mswin|mingw/ return ENV["TEMP"] when /cygwin|linux/ return "/tmp/" else raise "Unknown RUBY_PRATFORM : " + RUBY_PLATFORM end end def common_config_path File.join(File.dirname(RBatch.program_name),"..","conf","rbatch.yaml") end def common_config if File.exist?(RBatch.common_config_path) yaml = YAML::load_file(RBatch.common_config_path) if yaml return yaml else # If file is emply , YAML::load_file is false return nil end else return nil end end def double_run_check # double run check if ( RBatch::common_config != nil && RBatch::common_config["forbid_double_run"] ) lock_file="rbatch_lock_" + Digest::MD5.hexdigest(@@program_name) if Dir.exists? RBatch::tmp_dir Dir::foreach(RBatch::tmp_dir) do |f| if (Regexp.new(lock_file) =~ f) raise RBatchException, "Script double run is forbid about \"#{RBatch::program_name}\"" end end end # make lockfile Tempfile::new(lock_file,RBatch::tmp_dir) end end def double_run_lock_file ; ; end end # RBatch Exception class RBatchException < Exception ; end # main require 'rbatch/log' require 'rbatch/config' require 'rbatch/cmd' RBatch::double_run_check
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rbatch-1.8.2 | lib/rbatch.rb |
rbatch-1.8.1 | lib/rbatch.rb |
rbatch-1.8.0 | lib/rbatch.rb |