Class: SimpleCov::Formatter::MultiFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/simplecov/formatter/multi_formatter.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.[](*args) ⇒ Object


4
5
6
7
8
9
10
# File 'lib/simplecov/formatter/multi_formatter.rb', line 4

def self.[](*args)
  Class.new(self) do
    define_method :formatters do
      @formatters ||= args
    end
  end
end

Instance Method Details

#format(result) ⇒ Object


12
13
14
15
16
17
18
19
20
21
# File 'lib/simplecov/formatter/multi_formatter.rb', line 12

def format(result)
  formatters.map do |formatter|
    begin
      formatter.new.format(result)
    rescue => e
      STDERR.puts("Formatter #{formatter} failed with #{e.class}: #{e.message} (#{e.backtrace.first})")
      nil
    end
  end
end

#formattersObject


23
24
25
# File 'lib/simplecov/formatter/multi_formatter.rb', line 23

def formatters
  @formatters ||= []
end