Sha256: 4896577ef7d71d297c8d51afe41796c4f8ca3819005c356acae691a79214f1ce
Contents?: true
Size: 1.46 KB
Versions: 1
Compression:
Stored size: 1.46 KB
Contents
require 'multi_json' require 'fitting/documentation/request/route' module Fitting module Documentation module Response class Routes def initialize(tomogram, white_list) @tomogram = tomogram @white_list = white_list end def black if @white_list all.select do |response| data = response.split(' ') data[1] && !@white_list[data[1]] || (@white_list[data[1]] != [] && !@white_list[data[1]].include?(data[0])) end else [] end end def white if @white_list all.select do |response| data = response.split(' ') data[1] && @white_list[data[1]] && (@white_list[data[1]] == [] || @white_list[data[1]].include?(data[0])) end else all end end def all @all ||= MultiJson.load(@tomogram).inject([]) do |routes, request| request['responses'].inject({}) do |responses, response| responses[response['status']] ||= 0 responses[response['status']] += 1 responses end.map do |status, indexes| indexes.times do |index| route = "#{request['method']}\t#{request['path']} #{status} #{index}" routes.push(route) end end routes end.uniq end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fitting-1.4.0 | lib/fitting/documentation/response/routes.rb |