Class: RspecApiDocs::Renderer::JSONRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec_api_docs/formatter/renderer/json_renderer.rb,
lib/rspec_api_docs/formatter/renderer/json_renderer/name.rb,
lib/rspec_api_docs/formatter/renderer/json_renderer/example_serializer.rb,
lib/rspec_api_docs/formatter/renderer/json_renderer/resource_serializer.rb

Defined Under Namespace

Classes: ExampleSerializer, Name, ResourceSerializer

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resources) ⇒ JSONRenderer


10
11
12
# File 'lib/rspec_api_docs/formatter/renderer/json_renderer.rb', line 10

def initialize(resources)
  @resources = resources
end

Instance Attribute Details

#resourcesObject (readonly)

Returns the value of attribute resources


8
9
10
# File 'lib/rspec_api_docs/formatter/renderer/json_renderer.rb', line 8

def resources
  @resources
end

Instance Method Details

#renderObject


14
15
16
17
18
19
20
# File 'lib/rspec_api_docs/formatter/renderer/json_renderer.rb', line 14

def render
  FileUtils.mkdir_p output_file.dirname

  File.open(output_file, 'w') do |f|
    f.write JSON.pretty_generate(output) + "\n"
  end
end