Sha256: 0e1c0c93209f91e412bf50bf521a59e278009ae271e42b5bf39540a4ea23acc8

Contents?: true

Size: 1.12 KB

Versions: 124

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

require "rails/command"

module Rails
  module Command
    class RoutesCommand < Base # :nodoc:
      class_option :controller, aliases: "-c", desc: "Filter by a specific controller, e.g. PostsController or Admin::PostsController."
      class_option :grep, aliases: "-g", desc: "Grep routes by a specific pattern."
      class_option :expanded, type: :boolean, aliases: "-E", desc: "Print routes expanded vertically with parts explained."

      def perform(*)
        require_application_and_environment!
        require "action_dispatch/routing/inspector"

        say inspector.format(formatter, routes_filter)
      end

      private
        def inspector
          ActionDispatch::Routing::RoutesInspector.new(Rails.application.routes.routes)
        end

        def formatter
          if options.key?("expanded")
            ActionDispatch::Routing::ConsoleFormatter::Expanded.new
          else
            ActionDispatch::Routing::ConsoleFormatter::Sheet.new
          end
        end

        def routes_filter
          options.symbolize_keys.slice(:controller, :grep)
        end
    end
  end
end

Version data entries

124 entries across 117 versions & 11 rubygems

Version Path
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.1.0/gems/railties-7.0.8.6/lib/rails/commands/routes/routes_command.rb
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.3.0/gems/railties-7.0.8.7/lib/rails/commands/routes/routes_command.rb
railties-7.0.8.7 lib/rails/commands/routes/routes_command.rb
railties-7.0.8.6 lib/rails/commands/routes/routes_command.rb
railties-6.1.7.10 lib/rails/commands/routes/routes_command.rb
railties-6.1.7.9 lib/rails/commands/routes/routes_command.rb
railties-7.0.8.5 lib/rails/commands/routes/routes_command.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/railties-7.0.8.4/lib/rails/commands/routes/routes_command.rb
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/railties-7.0.5.1/lib/rails/commands/routes/routes_command.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/railties-7.0.5.1/lib/rails/commands/routes/routes_command.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/railties-7.0.5.1/lib/rails/commands/routes/routes_command.rb
railties-7.0.8.4 lib/rails/commands/routes/routes_command.rb
railties-6.1.7.8 lib/rails/commands/routes/routes_command.rb
railties-7.0.8.1 lib/rails/commands/routes/routes_command.rb
railties-6.1.7.7 lib/rails/commands/routes/routes_command.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/railties-6.1.6.1/lib/rails/commands/routes/routes_command.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/railties-7.0.3.1/lib/rails/commands/routes/routes_command.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/railties-7.0.2.3/lib/rails/commands/routes/routes_command.rb
railties-7.0.8 lib/rails/commands/routes/routes_command.rb
railties-7.0.7.2 lib/rails/commands/routes/routes_command.rb