lib/rbatch.rb in rbatch-1.12.3 vs lib/rbatch.rb in rbatch-1.13.0
- old
+ new
@@ -1,12 +1,16 @@
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)))
require 'digest'
module RBatch
@@program_name = $PROGRAM_NAME
+ @@home_dir = ""
module_function
def program_name=(f) ; @@program_name = f ; end
def program_name ; @@program_name ; end
+ def home_dir=(d) ; @@home_dir = d ; end
+ def home_dir ; @@home_dir ; end
+
# Hostname
def hostname
case RUBY_PLATFORM
when /mswin|mingw/
return ENV["COMPUTERNAME"] ? ENV["COMPUTERNAME"] : "unknownhost"
@@ -34,11 +38,11 @@
return ENV["TMPDIR"] || ENV["TEMP"]
end
end
end
def rbatch_config_path
- File.join(File.dirname(RBatch.program_name),"..","conf","rbatch.yaml")
+ File.join(@@home_dir,"conf","rbatch.yaml")
end
def rbatch_config
if File.exist?(RBatch.rbatch_config_path)
yaml = YAML::load_file(RBatch.rbatch_config_path)
if yaml
@@ -72,9 +76,15 @@
# RBatch Exception
class RBatchException < Exception ; end
# main
+if ENV["RB_HOME"]
+ RBatch::home_dir = ENV["RB_HOME"]
+else
+ RBatch::home_dir = File.join(File.dirname(RBatch.program_name) , "..")
+end
+
require 'rbatch/log'
require 'rbatch/config'
require 'rbatch/common_config'
require 'rbatch/cmd'