Handles basic indentation and colorization tasks
Print text. This will start a new line and indent if necessary but will not terminate the line (future print and puts statements will start off where this print left off).
# File lib/chef/formatters/indentable_output_stream.rb, line 30 def color(string, *args) print(string, from_args(args)) end
# File lib/chef/formatters/indentable_output_stream.rb, line 20 def highline @highline ||= begin require 'highline' HighLine.new end end
Print a string.
string: string to print. options: a hash with these possible options:
:stream => OBJ: unique identifier for a stream. If two prints have
different streams, they will print on separate lines. Otherwise, they will stay together.
:start_line => BOOLEAN: if true, print will begin on a blank (indented) line.
:end_line => BOOLEAN: if true, current line will be ended.
:name => STRING: a name to prefix in front of a stream. It will be printed
once (with the first line of the stream) and subsequent lines will be indented to match.
You may also call print(‘string’, :red) (a list of colors a la Highline.color)
# File lib/chef/formatters/indentable_output_stream.rb, line 70 def print(string, *args) options = from_args(args) # Make sure each line stays a unit even with threads sending output semaphore.synchronize do if should_start_line?(options) move_to_next_line end print_string(string, options) if should_end_line?(options) move_to_next_line end end end
Print a line. This will continue from the last start_line or print, or start a new line and indent if necessary.
# File lib/chef/formatters/indentable_output_stream.rb, line 43 def puts(string, *args) print(string, from_args(args, :end_line => true)) end
Print an entire line from start to end. This will terminate any existing lines and cause indentation.
# File lib/chef/formatters/indentable_output_stream.rb, line 49 def puts_line(string, *args) print(string, from_args(args, :start_line => true, :end_line => true)) end
Print the start of a new line. This will terminate any existing lines and cause indentation but will not move to the next line yet (future ‘print’ and ‘puts’ statements will stay on this line).
# File lib/chef/formatters/indentable_output_stream.rb, line 37 def start_line(string, *args) print(string, from_args(args, :start_line => true)) end
Generated with the Darkfish Rdoc Generator 2.