lib/api_taster/route.rb in api_taster-0.3.0 vs lib/api_taster/route.rb in api_taster-0.4.0

- old
+ new

@@ -1,9 +1,10 @@ module ApiTaster class Route cattr_accessor :route_set cattr_accessor :inputs + cattr_accessor :missing_definitions cattr_accessor :obsolete_definitions class << self def routes _routes = [] @@ -11,11 +12,11 @@ route_set.routes.each do |route| next if route.app.is_a?(Sprockets::Environment) next if route.app == ApiTaster::Engine - if rack_app = discover_rack_app(route.app) + if (rack_app = discover_rack_app(route.app)) && rack_app.respond_to?(:routes) rack_app.routes.routes.each do |rack_route| _routes << normalise_route(rack_route, i+=1) end end @@ -48,10 +49,23 @@ end inputs[route[:id]].collect { |input| split_input(input, route) } end + def calculate_missing_definitions + routes.each do |route| + if undefined_route?(route) + self.missing_definitions << route + end + end + end + private + + def undefined_route?(route) + r = inputs_for(route) + r.is_a?(Hash) && r.has_key?(:undefined) + end def discover_rack_app(app) class_name = app.class.name.to_s if class_name == "ActionDispatch::Routing::Mapper::Constraints" discover_rack_app(app.app)