aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib
diff options
context:
space:
mode:
Diffstat (limited to 'railties/lib')
-rw-r--r--railties/lib/rails/commands/routes/routes_command.rb42
-rw-r--r--railties/lib/rails/commands/server/server_command.rb11
-rw-r--r--railties/lib/rails/generators/rails/app/templates/config/storage.yml.tt1
3 files changed, 20 insertions, 34 deletions
diff --git a/railties/lib/rails/commands/routes/routes_command.rb b/railties/lib/rails/commands/routes/routes_command.rb
index c4f3717095..b592a5212f 100644
--- a/railties/lib/rails/commands/routes/routes_command.rb
+++ b/railties/lib/rails/commands/routes/routes_command.rb
@@ -5,45 +5,33 @@ require "rails/command"
module Rails
module Command
class RoutesCommand < Base # :nodoc:
- class_option :controller, aliases: "-c", type: :string, desc: "Specifies the controller."
- class_option :grep_pattern, aliases: "-g", type: :string, desc: "Specifies grep pattern."
- class_option :expanded_format, aliases: "--expanded", type: :string, desc: "Turn on expanded format mode."
-
- no_commands do
- def help
- say "Usage: Print out all defined routes in match order, with names."
- say ""
- say "Target specific controller with -c option, or grep routes using -g option"
- say "Use expanded format with --expanded option"
- say ""
- end
- end
+ 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"
- all_routes = Rails.application.routes.routes
- inspector = ActionDispatch::Routing::RoutesInspector.new(all_routes)
-
- if options.has_key?("expanded_format")
- say inspector.format(ActionDispatch::Routing::ConsoleFormatter::Expanded.new, routes_filter)
- else
- say inspector.format(ActionDispatch::Routing::ConsoleFormatter::Sheet.new, routes_filter)
- end
+ say inspector.format(formatter, routes_filter)
end
private
+ def inspector
+ ActionDispatch::Routing::RoutesInspector.new(Rails.application.routes.routes)
+ end
- def routes_filter
- if options.has_key?("controller")
- { controller: options["controller"] }
- elsif options.has_key?("grep_pattern")
- options["grep_pattern"]
+ def formatter
+ if options.key?("expanded")
+ ActionDispatch::Routing::ConsoleFormatter::Expanded.new
else
- nil
+ ActionDispatch::Routing::ConsoleFormatter::Sheet.new
end
end
+
+ def routes_filter
+ options.symbolize_keys.slice(:controller, :grep)
+ end
end
end
end
diff --git a/railties/lib/rails/commands/server/server_command.rb b/railties/lib/rails/commands/server/server_command.rb
index 64fb912b51..8588e2fd64 100644
--- a/railties/lib/rails/commands/server/server_command.rb
+++ b/railties/lib/rails/commands/server/server_command.rb
@@ -43,15 +43,15 @@ module Rails
ENV["RAILS_ENV"] ||= options[:environment]
end
- def start
+ def start(after_stop_callback = nil)
trap(:INT) { exit }
create_tmp_directories
setup_dev_caching
log_to_stdout if options[:log_stdout]
- super
+ super()
ensure
- yield
+ after_stop_callback.call if after_stop_callback
end
def serveable? # :nodoc:
@@ -157,9 +157,8 @@ module Rails
if server.serveable?
print_boot_information(server.server, server.served_url)
- server.start do
- say "Exiting" unless options[:daemon]
- end
+ after_stop_callback = -> { say "Exiting" unless options[:daemon] }
+ server.start(after_stop_callback)
else
say rack_server_suggestion(using)
end
diff --git a/railties/lib/rails/generators/rails/app/templates/config/storage.yml.tt b/railties/lib/rails/generators/rails/app/templates/config/storage.yml.tt
index 1c0cde0b09..7207c75086 100644
--- a/railties/lib/rails/generators/rails/app/templates/config/storage.yml.tt
+++ b/railties/lib/rails/generators/rails/app/templates/config/storage.yml.tt
@@ -24,7 +24,6 @@ local:
# Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
# microsoft:
# service: AzureStorage
-# path: your_azure_storage_path
# storage_account_name: your_account_name
# storage_access_key: <%%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %>
# container: your_container_name