Class: Albacore::Application

Inherits:
Object
  • Object
show all
Defined in:
lib/albacore/application.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(log = STDOUT, output = STDOUT, output_err = STDERR) ⇒ Application

initialize a new albacore application with a given log IO object

Raises:

  • (ArgumentError)


18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/albacore/application.rb', line 18

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

Instance Attribute Details

#loggerObject (readonly)

the logger instance for this application



8
9
10
# File 'lib/albacore/application.rb', line 8

def logger
  @logger
end

#outputObject (readonly)

the output IO for this application, defaults to STDOUT



12
13
14
# File 'lib/albacore/application.rb', line 12

def output
  @output
end

#output_errObject (readonly)

the standard IO error output



15
16
17
# File 'lib/albacore/application.rb', line 15

def output_err
  @output_err
end

Instance Method Details

#define_task(*args, &block) ⇒ Object



31
32
33
# File 'lib/albacore/application.rb', line 31

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

#err(*args) ⇒ Object

write a line to stderr



41
42
43
# File 'lib/albacore/application.rb', line 41

def err *args
  @output_err.puts *args
end

#puts(*args) ⇒ Object

wite a line to stdout



36
37
38
# File 'lib/albacore/application.rb', line 36

def puts *args
  @output.puts *args 
end