class RBatch::Controller

@private

Attributes

vars[RW]

Public Class Methods

new() click to toggle source
# File lib/rbatch/controller.rb, line 13
def initialize
  @vars = RBatch::Variables.new()
  RBatch::Journal.def_vars = @vars
  RBatch::Log.def_vars = @vars
  RBatch::Cmd.def_vars = @vars
  @journal = RBatch::Journal.new()
  RBatch::Log.journal = @journal
  @user_logs = []
  @journal.put 1,"=== START RBatch === (PID=#{$$.to_s})"
  @journal.put 1, "RB_HOME : \"#{@vars[:home_dir]}\""
  @journal.put 1, "Load Run-Conf: \"#{@vars[:run_conf_path]}\""
  @journal.put 2, "RBatch Variables : #{@vars.inspect}"
  # Load common_config
  if File.exist?(@vars[:common_config_path])
    @common_config = RBatch::Config.new(@vars[:common_config_path],false)
  elsif File.exist?(@vars[:common_config_erb_path])
    @common_config = RBatch::Config.new(@vars[:common_config_erb_path],true)
  else
    # If neither exist, make normal config instance.
    # This avoid outputting "undefined method `[]'" when RBatch.config[xx] is called.
    @common_config = RBatch::Config.new(@vars[:common_config_path],false)
  end
  @journal.put 1, "Load Config  : \"#{@common_config.path}\"" if @common_config.exist?
  # Load config
  if File.exist?(@vars[:config_path])
    @config = RBatch::Config.new(@vars[:config_path],false)
  elsif File.exist?(@vars[:config_erb_path])
    @config = RBatch::Config.new(@vars[:config_erb_path],true)
  else
    # If neither exist, make normal config instance.
    # This avoid outputting "undefined method `[]'" when RBatch.config[xx] is called.
    @config = RBatch::Config.new(@vars[:config_path],false)
  end
  @journal.put 1, "Load Config  : \"#{@config.path}\"" if @config.exist?
  # double_run_check
  if ( @vars[:forbid_double_run])
    RBatch::DoubleRunChecker.check(@vars[:program_base]) #raise error if check is NG
    RBatch::DoubleRunChecker.make_lock_file(@vars[:program_base])
  end
end

Public Instance Methods

cmd(cmd_str,opt) click to toggle source
# File lib/rbatch/controller.rb, line 67
def cmd(cmd_str,opt)
  RBatch::Cmd.new(cmd_str,opt).run
end
common_config() click to toggle source
# File lib/rbatch/controller.rb, line 66
def common_config ; @common_config ; end
config() click to toggle source
# File lib/rbatch/controller.rb, line 65
def config ; @config ; end
load_lib() click to toggle source
# File lib/rbatch/controller.rb, line 53
def load_lib
  $LOAD_PATH.push(@vars[:lib_dir])
  if @vars[:auto_lib_load] && Dir.exist?(@vars[:lib_dir])
    Dir.glob(File.join(@vars[:lib_dir],"**","*")) do |path|
      if File::basename(path) =~ /^[^\.].*\.rb$/
        require File.expand_path(path)
        @journal.put 1, "Load Library : \"#{File.expand_path(path)}\" "
      end
    end
  end
  @journal.put 1, "Start Script : \"#{@vars[:program_path]}\""
end