Class: RSpecDocumentation::Formatters::Ruby

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec_documentation/formatters/ruby.rb

Overview

Default formatter for all RSpec examples. Used by all examples to generate the “Spec” tab content, i.e. the original source of the example code.

Instance Method Summary collapse

Constructor Details

#initialize(subject:) ⇒ Ruby

Returns a new instance of Ruby.



8
9
10
# File 'lib/rspec_documentation/formatters/ruby.rb', line 8

def initialize(subject:)
  @subject = subject
end

Instance Method Details

#prettified_outputObject



12
13
14
# File 'lib/rspec_documentation/formatters/ruby.rb', line 12

def prettified_output
  nil
end

#render_raw?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/rspec_documentation/formatters/ruby.rb', line 24

def render_raw?
  false
end

#rendered_outputObject



16
17
18
19
20
21
22
# File 'lib/rspec_documentation/formatters/ruby.rb', line 16

def rendered_output
  formatter = Rouge::Formatters::HTML.new
  lexer = Rouge::Lexers::Ruby.new
  io = StringIO.new
  PP.pp(subject, io)
  formatter.format(lexer.lex(io.string))
end