Class: RSpecDocumentation::Document
- Inherits:
-
Object
- Object
- RSpecDocumentation::Document
- Defined in:
- lib/rspec_documentation/document.rb
Overview
Translates a Markdown document into a structure of parsed Markdown and embedded RSpec examples.
Instance Attribute Summary collapse
-
#failures ⇒ Object
readonly
Returns the value of attribute failures.
-
#page_tree ⇒ Object
readonly
Returns the value of attribute page_tree.
Instance Method Summary collapse
- #footer ⇒ Object
- #header ⇒ Object
- #homepage ⇒ Object
- #html ⇒ Object
-
#initialize(document:, path:, page_tree:) ⇒ Document
constructor
A new instance of Document.
- #javascript_bundle_src ⇒ Object
- #render ⇒ Object
- #specs ⇒ Object
- #stylesheet_bundle_href ⇒ Object
- #title ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(document:, path:, page_tree:) ⇒ Document
Returns a new instance of Document.
8 9 10 11 12 13 |
# File 'lib/rspec_documentation/document.rb', line 8 def initialize(document:, path:, page_tree:) @document = document @path = path @page_tree = page_tree @failures = [] end |
Instance Attribute Details
#failures ⇒ Object (readonly)
Returns the value of attribute failures.
6 7 8 |
# File 'lib/rspec_documentation/document.rb', line 6 def failures @failures end |
#page_tree ⇒ Object (readonly)
Returns the value of attribute page_tree.
6 7 8 |
# File 'lib/rspec_documentation/document.rb', line 6 def page_tree @page_tree end |
Instance Method Details
#footer ⇒ Object
50 51 52 |
# File 'lib/rspec_documentation/document.rb', line 50 def RSpecDocumentation.template('footer').result(binding) end |
#header ⇒ Object
46 47 48 |
# File 'lib/rspec_documentation/document.rb', line 46 def header RSpecDocumentation.template('header').result(binding) end |
#homepage ⇒ Object
42 43 44 |
# File 'lib/rspec_documentation/document.rb', line 42 def homepage gem_spec&.homepage end |
#html ⇒ Object
30 31 32 |
# File 'lib/rspec_documentation/document.rb', line 30 def html parsed_document.html end |
#javascript_bundle_src ⇒ Object
58 59 60 |
# File 'lib/rspec_documentation/document.rb', line 58 def javascript_bundle_src Util.assets_root.join('bundle.js') end |
#render ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rspec_documentation/document.rb', line 19 def render parsed_document.execute_and_substitute_examples! if parsed_document.failures.empty? RSpecDocumentation.template('layout').result(binding) else failures.concat(parsed_document.failures) nil end end |
#specs ⇒ Object
15 16 17 |
# File 'lib/rspec_documentation/document.rb', line 15 def specs @specs ||= parsed_document.specs end |
#stylesheet_bundle_href ⇒ Object
54 55 56 |
# File 'lib/rspec_documentation/document.rb', line 54 def stylesheet_bundle_href Util.assets_root.join('bundle.css') end |
#title ⇒ Object
34 35 36 |
# File 'lib/rspec_documentation/document.rb', line 34 def title gem_spec&.name || 'Documentation' end |
#version ⇒ Object
38 39 40 |
# File 'lib/rspec_documentation/document.rb', line 38 def version gem_spec&.version end |