Sha256: b6d900b71564a1a0a9008ffef4cee5832e1018b5d0593ed69d0ff7cd8fd4700e

Contents?: true

Size: 1.18 KB

Versions: 3

Compression:

Stored size: 1.18 KB

Contents

require 'rake'

module Albacore
  class Application

    # the logger instance for this application
    attr_reader :logger

    # the output IO for this application, defaults to
    # STDOUT
    attr_reader :output

    # the standard IO error output
    attr_reader :output_err
    
    # initialize a new albacore application with a given log IO object
    def initialize log = STDOUT, output = STDOUT, output_err = STDERR
      raise ArgumentError, "log must not be nil" unless log
      raise ArgumentError, "output must not be nil" unless output
      raise ArgumentError, "out_err must not be nil" unless output_err
      @logger = Logger.new log
      @logger.level = Logger::INFO
      @logger.formatter = proc do |severity, datetime, progname, msg|
        "#{severity[0]} #{datetime.to_datetime.iso8601(6)}: #{msg}\n"
      end
      @output = output
      @output_err = output_err
    end

    def define_task *args, &block
      Rake::Task.define_task *args, &block
    end

    # wite a line to stdout
    def puts *args
      @output.puts *args 
    end
    
    # write a line to stderr
    def err *args
      @output_err.puts *args
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
albacore-2.0.0.rc.9 lib/albacore/application.rb
albacore-2.0.0.rc.8 lib/albacore/application.rb
albacore-2.0.0.rc.7 lib/albacore/application.rb