Skip to content

Instantly share code, notes, and snippets.

@kumatch
Last active August 1, 2019 05:10
Show Gist options
  • Save kumatch/22c2dfbebba4d0b955665e07c03c71b9 to your computer and use it in GitHub Desktop.
Save kumatch/22c2dfbebba4d0b955665e07c03c71b9 to your computer and use it in GitHub Desktop.
list rails controller_path, action from routes.
#!/usr/bin/env ruby
ARGF.each do |line|
case line.chomp
when /^\s+Prefix/, "" then
# header
when /^Routes for /
# fin routes.
break
when /^\s*(?:(\w+) )?(GET|POST|PUT|PATCH|DELETE)\s+(\S+)\s+([\w\/]+)#(\w+)/ then
prefix, verb, url_pattern, controller_path, action = $1, $2, $3, $4, $5
puts "#{controller_path},#{action}"
else
#warn "unparsed: #{line.chomp}"
end
end
bundle exec rake routes | ruby format_routes.rb | sort
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment