diff --git a/lib/rspec_api_documentation.rb b/lib/rspec_api_documentation.rb index 6d6afdc2..d19c74c1 100644 --- a/lib/rspec_api_documentation.rb +++ b/lib/rspec_api_documentation.rb @@ -37,7 +37,7 @@ module Writers autoload :HtmlWriter autoload :TextileWriter autoload :MarkdownWriter - autoload :JsonWriter + autoload :JSONWriter autoload :AppendJsonWriter autoload :JsonIodocsWriter autoload :IndexHelper diff --git a/lib/rspec_api_documentation/api_documentation.rb b/lib/rspec_api_documentation/api_documentation.rb index 2503f594..34ad0320 100644 --- a/lib/rspec_api_documentation/api_documentation.rb +++ b/lib/rspec_api_documentation/api_documentation.rb @@ -1,3 +1,5 @@ +require 'rspec_api_documentation/writers/json_iodocs_writer' + module RspecApiDocumentation class ApiDocumentation attr_reader :configuration, :index diff --git a/lib/rspec_api_documentation/writers/combined_json_writer.rb b/lib/rspec_api_documentation/writers/combined_json_writer.rb index 2e4111c2..fe78bb64 100644 --- a/lib/rspec_api_documentation/writers/combined_json_writer.rb +++ b/lib/rspec_api_documentation/writers/combined_json_writer.rb @@ -7,7 +7,7 @@ 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)) + examples << Formatter.to_json(JSONExample.new(rspec_example, configuration)) end f.write "[" diff --git a/lib/rspec_api_documentation/writers/json_iodocs_writer.rb b/lib/rspec_api_documentation/writers/json_iodocs_writer.rb index fd2f5c1d..b8414045 100644 --- a/lib/rspec_api_documentation/writers/json_iodocs_writer.rb +++ b/lib/rspec_api_documentation/writers/json_iodocs_writer.rb @@ -32,7 +32,7 @@ def sections end def examples - @index.examples.map { |example| JsonExample.new(example, @configuration) } + @index.examples.map { |example| JsonIodocsExample.new(example, @configuration) } end def as_json(opts = nil) @@ -48,7 +48,7 @@ def as_json(opts = nil) end end - class JsonExample + class JsonIodocsExample def initialize(example, configuration) @example = example end diff --git a/lib/rspec_api_documentation/writers/json_writer.rb b/lib/rspec_api_documentation/writers/json_writer.rb index 022240ad..c23437bf 100644 --- a/lib/rspec_api_documentation/writers/json_writer.rb +++ b/lib/rspec_api_documentation/writers/json_writer.rb @@ -2,19 +2,19 @@ module RspecApiDocumentation module Writers - class JsonWriter < Writer + class JSONWriter < Writer delegate :docs_dir, :to => :configuration def write File.open(docs_dir.join("index.json"), "w+") do |f| - f.write Formatter.to_json(JsonIndex.new(index, configuration)) + f.write Formatter.to_json(JSONIndex.new(index, configuration)) end write_examples end def write_examples index.examples.each do |example| - json_example = JsonExample.new(example, configuration) + json_example = JSONExample.new(example, configuration) FileUtils.mkdir_p(docs_dir.join(json_example.dirname)) File.open(docs_dir.join(json_example.dirname, json_example.filename), "w+") do |f| f.write Formatter.to_json(json_example) @@ -23,7 +23,7 @@ def write_examples end end - class JsonIndex + class JSONIndex def initialize(index, configuration) @index = index @configuration = configuration @@ -34,7 +34,7 @@ def sections end def examples - @index.examples.map { |example| JsonExample.new(example, @configuration) } + @index.examples.map { |example| JSONExample.new(example, @configuration) } end def as_json(opts = nil) @@ -61,7 +61,7 @@ def section_hash(section) end end - class JsonExample + class JSONExample def initialize(example, configuration) @example = example @host = configuration.curl_host diff --git a/spec/writers/json_example_spec.rb b/spec/writers/json_example_spec.rb index edcf1f68..0bbeb0c3 100644 --- a/spec/writers/json_example_spec.rb +++ b/spec/writers/json_example_spec.rb @@ -1,7 +1,8 @@ # -*- coding: utf-8 -*- require 'spec_helper' +require 'rspec_api_documentation/writers/json_writer' -describe RspecApiDocumentation::Writers::JsonExample do +describe RspecApiDocumentation::Writers::JSONExample do let(:configuration) { RspecApiDocumentation::Configuration.new } describe "#dirname" do @@ -9,7 +10,7 @@ example = double(resource_name: "/test_string") json_example = - RspecApiDocumentation::Writers::JsonExample.new(example, configuration) + RspecApiDocumentation::Writers::JSONExample.new(example, configuration) expect(json_example.dirname).to eq "test_string" end @@ -18,7 +19,7 @@ example = double(resource_name: "test_string/test") json_example = - RspecApiDocumentation::Writers::JsonExample.new(example, configuration) + RspecApiDocumentation::Writers::JSONExample.new(example, configuration) expect(json_example.dirname).to eq "test_string/test" end diff --git a/spec/writers/json_writer_spec.rb b/spec/writers/json_writer_spec.rb index 4f36d506..9e5e6b8d 100644 --- a/spec/writers/json_writer_spec.rb +++ b/spec/writers/json_writer_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe RspecApiDocumentation::Writers::JsonWriter do +describe RspecApiDocumentation::Writers::JSONWriter do let(:index) { RspecApiDocumentation::Index.new } let(:configuration) { RspecApiDocumentation::Configuration.new }