Sha256: 365cc8b80606c32a75b3db6fea8ff3554db230a9ecb83fc010c862162333ed13

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

module Empezar
  class Runner
    def self.run params
      self.start_configuration params[:config_file], params[:arguments]
      self.start_logger params[:log_file], params[:stdout]
    end

    def self.start_configuration config_file, arguments
      unless File.exist? config_file
        raise ConfigurationFileMissingException, "The configuration file is missing from '#{config_file}'"
      end
      Empezar::Configuration.instance.merge! SymbolMatrix.new config_file
      Empezar::Configuration.instance
        .recursive_merge! SymbolMatrix.new(arguments.join(" ")), true
    end

    def self.start_logger log_file, stdout
      if log_file == 'log/main.log'
        Dir.mkdir 'log' unless Dir.exist? 'log'
        Empezar::Log.start Logger.new 'log/main.log', 'daily'
      else 
        Empezar::Log.start Logger.new log_file, 'daily'
      end
      if Empezar::Configuration.instance.has_key? :verbosity and Empezar::Configuration.instance.verbosity == 'silent'
      else
        Empezar::Log.instance.formatter = EchoingFormatter.new Logger::Formatter.new, stdout
      end
    end
  end
end

class Runner
  class << self
    def method_missing *args
      Empezar::Runner.send *args
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
empezar-0.4.1 lib/empezar/runner.rb