class Rake::Application

Public Class Methods

catchStderr() click to toggle source
# File lib/rake/extensions.rb, line 118
def self.catchStderr()
  @logToStderr = false;
  @oldStderr = $stderr;
  $stderr = @logFile;
end
catchStdout() click to toggle source
# File lib/rake/extensions.rb, line 113
def self.catchStdout()
  @oldStdout = $stdout;
  $stdout = @logFile;
end
debug(*args) click to toggle source
# File lib/rake/extensions.rb, line 171
def self.debug(*args)
  @logger.debug(*args) if @logger;
end
error(*args) click to toggle source
# File lib/rake/extensions.rb, line 159
def self.error(*args)
  @logger.error(*args) if @logger;
end
fatal(*args) click to toggle source
# File lib/rake/extensions.rb, line 155
def self.fatal(*args)
  @logger.fatal(*args) if @logger;
end
flushLog() click to toggle source
# File lib/rake/extensions.rb, line 128
def self.flushLog()
  @logFile.flush();
end
info(*args) click to toggle source
# File lib/rake/extensions.rb, line 167
def self.info(*args)
  @logger.info(*args) if @logger;
end
log(*args) click to toggle source
# File lib/rake/extensions.rb, line 151
def self.log(*args)
  @logger.log(*args) if @logger;
end
logData(someData) click to toggle source
# File lib/rake/extensions.rb, line 140
def self.logData(someData)
  @logFile.write(someData) if @logFile;
end
logFile() click to toggle source
# File lib/rake/extensions.rb, line 136
def self.logFile()
  return @logFile;
end
logger() click to toggle source
# File lib/rake/extensions.rb, line 132
def self.logger()
  return @logger;
end
mesg(*args) click to toggle source
# File lib/rake/extensions.rb, line 175
def self.mesg(*args)
  @logger.info(*args) if @logger;
  $stderr.puts(*args) if @logToStderr;
end
mesg_conf() click to toggle source
# File lib/rake/extensions.rb, line 202
def self.mesg_conf
  str = Conf.prettyPrint;
  @logger.info(str);
  $stderr.puts(str) if @logToStderr;
end
mesg_pp(*args) click to toggle source

taken from www.ruby-forum.com/topic/43725 (2012/01/21)

# File lib/rake/extensions.rb, line 181
def self.mesg_pp(*args)
  old_out = $stdout
  begin
    s=StringIO.new
    $stdout=s
    pp(*args)
  ensure
    $stdout=old_out
  end
  @logger.info(s.string);
  $stderr.puts(s.string) if @logToStderr;
end
mesg_yaml(*args) click to toggle source
# File lib/rake/extensions.rb, line 194
def self.mesg_yaml(*args)
  args.each do | anArg |
    str = YAML.dump(anArg);
    @logger.info(str);
    $stderr.puts(str) if @logToStderr;
  end
end
openLogger(logFileBaseName) click to toggle source
# File lib/rake/extensions.rb, line 105
def self.openLogger(logFileBaseName)
  timeStamp = Time.now.utc.strftime("%Y-%m-%d-%H-%M-%S-%L.log");
  @logFile = File.open(logFileBaseName+'-'+timeStamp, 'w');
  @logger = Logger.new(@logFile);
  @logger.datetime_format = "%H-%M-%S-%L";
  @logToStderr = true;
end
setLogToStderr(logToStderr) click to toggle source
# File lib/rake/extensions.rb, line 124
def self.setLogToStderr(logToStderr)
  @logToStderr = logToStderr;
end
set_logger(aLogger, aLogFile=nil) click to toggle source
# File lib/rake/extensions.rb, line 144
def self.set_logger(aLogger, aLogFile=nil)
  @logFile = aLogFile;
  oldLogger = @logger;
  @logger = aLogger;
  return oldLogger;
end
warn(*args) click to toggle source
# File lib/rake/extensions.rb, line 163
def self.warn(*args)
  @logger.warn(*args) if @logger;
end

Public Instance Methods

collect_command_line_tasks() click to toggle source
# File lib/rake/config.rb, line 531
def collect_command_line_tasks
  rake_config_original_collect_command_line_tasks;
  @top_level_tasks.unshift("cookPostConfig");
  @top_level_tasks.unshift("cookConfig");
  @top_level_tasks.unshift("cookPreConfig");
end
rake_config_original_collect_command_line_tasks()
rake_config_original_standard_rake_options()
rake_config_original_top_level()
Alias for: top_level
raw_load_rakefile() click to toggle source
# File lib/rake/config.rb, line 546
def raw_load_rakefile
  myCookbookDir = File.expand_path(Dir.getwd());
  FileUtils.mkdir_p('logs');
  Rake::Application.openLogger('logs/'+Conf.log_file_name.gsub(/\//,'_')+'-buildLog');
  Rake::Application.logger.level = Logger::DEBUG;
  Rake::Application.mesg "Cook version: #{Cook::VERSION}";
  Conf.add_global_cookbooks();
  Rake::Application.mesg "Building in #{myCookbookDir}";
  Conf.add_cookbook(myCookbookDir);
end
standard_rake_options() click to toggle source
# File lib/rake/config.rb, line 509
def standard_rake_options
  options = rake_config_original_standard_rake_options();
  options.push(
    ['--config', '-c YAML-CONFIG-FILE-NAME', "Load YAML configuration files named YAML-CONFIG-FILE-NAME in each receipe if it exists", 
      lambda { |value|
        confValues = value.split(/,/).each do | aValue |
          Conf.add_config_file_name(aValue);
        end
      }
    ]);
  options.push(
    ['--global-cookbook', '-C GLOBAL-COOKBOOK-DIRECTORY', "Load global Cookbook from the GLOBAL-COOKBOOK-DIRECTORY if it exists", 
      lambda { |value|
        confDirValues = value.split(/,/).each do | aValue |
          Conf.add_global_cookbook_directory(aValue);
        end
      }
    ]);
  return options;
end
top_level() click to toggle source
# File lib/rake/config.rb, line 539
def top_level
  # load the central config files after all recipes
  Conf.load_central_config_files(); 
  # but before we start invoking tasks
  rake_config_original_top_level;
end