Class: Polytrix::Reporters::MarkdownReporter

Inherits:
Object
  • Object
show all
Includes:
Util::String
Defined in:
lib/polytrix/reporters/markdown_reporter.rb

Instance Method Summary collapse

Methods included from Util::String

included

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

Returns:

  • (Boolean)


21
22
23
# File 'lib/polytrix/reporters/markdown_reporter.rb', line 21

def colors?
  false
end


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