Class: Airbrussh::ConsoleFormatter
- Inherits:
-
SSHKit::Formatter::Abstract
- Object
- SSHKit::Formatter::Abstract
- Airbrussh::ConsoleFormatter
show all
- Extended by:
- Forwardable
- Includes:
- Colors
- Defined in:
- lib/airbrussh/console_formatter.rb
Constant Summary
Constants included
from Colors
Airbrussh::Colors::ANSI_CODES
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(io, config = Airbrussh.configuration) ⇒ ConsoleFormatter
Returns a new instance of ConsoleFormatter.
15
16
17
18
19
20
21
22
23
|
# File 'lib/airbrussh/console_formatter.rb', line 15
def initialize(io, config=Airbrussh.configuration)
super(io)
@config = config
@context = config.context.new(config)
@console = Airbrussh::Console.new(original_output, config)
write_banner
end
|
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
12
13
14
|
# File 'lib/airbrussh/console_formatter.rb', line 12
def config
@config
end
|
#context ⇒ Object
Returns the value of attribute context.
12
13
14
|
# File 'lib/airbrussh/console_formatter.rb', line 12
def context
@context
end
|
Instance Method Details
#log_command_data(command, stream_type, string) ⇒ Object
37
38
39
40
41
42
43
44
|
# File 'lib/airbrussh/console_formatter.rb', line 37
def log_command_data(command, stream_type, string)
return if debug?(command)
return unless config.show_command_output?(stream_type)
command = decorate(command)
string.each_line do |line|
print_indented_line(command.format_output(line))
end
end
|
#log_command_exit(command) ⇒ Object
46
47
48
49
50
|
# File 'lib/airbrussh/console_formatter.rb', line 46
def log_command_exit(command)
return if debug?(command)
command = decorate(command)
print_indented_line(command.exit_message, -2)
end
|
#log_command_start(command) ⇒ Object
29
30
31
32
33
34
35
|
# File 'lib/airbrussh/console_formatter.rb', line 29
def log_command_start(command)
return if debug?(command)
first_execution = register_new_command(command)
command = decorate(command)
print_task_if_changed
print_indented_line(command.start_message) if first_execution
end
|
#write(obj) ⇒ Object
Also known as:
<<
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/airbrussh/console_formatter.rb', line 52
def write(obj)
case obj
when SSHKit::Command
log_command_start(obj)
log_and_clear_command_output(obj, :stderr)
log_and_clear_command_output(obj, :stdout)
log_command_exit(obj) if obj.finished?
when SSHKit::LogMessage
write_log_message(obj)
end
end
|
#write_banner ⇒ Object
25
26
27
|
# File 'lib/airbrussh/console_formatter.rb', line 25
def write_banner
print_line(config.banner_message) if config.banner_message
end
|