Class: Build::CompactFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/build/logger.rb

Instance Method Summary collapse

Constructor Details

#initializeCompactFormatter



26
27
28
# File 'lib/build/logger.rb', line 26

def initialize
	@start = Time.now
end

Instance Method Details

#call(severity, datetime, progname, message) ⇒ Object



57
58
59
60
61
62
63
# File 'lib/build/logger.rb', line 57

def call(severity, datetime, progname, message)
	if progname == 'shell' and Array === message
		"#{time_offset_string}: #{format_command(message)}\n"
	else
		"#{time_offset_string}: #{message}\n"
	end
end

#chdir_string(options) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/build/logger.rb', line 36

def chdir_string(options)
	if options[:chdir]
		" in #{options[:chdir]}"
	else
		""
	end
end

#format_command(arguments) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/build/logger.rb', line 44

def format_command(arguments)
	if arguments.last.is_a? Hash
		options = arguments.last
		arguments = arguments[0...-1]
	else
		options = {}
	end
	
	arguments = arguments.flatten.collect &:to_s
	
	Rainbow(arguments.join(' ')).blue + chdir_string(options)
end

#time_offset_stringObject



30
31
32
33
34
# File 'lib/build/logger.rb', line 30

def time_offset_string
	offset = Time.now - @start
	
	"T+#{offset.round(2).to_s.ljust(5)}"
end