class RspecApiDocs::Formatter
The RSpec formatter.
Usage:
rspec --format=RspecApiDocs::Formatter
Attributes
renderer[R]
Public Class Methods
new(*args, renderer: default_renderer)
click to toggle source
Calls superclass method
# File lib/rspec_api_docs/formatter.rb, line 24 def initialize(*args, renderer: default_renderer) @renderer = renderer super args end
Public Instance Methods
close(null_notification)
click to toggle source
Calls the configured renderer with the stored {Resource}s.
@return [void]
# File lib/rspec_api_docs/formatter.rb, line 41 def close(null_notification) renderer.new(resource_collection.all).render end
example_passed(example_notification)
click to toggle source
Initializes and stores {Resource}s.
@return [void]
# File lib/rspec_api_docs/formatter.rb, line 32 def example_passed(example_notification) rspec_example = example_notification.example return unless rspec_example.metadata[METADATA_NAMESPACE] resource_collection.add_example(rspec_example) end
Private Instance Methods
default_renderer()
click to toggle source
# File lib/rspec_api_docs/formatter.rb, line 51 def default_renderer value = RspecApiDocs.configuration.renderer case value when :json Renderer::JSONRenderer when :raddocs Renderer::RaddocsRenderer when :slate Renderer::SlateRenderer when Class value else raise UnknownRenderer, "unknown renderer #{value.inspect}" end end
resource_collection()
click to toggle source
# File lib/rspec_api_docs/formatter.rb, line 47 def resource_collection @resource_collection ||= ResourceCollection.new end