Is there a way to make “rake routes” look better?

前端 未结 9 1326
谎友^
谎友^ 2021-02-04 04:38

I am always forced to make my terminal window two dual monitors wide just to see read them right. I\'m not a stickler for buttery GUI\'s, but this is ridiculous.

Is ther

9条回答
  •  难免孤独
    2021-02-04 05:22

    Rails 3.1 version, Replace all  tag with your application name.
    
    desc 'Pretty print out all defined routes in match order, with names. Target specific controller with CONTROLLER=x.'
    task :pretty_routes => :environment do
      all_routes = ENV['CONTROLLER'] ? ::Application.routes.select { |route| route.defaults[:controller] == ENV['CONTROLLER'] } : ::Application.routes
      routes = all_routes.routes.collect do |route|
        reqs = route.requirements.empty? ? "" : route.requirements.inspect
        {:name => route.name, :verb => route.verb, :path => route.path, :reqs => reqs}
      end
      File.open(File.join(Rails.root, "routes.html"), "w") do |f|
        f.puts "Rails 3 Routes"
        f.puts ""
        routes.each do |r|
          f.puts ""
        end
        f.puts "
    NameVerbPathRequirements
    #{r[:name]}#{r[:verb]}#{r[:path]}#{r[:reqs]}
    " end end

提交回复
热议问题