Created
October 12, 2014 04:42
-
-
Save pragmaticivan/9a9d925e7bbcc8df72f6 to your computer and use it in GitHub Desktop.
Grape Rake (routes)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :grape do | |
desc "Condensed API Routes" | |
task :routes => :environment do | |
mapped_prefix = '' # where mounted in routes.rb | |
format = "%46s %3s %7s %50s %12s: %s" | |
API.routes.each do |grape_route| | |
info = grape_route.instance_variable_get :@options | |
puts format % [ | |
info[:description] ? info[:description][0..45] : '', | |
info[:version], | |
info[:method], | |
mapped_prefix + info[:path], | |
'# params: ' + info[:params].length.to_s, | |
info[:params].first.inspect | |
] | |
if info[:params].length > 1 | |
info[:params].each_with_index do |param_info, index| | |
next if index == 0 | |
puts format % ['','','','','',param_info.inspect] | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment