Class: RSpecDocumentation::Formatters::Yaml
- Inherits:
-
Object
- Object
- RSpecDocumentation::Formatters::Yaml
- Defined in:
- lib/rspec_documentation/formatters/yaml.rb
Overview
Produces prettified YAML to from an RSpec ‘subject` value.
Instance Method Summary collapse
-
#initialize(subject:) ⇒ Yaml
constructor
A new instance of Yaml.
- #prettified_output ⇒ Object
- #render_raw? ⇒ Boolean
- #rendered_output ⇒ Object
Constructor Details
#initialize(subject:) ⇒ Yaml
Returns a new instance of Yaml.
7 8 9 |
# File 'lib/rspec_documentation/formatters/yaml.rb', line 7 def initialize(subject:) @subject = subject end |
Instance Method Details
#prettified_output ⇒ Object
11 12 13 |
# File 'lib/rspec_documentation/formatters/yaml.rb', line 11 def prettified_output nil end |
#render_raw? ⇒ Boolean
23 24 25 |
# File 'lib/rspec_documentation/formatters/yaml.rb', line 23 def render_raw? false end |
#rendered_output ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/rspec_documentation/formatters/yaml.rb', line 15 def rendered_output formatter = Rouge::Formatters::HTML.new lexer = Rouge::Lexers::YAML.new formatter.format(lexer.lex(YAML.safe_load(subject, permitted_classes: permitted_classes).to_yaml)) rescue Psych::SyntaxError => e raise Error, "Expected YAML for:\n#{subject}\n\nSyntax Error: #{e}" end |