Class: ApiTaster::Route
- Inherits:
-
Object
- Object
- ApiTaster::Route
- Defined in:
- lib/api_taster/route.rb
Class Method Summary collapse
- .find(id) ⇒ Object
- .find_by_verb_and_path(verb, path) ⇒ Object
- .grouped_routes ⇒ Object
- .inputs_for(route) ⇒ Object
- .missing_definitions ⇒ Object
- .routes ⇒ Object
Class Method Details
.find(id) ⇒ Object
39 40 41 |
# File 'lib/api_taster/route.rb', line 39 def find(id) routes.select { |r| r[:id] == id.to_i }[0] end |
.find_by_verb_and_path(verb, path) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/api_taster/route.rb', line 43 def find_by_verb_and_path(verb, path) routes.select do |r| r[:path].to_s == path && r[:verb].to_s.downcase == verb.to_s.downcase end[0] end |
.grouped_routes ⇒ Object
35 36 37 |
# File 'lib/api_taster/route.rb', line 35 def grouped_routes routes.group_by { |r| r[:reqs][:controller] } end |
.inputs_for(route) ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/api_taster/route.rb', line 50 def inputs_for(route) unless inputs.has_key?(route[:id]) return { :undefined => route } end inputs[route[:id]].collect { |input| split_input(input, route) } end |
.missing_definitions ⇒ Object
58 59 60 |
# File 'lib/api_taster/route.rb', line 58 def missing_definitions routes.select { |route| undefined_route?(route) } end |
.routes ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/api_taster/route.rb', line 9 def routes _routes = [] i = -1 unless route_set.respond_to?(:routes) raise ApiTaster::Exception.new('Route definitions are missing, have you defined ApiTaster.routes?') end 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)) && rack_app.respond_to?(:routes) rack_app.routes.routes.each do |rack_route| _routes << normalise_route(rack_route, i+=1) end end next if route.verb.source.empty? _routes << normalise_route(route, i+=1) end _routes end |