Class: Simplabs::Excellent::Formatters::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/simplabs/excellent/formatters/base.rb

Overview

The base class for all formatters.

Direct Known Subclasses

Html, Text

Instance Method Summary collapse

Constructor Details

#initialize(stream) ⇒ Base

Initializes the formatter.

Always call super in custom formatters!



13
14
15
# File 'lib/simplabs/excellent/formatters/base.rb', line 13

def initialize(stream)
  @stream = stream
end

Instance Method Details

#endObject

Called when the Simplabs::Excellent::Runner ends processing code.

The text formatter renders the footer here (‘Found <x> warnings’).



40
41
# File 'lib/simplabs/excellent/formatters/base.rb', line 40

def end
end

#file(filename) ⇒ Object

Called whenever the Simplabs::Excellent::Runner processes a file. Yields the formatter

You have to yield self in custom formatters. file is called like that by the runner:

formatter.file(filename) do |formatter|
  warnings.each { |warning| formatter.warning(warning) }
end


30
31
# File 'lib/simplabs/excellent/formatters/base.rb', line 30

def file(filename)
end

#startObject

Called when the Simplabs::Excellent::Runner starts processing code.

The text formatter renders the heading here (‘Excellent result’)



20
21
# File 'lib/simplabs/excellent/formatters/base.rb', line 20

def start
end

#warning(warning) ⇒ Object

Called when the Simplabs::Excellent::Runner found a warning. This warning will always refer to the last filename, file was invoked with.



34
35
# File 'lib/simplabs/excellent/formatters/base.rb', line 34

def warning(warning)
end