Class: MatrixFormatter::Formatters::MarkdownFormatter

Inherits:
BaseFormatter
  • Object
show all
Defined in:
lib/matrix_formatter/formatters/markdown_formatter.rb

Direct Known Subclasses

HTMLFormatter

Instance Attribute Summary

Attributes inherited from BaseFormatter

#matrix

Instance Method Summary collapse

Methods inherited from BaseFormatter

#dump_summary, #example_failed, #example_group_started, #example_passed, #example_pending, #example_started, #initialize, #start

Constructor Details

This class inherits a constructor from MatrixFormatter::Formatters::BaseFormatter

Instance Method Details

#markdownObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/matrix_formatter/formatters/markdown_formatter.rb', line 4

def markdown
  buffer = StringIO.new
  header_line = ['Feature Group', 'Feature', RSpec.configuration.matrix_implementors].join ' | '
  buffer.puts header_line
  buffer.puts header_line.gsub(/[^|]/, '-')

  @matrix.results.each do |product, features|
    # Only show the product on the first line
    product_text = "**#{product}**"
    features.each do |feature_key, feature_results|
      states = RSpec.configuration.matrix_implementors.map { |implementor|
        feature_results[implementor]
      }
      buffer.puts [product_text, "**#{feature_key}**", states].join ' | '
      product_text = ''
    end
  end
  buffer.string
end

#start_dumpObject



24
25
26
# File 'lib/matrix_formatter/formatters/markdown_formatter.rb', line 24

def start_dump
  @output.puts markdown
end