class RspecApiDocumentation::Writers::JSONExample
Public Class Methods
new(example, configuration)
click to toggle source
# File lib/rspec_api_documentation/writers/json_writer.rb, line 69 def initialize(example, configuration) @example = example @host = configuration.curl_host @filter_headers = configuration.curl_headers_to_filter end
Public Instance Methods
as_json(opts = nil)
click to toggle source
# File lib/rspec_api_documentation/writers/json_writer.rb, line 92 def as_json(opts = nil) { :resource => resource_name, :resource_explanation => resource_explanation, :http_method => http_method, :route => route, :description => description, :explanation => explanation, :parameters => respond_to?(:parameters) ? parameters : [], :response_fields => respond_to?(:response_fields) ? response_fields : [], :requests => requests } end
dirname()
click to toggle source
# File lib/rspec_api_documentation/writers/json_writer.rb, line 83 def dirname resource_name.to_s.downcase.gsub(/\s+/, '_').sub(/^\//,'') end
filename()
click to toggle source
# File lib/rspec_api_documentation/writers/json_writer.rb, line 87 def filename basename = description.downcase.gsub(/\s+/, '_').gsub(Pathname::SEPARATOR_PAT, '') "#{basename}.json" end
method_missing(method, *args, &block)
click to toggle source
# File lib/rspec_api_documentation/writers/json_writer.rb, line 75 def method_missing(method, *args, &block) @example.send(method, *args, &block) end
requests()
click to toggle source
Calls superclass method
# File lib/rspec_api_documentation/writers/json_writer.rb, line 106 def requests super.map do |hash| if @host if hash[:curl].is_a? RspecApiDocumentation::Curl hash[:curl] = hash[:curl].output(@host, @filter_headers) end else hash[:curl] = nil end hash end end
respond_to?(method, include_private = false)
click to toggle source
Calls superclass method
# File lib/rspec_api_documentation/writers/json_writer.rb, line 79 def respond_to?(method, include_private = false) super || @example.respond_to?(method, include_private) end