Skip to content
Wes Bailey edited this page Jul 21, 2017 · 7 revisions

The most important concept of command line reporter is the usage of report block. This is what sets up the capability of having Formatters do all of their work. The following are the allowed values of the options hash argument to the report method:

  • :message - The string that is displayed as the first part of the message to the user
  • :complete - The string that completes the message to the user
  • :type - Define as 'inline' if you want the message and complete strings on the same line
  • :indent_size - The number of spaces to indent the current level
  • :color - The color to use for the terminal output i.e. 'red' or 'blue' or 'green'
  • :bold - true|false to boldface the font
report(message: 'running', complete: 'finished', type: 'inline', indent_size: 8) do
  # code here
end

Variable Access

Just like any block in ruby if the code requires access outside it then you need to initialize the variable prior to the block.

counter = 0

report do
  ...
  counter += 1
  ...
end

aligned(counter, align: 'right', width: 50)

Colors

With the release of version 3.0 it is now possible to specify both the color of the font and the boldface as shown below:

report color: 'red', bold: true do
   ...
end
Clone this wiki locally