Sha256: 33400dee8033dcd8d421a668894642e67f91a34e0048dd5d9ed31737d5e45f66

Contents?: true

Size: 1.2 KB

Versions: 30

Compression:

Stored size: 1.2 KB

Contents

require 'rake'
require 'time'

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

30 entries across 30 versions & 1 rubygems

Version Path
albacore-2.1.2 lib/albacore/application.rb
albacore-2.1.1 lib/albacore/application.rb
albacore-2.0.16 lib/albacore/application.rb
albacore-2.0.15 lib/albacore/application.rb
albacore-2.0.14 lib/albacore/application.rb
albacore-2.0.13 lib/albacore/application.rb
albacore-2.0.12 lib/albacore/application.rb
albacore-2.0.11 lib/albacore/application.rb
albacore-2.0.10 lib/albacore/application.rb
albacore-2.0.9 lib/albacore/application.rb
albacore-2.0.8 lib/albacore/application.rb
albacore-2.0.7 lib/albacore/application.rb
albacore-2.0.6 lib/albacore/application.rb
albacore-2.0.5 lib/albacore/application.rb
albacore-2.0.4 lib/albacore/application.rb
albacore-2.0.3 lib/albacore/application.rb
albacore-2.0.2 lib/albacore/application.rb
albacore-2.0.1 lib/albacore/application.rb
albacore-2.0.0 lib/albacore/application.rb
albacore-2.0.0.rc.21 lib/albacore/application.rb