Class: RspecApiDocumentation::Writers::CombinedJsonWriter

Inherits:
Writer
  • Object
show all
Defined in:
lib/rspec_api_documentation/writers/combined_json_writer.rb

Instance Attribute Summary

Attributes inherited from Writer

#configuration, #index

Instance Method Summary collapse

Methods inherited from Writer

clear_docs, #initialize, write

Constructor Details

This class inherits a constructor from RspecApiDocumentation::Writers::Writer

Instance Method Details

#writeObject



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/rspec_api_documentation/writers/combined_json_writer.rb', line 6

def write
  File.open(configuration.docs_dir.join("combined.json"), "w+") do |f|
    examples = []
    index.examples.each do |rspec_example|
      examples << Formatter.to_json(JSONExample.new(rspec_example, configuration))
    end

    f.write "["
    f.write examples.join(",")
    f.write "]"
  end
end