Skip to content

Instantly share code, notes, and snippets.

@mathie
Created May 14, 2010 15:42
Show Gist options
  • Save mathie/401308 to your computer and use it in GitHub Desktop.
Save mathie/401308 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require "#{RAILS_ROOT}/config/environment"
crud_actions = [ "index", "show", "new", "edit", "create", "update", "destroy" ]
# Force all the controllers in the application to be loaded.
Dir['app/controllers/**/*_controller.rb'].each { |f| load f }
all_controllers = ObjectSpace.each_object.select do |object|
object.class == Class && object.name =~ /Controller$/
end
leaf_controllers = all_controllers - all_controllers.map { |controller| controller.superclass }
controllers = leaf_controllers.sort_by { |a| a.name }
def controller_actions(controller)
controller.public_instance_methods -
(controller.ancestors - [controller]).map { |a| a.public_instance_methods }.flatten
end
puts "# All controller actions"
puts
controllers.each do |controller|
actions = controller_actions(controller)
actions.sort.each do |action|
puts "#{controller.name}##{action}"
end
end
puts
puts "# Non-REST controller actions"
puts
controllers.each do |controller|
actions = controller_actions(controller) - crud_actions
actions.sort.each do |action|
puts "#{controller.name}##{action}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment