lib/fitting/documentation.rb in fitting-2.0.3 vs lib/fitting/documentation.rb in fitting-2.1.0
- old
+ new
@@ -8,41 +8,51 @@
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]))
+ black?(response)
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]))
+ white?(response)
end
else
all
end
end
def all
- @all ||= @tomogram.to_hash.inject([]) do |routes, request|
- request['responses'].inject({}) do |responses, response|
- responses[response['status']] ||= 0
- responses[response['status']] += 1
- responses
- end.map do |status, indexes|
+ @all ||= @tomogram.to_hash.each_with_object([]) do |request, routes|
+ responses(request).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
+
+ def responses(request)
+ request['responses'].each_with_object({}) do |response, responses|
+ responses[response['status']] ||= 0
+ responses[response['status']] += 1
+ end
+ end
+
+ def black?(response)
+ data = response.split(' ')
+ data[1] && !@white_list[data[1]] || (@white_list[data[1]] != [] && !@white_list[data[1]].include?(data[0]))
+ end
+
+ def white?(response)
+ data = response.split(' ')
+ data[1] && @white_list[data[1]] && (@white_list[data[1]] == [] || @white_list[data[1]].include?(data[0]))
end
end
end