Skip to content

Instantly share code, notes, and snippets.

@inferno
Created June 25, 2012 12:47
Show Gist options
  • Save inferno/2988383 to your computer and use it in GitHub Desktop.
Save inferno/2988383 to your computer and use it in GitHub Desktop.
Rake task for show defined routes in Sinatra
desc 'List defined routes'
task 'routes' do
App::routes.each_pair do |method, list|
puts ":: #{method} ::"
routes = []
list.each do |item|
source = item[0].source
item[1].each do |s|
source.sub!(/\(.+?\)/, ':'+s)
end
routes << source[1...-1]
end
puts routes.sort.join("\n")
puts "\n"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment