Class: Scripted::Formatters::Default
- Inherits:
-
Blank
- Object
- Blank
- Scripted::Formatters::Default
show all
- Defined in:
- lib/scripted/formatters/default.rb
Instance Attribute Summary
Attributes inherited from Blank
#configuration, #raw_out
Instance Method Summary
collapse
Methods inherited from Blank
#done, #execute, #halted, #start, #stop
Constructor Details
Returns a new instance of Default.
15
16
17
18
|
# File 'lib/scripted/formatters/default.rb', line 15
def initialize(*)
super
@buffers = Hash.new { |h,k| h[k] = StringIO.new }
end
|
Instance Method Details
#clean_backtrace(backtrace) ⇒ Object
55
56
57
58
|
# File 'lib/scripted/formatters/default.rb', line 55
def clean_backtrace(backtrace)
gem_path = File.expand_path("../../../", __FILE__)
backtrace.reject { |line| line.start_with?(gem_path) }
end
|
#close ⇒ Object
38
39
40
41
42
43
44
45
|
# File 'lib/scripted/formatters/default.rb', line 38
def close
if file?
@buffers.each do |command, output|
output.rewind
puts output.read
end
end
end
|
#command_puts(command, *args) ⇒ Object
47
48
49
50
51
52
53
|
# File 'lib/scripted/formatters/default.rb', line 47
def command_puts(command, *args)
if file?
@buffers[command].puts *args
else
puts *args
end
end
|
#each_char(output, command) ⇒ Object
20
21
22
23
24
25
26
|
# File 'lib/scripted/formatters/default.rb', line 20
def each_char(output, command)
if file?
@buffers[command].print output
else
print output
end
end
|
#exception(command, exception) ⇒ Object
28
29
30
31
32
33
34
35
36
|
# File 'lib/scripted/formatters/default.rb', line 28
def exception(command, exception)
command_puts command, red(" #{exception.class} during the execution of #{command.name.inspect}:")
exception.to_s.split("\n").each do |line|
command_puts command, red(" #{line}")
end
clean_backtrace(exception.backtrace).each do |line|
command_puts command, cyan(" # #{line}")
end
end
|