Created
June 25, 2012 12:47
-
-
Save inferno/2988383 to your computer and use it in GitHub Desktop.
Rake task for show defined routes in Sinatra
This file contains 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
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