Class: RspecApiDocumentation::Writers::JsonIodocsWriter

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

Instance Attribute Summary collapse

Attributes inherited from Writer

#configuration, #index

Instance Method Summary collapse

Methods inherited from Writer

clear_docs, write

Constructor Details

#initialize(index, configuration) ⇒ JsonIodocsWriter

Returns a new instance of JsonIodocsWriter.



9
10
11
12
# File 'lib/rspec_api_documentation/writers/json_iodocs_writer.rb', line 9

def initialize(index, configuration)
  super
  self.api_key = configuration.api_name.parameterize
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



6
7
8
# File 'lib/rspec_api_documentation/writers/json_iodocs_writer.rb', line 6

def api_key
  @api_key
end

Instance Method Details

#writeObject



14
15
16
17
18
19
20
21
# File 'lib/rspec_api_documentation/writers/json_iodocs_writer.rb', line 14

def write
  File.open(docs_dir.join("apiconfig.json"), "w+") do |file|
    file.write Formatter.to_json(ApiConfig.new(configuration))
  end
  File.open(docs_dir.join("#{api_key}.json"), "w+") do |file|
    file.write Formatter.to_json(JsonIndex.new(index, configuration))
  end
end