Class: Polytrix::Reporters::MarkdownReporter
- Inherits:
-
Object
- Object
- Polytrix::Reporters::MarkdownReporter
- Includes:
- Util::String
- Defined in:
- lib/polytrix/reporters/markdown_reporter.rb
Instance Method Summary collapse
- #colors? ⇒ Boolean
-
#initialize(io = $stdout) ⇒ MarkdownReporter
constructor
A new instance of MarkdownReporter.
- #print_table(table) ⇒ Object
Methods included from Util::String
Methods included from Util::String::ClassMethods
#ansi2html, #escape_html, #highlight, #slugify
Constructor Details
#initialize(io = $stdout) ⇒ MarkdownReporter
Returns a new instance of MarkdownReporter.
5 6 7 |
# File 'lib/polytrix/reporters/markdown_reporter.rb', line 5 def initialize(io = $stdout) @buffer = io end |
Instance Method Details
#colors? ⇒ Boolean
21 22 23 |
# File 'lib/polytrix/reporters/markdown_reporter.rb', line 21 def colors? false end |
#print_table(table) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/polytrix/reporters/markdown_reporter.rb', line 9 def print_table(table) @buffer.puts # Markdown tables don't always render properly without a break header_data = table[0] header_line = header_data.join ' | ' @buffer.puts header_line @buffer.puts header_line.gsub(/[^|]/, '-') table[1..-1].each do |data_line| @buffer.puts data_line.map { |line| escape_html(line) }.join(' | ') end end |