Class: Empezar::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/empezar/runner.rb

Class Method Summary collapse

Class Method Details

.run(params) ⇒ Object



3
4
5
6
# File 'lib/empezar/runner.rb', line 3

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

.start_configuration(config_file, arguments) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/empezar/runner.rb', line 8

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

.start_logger(log_file, stdout) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/empezar/runner.rb', line 17

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