Sha256: b07b2426551e92bb13be1eb7f97f288deb57e198f5ac4ca5b8830ccc5b0d3741
Contents?: true
Size: 1.42 KB
Versions: 3
Compression:
Stored size: 1.42 KB
Contents
require 'xing/specdoc/patterner' require 'xing/specdoc/document' module Xing module SpecDoc class ApiDoccer def self.patterner @patterner ||= Patterner.new(Rails.application.routes) end def initialize(example, request, response, patterner=nil) @example = example @request = request @response = response @patterner = patterner || ApiDoccer.patterner end attr_reader :example, :request, :response, :patterner def output_path @output_path ||= File::join( SpecDoc.response_target_dir, filename ) end def base_filename @base_filename ||= begin pattern = patterner.build(request).sub(%r{^/},"").gsub(%{/:},":").gsub(%r{/},"-") File::join(example.metadata[:doc_path], "#{request.method}+#{response.status}@#{pattern}") end end def filename base_filename + ".json" end def existing_body JSON.parse(File.read(output_path)) end def example_passed? example.exception.nil? end def document @document ||= Document.new(output_path, response.body) end def significant_change? document.different_from?(existing_body) rescue Errno::ENOENT true end def store if example_passed? Xing::SpecDoc.store(self) end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
xing-backend-specdoc-1.0.0.pre.beta | lib/xing/specdoc/api-doccer.rb |
xing-backend-specdoc-0.0.2 | lib/xing/specdoc/api-doccer.rb |
xing-backend-specdoc-0.0.1 | lib/xing/specdoc/api-doccer.rb |