railties 5.2.7.1 → 6.1.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +276 -158
- data/MIT-LICENSE +1 -1
- data/RDOC_MAIN.rdoc +39 -33
- data/README.rdoc +3 -3
- data/lib/minitest/rails_plugin.rb +23 -12
- data/lib/rails/all.rb +4 -0
- data/lib/rails/api/generator.rb +2 -1
- data/lib/rails/api/task.rb +18 -1
- data/lib/rails/app_loader.rb +2 -2
- data/lib/rails/app_updater.rb +3 -1
- data/lib/rails/application/bootstrap.rb +9 -17
- data/lib/rails/application/configuration.rb +184 -26
- data/lib/rails/application/default_middleware_stack.rb +7 -3
- data/lib/rails/application/dummy_erb_compiler.rb +18 -0
- data/lib/rails/application/finisher.rb +68 -1
- data/lib/rails/application/routes_reloader.rb +9 -3
- data/lib/rails/application.rb +86 -65
- data/lib/rails/application_controller.rb +0 -1
- data/lib/rails/autoloaders.rb +48 -0
- data/lib/rails/backtrace_cleaner.rb +14 -21
- data/lib/rails/code_statistics.rb +8 -6
- data/lib/rails/code_statistics_calculator.rb +6 -6
- data/lib/rails/command/base.rb +13 -5
- data/lib/rails/command/behavior.rb +8 -49
- data/lib/rails/command/environment_argument.rb +9 -16
- data/lib/rails/command/spellchecker.rb +57 -0
- data/lib/rails/command.rb +16 -11
- data/lib/rails/commands/console/console_command.rb +6 -0
- data/lib/rails/commands/credentials/USAGE +33 -0
- data/lib/rails/commands/credentials/credentials_command/diffing.rb +41 -0
- data/lib/rails/commands/credentials/credentials_command.rb +76 -19
- data/lib/rails/commands/db/system/change/change_command.rb +25 -0
- data/lib/rails/commands/dbconsole/dbconsole_command.rb +66 -51
- data/lib/rails/commands/dev/dev_command.rb +19 -0
- data/lib/rails/commands/encrypted/USAGE +1 -1
- data/lib/rails/commands/encrypted/encrypted_command.rb +4 -4
- data/lib/rails/commands/generate/generate_command.rb +1 -1
- data/lib/rails/commands/help/help_command.rb +1 -1
- data/lib/rails/commands/initializers/initializers_command.rb +23 -0
- data/lib/rails/commands/new/new_command.rb +2 -2
- data/lib/rails/commands/notes/notes_command.rb +29 -0
- data/lib/rails/commands/plugin/plugin_command.rb +1 -1
- data/lib/rails/commands/rake/rake_command.rb +9 -8
- data/lib/rails/commands/routes/routes_command.rb +37 -0
- data/lib/rails/commands/runner/runner_command.rb +13 -9
- data/lib/rails/commands/secrets/USAGE +6 -0
- data/lib/rails/commands/secrets/secrets_command.rb +3 -3
- data/lib/rails/commands/server/server_command.rb +92 -56
- data/lib/rails/commands/test/test_command.rb +2 -2
- data/lib/rails/configuration.rb +48 -19
- data/lib/rails/engine/configuration.rb +6 -2
- data/lib/rails/engine/updater.rb +1 -1
- data/lib/rails/engine.rb +59 -49
- data/lib/rails/gem_version.rb +4 -4
- data/lib/rails/generators/actions/create_migration.rb +7 -1
- data/lib/rails/generators/actions.rb +89 -56
- data/lib/rails/generators/app_base.rb +90 -106
- data/lib/rails/generators/app_name.rb +50 -0
- data/lib/rails/generators/base.rb +15 -12
- data/lib/rails/generators/database.rb +57 -0
- data/lib/rails/generators/erb/mailer/mailer_generator.rb +1 -2
- data/lib/rails/generators/erb/scaffold/scaffold_generator.rb +0 -1
- data/lib/rails/generators/erb/scaffold/templates/_form.html.erb.tt +7 -4
- data/lib/rails/generators/erb/scaffold/templates/index.html.erb.tt +1 -1
- data/lib/rails/generators/erb/scaffold/templates/show.html.erb.tt +9 -1
- data/lib/rails/generators/erb.rb +0 -1
- data/lib/rails/generators/generated_attribute.rb +50 -31
- data/lib/rails/generators/migration.rb +3 -3
- data/lib/rails/generators/model_helpers.rb +33 -2
- data/lib/rails/generators/named_base.rb +3 -7
- data/lib/rails/generators/rails/app/USAGE +2 -1
- data/lib/rails/generators/rails/app/app_generator.rb +120 -84
- data/lib/rails/generators/rails/app/templates/Gemfile.tt +17 -20
- data/lib/rails/generators/rails/app/templates/Rakefile.tt +1 -1
- data/lib/rails/generators/rails/app/templates/app/assets/config/manifest.js.tt +0 -3
- data/lib/rails/generators/rails/app/templates/app/javascript/channels/consumer.js +6 -0
- data/lib/rails/generators/rails/app/templates/app/javascript/channels/index.js +5 -0
- data/lib/rails/generators/rails/app/templates/app/javascript/packs/application.js.tt +23 -0
- data/lib/rails/generators/rails/app/templates/app/jobs/application_job.rb.tt +5 -0
- data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +6 -5
- data/lib/rails/generators/rails/app/templates/bin/rails.tt +5 -2
- data/lib/rails/generators/rails/app/templates/bin/rake.tt +5 -2
- data/lib/rails/generators/rails/app/templates/bin/setup.tt +9 -9
- data/lib/rails/generators/rails/app/templates/bin/spring.tt +13 -0
- data/lib/rails/generators/rails/app/templates/bin/yarn.tt +9 -3
- data/lib/rails/generators/rails/app/templates/config/application.rb.tt +16 -7
- data/lib/rails/generators/rails/app/templates/config/boot.rb.tt +2 -2
- data/lib/rails/generators/rails/app/templates/config/cable.yml.tt +1 -1
- data/lib/rails/generators/rails/app/templates/config/databases/jdbc.yml.tt +4 -5
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcmysql.yml.tt +12 -11
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml.tt +13 -12
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcsqlite3.yml.tt +1 -1
- data/lib/rails/generators/rails/app/templates/config/databases/mysql.yml.tt +13 -12
- data/lib/rails/generators/rails/app/templates/config/databases/oracle.yml.tt +12 -11
- data/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml.tt +16 -15
- data/lib/rails/generators/rails/app/templates/config/databases/sqlite3.yml.tt +1 -1
- data/lib/rails/generators/rails/app/templates/config/databases/sqlserver.yml.tt +11 -10
- data/lib/rails/generators/rails/app/templates/config/environment.rb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +22 -5
- data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +43 -17
- data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +26 -7
- data/lib/rails/generators/rails/app/templates/config/initializers/assets.rb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/config/initializers/backtrace_silencers.rb.tt +4 -3
- data/lib/rails/generators/rails/app/templates/config/initializers/content_security_policy.rb.tt +7 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/filter_parameter_logging.rb.tt +3 -1
- data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_6_1.rb.tt +67 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/permissions_policy.rb.tt +11 -0
- data/lib/rails/generators/rails/app/templates/config/locales/en.yml +1 -1
- data/lib/rails/generators/rails/app/templates/config/puma.rb.tt +10 -4
- data/lib/rails/generators/rails/app/templates/config/routes.rb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/config/spring.rb.tt +6 -6
- data/lib/rails/generators/rails/app/templates/config.ru.tt +2 -1
- data/lib/rails/generators/rails/app/templates/db/seeds.rb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/gitattributes.tt +14 -0
- data/lib/rails/generators/rails/app/templates/gitignore.tt +8 -8
- data/lib/rails/generators/rails/app/templates/package.json.tt +8 -2
- data/lib/rails/generators/rails/app/templates/public/robots.txt +1 -1
- data/lib/rails/generators/rails/app/templates/ruby-version.tt +1 -1
- data/lib/rails/generators/rails/app/templates/test/channels/application_cable/connection_test.rb.tt +11 -0
- data/lib/rails/generators/rails/app/templates/test/test_helper.rb.tt +9 -2
- data/lib/rails/generators/rails/assets/USAGE +3 -7
- data/lib/rails/generators/rails/assets/assets_generator.rb +0 -1
- data/lib/rails/generators/rails/benchmark/USAGE +19 -0
- data/lib/rails/generators/rails/benchmark/benchmark_generator.rb +29 -0
- data/lib/rails/generators/rails/benchmark/templates/benchmark.rb.tt +15 -0
- data/lib/rails/generators/rails/controller/USAGE +2 -2
- data/lib/rails/generators/rails/controller/controller_generator.rb +10 -39
- data/lib/rails/generators/rails/credentials/credentials_generator.rb +6 -7
- data/lib/rails/generators/rails/db/system/change/change_generator.rb +65 -0
- data/lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb +10 -7
- data/lib/rails/generators/rails/generator/USAGE +2 -2
- data/lib/rails/generators/rails/generator/generator_generator.rb +0 -1
- data/lib/rails/generators/rails/generator/templates/USAGE.tt +1 -1
- data/lib/rails/generators/rails/helper/USAGE +2 -3
- data/lib/rails/generators/rails/helper/helper_generator.rb +5 -0
- data/lib/rails/generators/rails/integration_test/USAGE +2 -2
- data/lib/rails/generators/rails/migration/USAGE +4 -4
- data/lib/rails/generators/rails/model/USAGE +15 -16
- data/lib/rails/generators/rails/plugin/plugin_generator.rb +33 -56
- data/lib/rails/generators/rails/plugin/templates/%name%.gemspec.tt +10 -19
- data/lib/rails/generators/rails/plugin/templates/Gemfile.tt +3 -10
- data/lib/rails/generators/rails/plugin/templates/Rakefile.tt +4 -18
- data/lib/rails/generators/rails/plugin/templates/app/controllers/%namespaced_name%/application_controller.rb.tt +1 -2
- data/lib/rails/generators/rails/plugin/templates/app/helpers/%namespaced_name%/application_helper.rb.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/app/jobs/%namespaced_name%/application_job.rb.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/app/mailers/%namespaced_name%/application_mailer.rb.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/app/models/%namespaced_name%/application_record.rb.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/bin/rails.tt +3 -3
- data/lib/rails/generators/rails/plugin/templates/gitignore.tt +14 -11
- data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/engine.rb.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/railtie.rb.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%.rb.tt +1 -0
- data/lib/rails/generators/rails/plugin/templates/rails/boot.rb.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/test/%namespaced_name%_test.rb.tt +4 -4
- data/lib/rails/generators/rails/plugin/templates/test/integration/navigation_test.rb.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/test/test_helper.rb.tt +0 -4
- data/lib/rails/generators/rails/resource/USAGE +4 -4
- data/lib/rails/generators/rails/resource_route/resource_route_generator.rb +2 -27
- data/lib/rails/generators/rails/scaffold/USAGE +5 -5
- data/lib/rails/generators/rails/scaffold_controller/USAGE +2 -2
- data/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb +19 -0
- data/lib/rails/generators/rails/scaffold_controller/templates/api_controller.rb.tt +2 -2
- data/lib/rails/generators/rails/scaffold_controller/templates/controller.rb.tt +2 -2
- data/lib/rails/generators/rails/system_test/USAGE +2 -2
- data/lib/rails/generators/rails/task/USAGE +3 -3
- data/lib/rails/generators/resource_helpers.rb +1 -6
- data/lib/rails/generators/test_case.rb +1 -1
- data/lib/rails/generators/test_unit/controller/controller_generator.rb +2 -0
- data/lib/rails/generators/test_unit/controller/templates/functional_test.rb.tt +3 -3
- data/lib/rails/generators/test_unit/generator/generator_generator.rb +0 -1
- data/lib/rails/generators/test_unit/generator/templates/generator_test.rb.tt +2 -2
- data/lib/rails/generators/test_unit/integration/integration_generator.rb +5 -0
- data/lib/rails/generators/test_unit/integration/templates/integration_test.rb.tt +1 -1
- data/lib/rails/generators/test_unit/job/job_generator.rb +5 -0
- data/lib/rails/generators/test_unit/job/templates/unit_test.rb.tt +1 -1
- data/lib/rails/generators/test_unit/mailer/mailer_generator.rb +1 -1
- data/lib/rails/generators/test_unit/mailer/templates/functional_test.rb.tt +1 -1
- data/lib/rails/generators/test_unit/model/templates/fixtures.yml.tt +3 -3
- data/lib/rails/generators/test_unit/model/templates/unit_test.rb.tt +1 -1
- data/lib/rails/generators/test_unit/plugin/templates/%file_name%_test.rb.tt +1 -1
- data/lib/rails/generators/test_unit/plugin/templates/test_helper.rb +2 -2
- data/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb +8 -4
- data/lib/rails/generators/test_unit/scaffold/templates/api_functional_test.rb.tt +1 -1
- data/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb.tt +1 -1
- data/lib/rails/generators/test_unit/system/system_generator.rb +5 -0
- data/lib/rails/generators/testing/assertions.rb +2 -2
- data/lib/rails/generators/testing/behaviour.rb +4 -2
- data/lib/rails/generators.rb +38 -24
- data/lib/rails/info.rb +4 -4
- data/lib/rails/info_controller.rb +2 -3
- data/lib/rails/mailers_controller.rb +8 -4
- data/lib/rails/paths.rb +26 -10
- data/lib/rails/rack/logger.rb +1 -2
- data/lib/rails/railtie/configurable.rb +0 -1
- data/lib/rails/railtie/configuration.rb +3 -3
- data/lib/rails/railtie.rb +33 -13
- data/lib/rails/ruby_version_check.rb +3 -3
- data/lib/rails/secrets.rb +0 -1
- data/lib/rails/source_annotation_extractor.rb +124 -117
- data/lib/rails/tasks/engine.rake +1 -4
- data/lib/rails/tasks/framework.rake +12 -2
- data/lib/rails/tasks/log.rake +0 -1
- data/lib/rails/tasks/misc.rake +1 -1
- data/lib/rails/tasks/statistics.rake +5 -1
- data/lib/rails/tasks/yarn.rake +14 -2
- data/lib/rails/tasks/zeitwerk.rake +69 -0
- data/lib/rails/tasks.rb +1 -4
- data/lib/rails/templates/rails/mailers/email.html.erb +1 -0
- data/lib/rails/templates/rails/welcome/index.html.erb +3 -3
- data/lib/rails/test_help.rb +11 -9
- data/lib/rails/test_unit/reporter.rb +3 -2
- data/lib/rails/test_unit/runner.rb +25 -8
- data/lib/rails/test_unit/testing.rake +7 -1
- data/lib/rails.rb +10 -8
- metadata +46 -40
- data/lib/rails/generators/js/assets/assets_generator.rb +0 -15
- data/lib/rails/generators/js/assets/templates/javascript.js +0 -2
- data/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt +0 -22
- data/lib/rails/generators/rails/app/templates/app/assets/javascripts/cable.js.tt +0 -13
- data/lib/rails/generators/rails/app/templates/bin/bundle.tt +0 -2
- data/lib/rails/generators/rails/app/templates/bin/update.tt +0 -34
- data/lib/rails/generators/rails/app/templates/config/databases/frontbase.yml.tt +0 -50
- data/lib/rails/generators/rails/app/templates/config/databases/ibm_db.yml.tt +0 -86
- data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_5_2.rb.tt +0 -38
- data/lib/rails/generators/rails/assets/templates/javascript.js +0 -2
- data/lib/rails/generators/rails/plugin/templates/rails/application.rb.tt +0 -23
- data/lib/rails/tasks/annotations.rake +0 -22
- data/lib/rails/tasks/dev.rake +0 -10
- data/lib/rails/tasks/initializers.rake +0 -8
- data/lib/rails/tasks/routes.rake +0 -31
data/lib/rails/application.rb
CHANGED
@@ -6,7 +6,8 @@ require "active_support/core_ext/object/blank"
|
|
6
6
|
require "active_support/key_generator"
|
7
7
|
require "active_support/message_verifier"
|
8
8
|
require "active_support/encrypted_configuration"
|
9
|
-
require "active_support/
|
9
|
+
require "active_support/hash_with_indifferent_access"
|
10
|
+
require "active_support/configuration_file"
|
10
11
|
require "rails/engine"
|
11
12
|
require "rails/secrets"
|
12
13
|
|
@@ -44,7 +45,7 @@ module Rails
|
|
44
45
|
# process. From the moment you require "config/application.rb" in your app,
|
45
46
|
# the booting process goes like this:
|
46
47
|
#
|
47
|
-
# 1) require "config/boot.rb" to
|
48
|
+
# 1) require "config/boot.rb" to set up load paths
|
48
49
|
# 2) require railties and engines
|
49
50
|
# 3) Define Rails.application as "class MyApp::Application < Rails::Application"
|
50
51
|
# 4) Run config.before_configuration callbacks
|
@@ -172,14 +173,9 @@ module Rails
|
|
172
173
|
def key_generator
|
173
174
|
# number of iterations selected based on consultation with the google security
|
174
175
|
# team. Details at https://github.com/rails/rails/pull/6952#issuecomment-7661220
|
175
|
-
@caching_key_generator ||=
|
176
|
-
|
177
|
-
|
178
|
-
ActiveSupport::KeyGenerator.new(secret_key_base, iterations: 1000)
|
179
|
-
)
|
180
|
-
else
|
181
|
-
ActiveSupport::LegacyKeyGenerator.new(secrets.secret_token)
|
182
|
-
end
|
176
|
+
@caching_key_generator ||= ActiveSupport::CachingKeyGenerator.new(
|
177
|
+
ActiveSupport::KeyGenerator.new(secret_key_base, iterations: 1000)
|
178
|
+
)
|
183
179
|
end
|
184
180
|
|
185
181
|
# Returns a message verifier object.
|
@@ -209,12 +205,13 @@ module Rails
|
|
209
205
|
|
210
206
|
# Convenience for loading config/foo.yml for the current Rails env.
|
211
207
|
#
|
212
|
-
#
|
208
|
+
# Examples:
|
213
209
|
#
|
214
210
|
# # config/exception_notification.yml:
|
215
211
|
# production:
|
216
212
|
# url: http://127.0.0.1:8080
|
217
213
|
# namespace: my_app_production
|
214
|
+
#
|
218
215
|
# development:
|
219
216
|
# url: http://localhost:3001
|
220
217
|
# namespace: my_app_development
|
@@ -223,23 +220,47 @@ module Rails
|
|
223
220
|
# Rails.application.configure do
|
224
221
|
# config.middleware.use ExceptionNotifier, config_for(:exception_notification)
|
225
222
|
# end
|
223
|
+
#
|
224
|
+
# # You can also store configurations in a shared section which will be
|
225
|
+
# # merged with the environment configuration
|
226
|
+
#
|
227
|
+
# # config/example.yml
|
228
|
+
# shared:
|
229
|
+
# foo:
|
230
|
+
# bar:
|
231
|
+
# baz: 1
|
232
|
+
#
|
233
|
+
# development:
|
234
|
+
# foo:
|
235
|
+
# bar:
|
236
|
+
# qux: 2
|
237
|
+
#
|
238
|
+
# # development environment
|
239
|
+
# Rails.application.config_for(:example)[:foo][:bar]
|
240
|
+
# # => { baz: 1, qux: 2 }
|
226
241
|
def config_for(name, env: Rails.env)
|
227
|
-
|
228
|
-
yaml = name
|
229
|
-
else
|
230
|
-
yaml = Pathname.new("#{paths["config"].existent.first}/#{name}.yml")
|
231
|
-
end
|
242
|
+
yaml = name.is_a?(Pathname) ? name : Pathname.new("#{paths["config"].existent.first}/#{name}.yml")
|
232
243
|
|
233
244
|
if yaml.exist?
|
234
245
|
require "erb"
|
235
|
-
|
246
|
+
all_configs = ActiveSupport::ConfigurationFile.parse(yaml).deep_symbolize_keys
|
247
|
+
config, shared = all_configs[env.to_sym], all_configs[:shared]
|
248
|
+
|
249
|
+
if shared
|
250
|
+
config = {} if config.nil?
|
251
|
+
if config.is_a?(Hash)
|
252
|
+
config = shared.deep_merge(config)
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
if config.is_a?(Hash)
|
257
|
+
config = ActiveSupport::OrderedOptions.new.update(config)
|
258
|
+
end
|
259
|
+
|
260
|
+
config
|
236
261
|
else
|
237
262
|
raise "Could not load configuration. No such file - #{yaml}"
|
238
263
|
end
|
239
|
-
rescue Psych::SyntaxError => e
|
240
|
-
raise "YAML syntax error occurred while parsing #{yaml}. " \
|
241
|
-
"Please note that YAML must be consistently indented using spaces. Tabs are not allowed. " \
|
242
|
-
"Error: #{e.message}"
|
243
264
|
end
|
244
265
|
|
245
266
|
# Stores some of the Rails initial environment parameters which
|
@@ -249,7 +270,6 @@ module Rails
|
|
249
270
|
super.merge(
|
250
271
|
"action_dispatch.parameter_filter" => config.filter_parameters,
|
251
272
|
"action_dispatch.redirect_filter" => config.filter_redirect,
|
252
|
-
"action_dispatch.secret_token" => secrets.secret_token,
|
253
273
|
"action_dispatch.secret_key_base" => secret_key_base,
|
254
274
|
"action_dispatch.show_exceptions" => config.action_dispatch.show_exceptions,
|
255
275
|
"action_dispatch.show_detailed_exceptions" => config.consider_all_requests_local,
|
@@ -267,9 +287,13 @@ module Rails
|
|
267
287
|
"action_dispatch.cookies_serializer" => config.action_dispatch.cookies_serializer,
|
268
288
|
"action_dispatch.cookies_digest" => config.action_dispatch.cookies_digest,
|
269
289
|
"action_dispatch.cookies_rotations" => config.action_dispatch.cookies_rotations,
|
290
|
+
"action_dispatch.cookies_same_site_protection" => coerce_same_site_protection(config.action_dispatch.cookies_same_site_protection),
|
291
|
+
"action_dispatch.use_cookies_with_metadata" => config.action_dispatch.use_cookies_with_metadata,
|
270
292
|
"action_dispatch.content_security_policy" => config.content_security_policy,
|
271
293
|
"action_dispatch.content_security_policy_report_only" => config.content_security_policy_report_only,
|
272
|
-
"action_dispatch.content_security_policy_nonce_generator" => config.content_security_policy_nonce_generator
|
294
|
+
"action_dispatch.content_security_policy_nonce_generator" => config.content_security_policy_nonce_generator,
|
295
|
+
"action_dispatch.content_security_policy_nonce_directives" => config.content_security_policy_nonce_directives,
|
296
|
+
"action_dispatch.permissions_policy" => config.permissions_policy,
|
273
297
|
)
|
274
298
|
end
|
275
299
|
end
|
@@ -305,6 +329,12 @@ module Rails
|
|
305
329
|
self.class.generators(&blk)
|
306
330
|
end
|
307
331
|
|
332
|
+
# Sends any server called in the instance of a new application up
|
333
|
+
# to the +server+ method defined in Rails::Railtie.
|
334
|
+
def server(&blk)
|
335
|
+
self.class.server(&blk)
|
336
|
+
end
|
337
|
+
|
308
338
|
# Sends the +isolate_namespace+ method up to the class method.
|
309
339
|
def isolate_namespace(mod)
|
310
340
|
self.class.isolate_namespace(mod)
|
@@ -348,7 +378,7 @@ module Rails
|
|
348
378
|
files, dirs = config.watchable_files.dup, config.watchable_dirs.dup
|
349
379
|
|
350
380
|
ActiveSupport::Dependencies.autoload_paths.each do |path|
|
351
|
-
dirs[path.to_s] = [:rb]
|
381
|
+
File.file?(path) ? files << path.to_s : dirs[path.to_s] = [:rb]
|
352
382
|
end
|
353
383
|
|
354
384
|
[files, dirs]
|
@@ -373,24 +403,8 @@ module Rails
|
|
373
403
|
@config ||= Application::Configuration.new(self.class.find_root(self.class.called_from))
|
374
404
|
end
|
375
405
|
|
376
|
-
|
377
|
-
@config = configuration
|
378
|
-
end
|
406
|
+
attr_writer :config
|
379
407
|
|
380
|
-
# Returns secrets added to config/secrets.yml.
|
381
|
-
#
|
382
|
-
# Example:
|
383
|
-
#
|
384
|
-
# development:
|
385
|
-
# secret_key_base: 836fa3665997a860728bcb9e9a1e704d427cfc920e79d847d79c8a9a907b9e965defa4154b2b86bdec6930adbe33f21364523a6f6ce363865724549fdfc08553
|
386
|
-
# test:
|
387
|
-
# secret_key_base: 5a37811464e7d378488b0f073e2193b093682e4e21f5d6f3ae0a4e1781e61a351fdc878a843424e81c73fb484a40d23f92c8dafac4870e74ede6e5e174423010
|
388
|
-
# production:
|
389
|
-
# secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
|
390
|
-
# namespace: my_app_production
|
391
|
-
#
|
392
|
-
# +Rails.application.secrets.namespace+ returns +my_app_production+ in the
|
393
|
-
# production environment.
|
394
408
|
def secrets
|
395
409
|
@secrets ||= begin
|
396
410
|
secrets = ActiveSupport::OrderedOptions.new
|
@@ -400,27 +414,18 @@ module Rails
|
|
400
414
|
|
401
415
|
# Fallback to config.secret_key_base if secrets.secret_key_base isn't set
|
402
416
|
secrets.secret_key_base ||= config.secret_key_base
|
403
|
-
# Fallback to config.secret_token if secrets.secret_token isn't set
|
404
|
-
secrets.secret_token ||= config.secret_token
|
405
|
-
|
406
|
-
if secrets.secret_token.present?
|
407
|
-
ActiveSupport::Deprecation.warn(
|
408
|
-
"`secrets.secret_token` is deprecated in favor of `secret_key_base` and will be removed in Rails 6.0."
|
409
|
-
)
|
410
|
-
end
|
411
417
|
|
412
418
|
secrets
|
413
419
|
end
|
414
420
|
end
|
415
421
|
|
416
|
-
|
417
|
-
@secrets = secrets
|
418
|
-
end
|
422
|
+
attr_writer :secrets, :credentials
|
419
423
|
|
420
424
|
# The secret_key_base is used as the input secret to the application's key generator, which in turn
|
421
425
|
# is used to create all MessageVerifiers/MessageEncryptors, including the ones that sign and encrypt cookies.
|
422
426
|
#
|
423
|
-
# In
|
427
|
+
# In development and test, this is randomly generated and stored in a
|
428
|
+
# temporary file in <tt>tmp/development_secret.txt</tt>.
|
424
429
|
#
|
425
430
|
# In all other environments, we look for it first in ENV["SECRET_KEY_BASE"],
|
426
431
|
# then credentials.secret_key_base, and finally secrets.secret_key_base. For most applications,
|
@@ -438,13 +443,17 @@ module Rails
|
|
438
443
|
# Decrypts the credentials hash as kept in +config/credentials.yml.enc+. This file is encrypted with
|
439
444
|
# the Rails master key, which is either taken from <tt>ENV["RAILS_MASTER_KEY"]</tt> or from loading
|
440
445
|
# +config/master.key+.
|
446
|
+
# If specific credentials file exists for current environment, it takes precedence, thus for +production+
|
447
|
+
# environment look first for +config/credentials/production.yml.enc+ with master key taken
|
448
|
+
# from <tt>ENV["RAILS_MASTER_KEY"]</tt> or from loading +config/credentials/production.key+.
|
449
|
+
# Default behavior can be overwritten by setting +config.credentials.content_path+ and +config.credentials.key_path+.
|
441
450
|
def credentials
|
442
|
-
@credentials ||= encrypted(
|
451
|
+
@credentials ||= encrypted(config.credentials.content_path, key_path: config.credentials.key_path)
|
443
452
|
end
|
444
453
|
|
445
454
|
# Shorthand to decrypt any encrypted configurations or files.
|
446
455
|
#
|
447
|
-
# For any file added with <tt>
|
456
|
+
# For any file added with <tt>rails encrypted:edit</tt> call +read+ to decrypt
|
448
457
|
# the file with the master key.
|
449
458
|
# The master key is either stored in +config/master.key+ or <tt>ENV["RAILS_MASTER_KEY"]</tt>.
|
450
459
|
#
|
@@ -486,10 +495,6 @@ module Rails
|
|
486
495
|
config.helpers_paths
|
487
496
|
end
|
488
497
|
|
489
|
-
console do
|
490
|
-
require "pp"
|
491
|
-
end
|
492
|
-
|
493
498
|
console do
|
494
499
|
unless ::Kernel.private_method_defined?(:y)
|
495
500
|
require "psych/y"
|
@@ -506,16 +511,24 @@ module Rails
|
|
506
511
|
ordered_railties.flatten - [self]
|
507
512
|
end
|
508
513
|
|
509
|
-
|
514
|
+
# Eager loads the application code.
|
515
|
+
def eager_load!
|
516
|
+
if Rails.autoloaders.zeitwerk_enabled?
|
517
|
+
Rails.autoloaders.each(&:eager_load)
|
518
|
+
else
|
519
|
+
super
|
520
|
+
end
|
521
|
+
end
|
510
522
|
|
523
|
+
protected
|
511
524
|
alias :build_middleware_stack :app
|
512
525
|
|
513
526
|
def run_tasks_blocks(app) #:nodoc:
|
514
527
|
railties.each { |r| r.run_tasks_blocks(app) }
|
515
528
|
super
|
516
|
-
|
529
|
+
load "rails/tasks.rb"
|
517
530
|
task :environment do
|
518
|
-
ActiveSupport.on_load(:before_initialize) { config.eager_load =
|
531
|
+
ActiveSupport.on_load(:before_initialize) { config.eager_load = config.rake_eager_load }
|
519
532
|
|
520
533
|
require_environment!
|
521
534
|
end
|
@@ -536,6 +549,11 @@ module Rails
|
|
536
549
|
super
|
537
550
|
end
|
538
551
|
|
552
|
+
def run_server_blocks(app) #:nodoc:
|
553
|
+
railties.each { |r| r.run_server_blocks(app) }
|
554
|
+
super
|
555
|
+
end
|
556
|
+
|
539
557
|
# Returns the ordered railties for this application considering railties_order.
|
540
558
|
def ordered_railties #:nodoc:
|
541
559
|
@ordered_railties ||= begin
|
@@ -581,13 +599,12 @@ module Rails
|
|
581
599
|
secret_key_base
|
582
600
|
elsif secret_key_base
|
583
601
|
raise ArgumentError, "`secret_key_base` for #{Rails.env} environment must be a type of String`"
|
584
|
-
|
585
|
-
raise ArgumentError, "Missing `secret_key_base` for '#{Rails.env}' environment, set this string with `rails credentials:edit`"
|
602
|
+
else
|
603
|
+
raise ArgumentError, "Missing `secret_key_base` for '#{Rails.env}' environment, set this string with `bin/rails credentials:edit`"
|
586
604
|
end
|
587
605
|
end
|
588
606
|
|
589
607
|
private
|
590
|
-
|
591
608
|
def generate_development_secret
|
592
609
|
if secrets.secret_key_base.nil?
|
593
610
|
key_file = Rails.root.join("tmp/development_secret.txt")
|
@@ -614,5 +631,9 @@ module Rails
|
|
614
631
|
def build_middleware
|
615
632
|
config.app_middleware + super
|
616
633
|
end
|
634
|
+
|
635
|
+
def coerce_same_site_protection(protection)
|
636
|
+
protection.respond_to?(:call) ? protection : proc { protection }
|
637
|
+
end
|
617
638
|
end
|
618
639
|
end
|
@@ -12,7 +12,6 @@ class Rails::ApplicationController < ActionController::Base # :nodoc:
|
|
12
12
|
end
|
13
13
|
|
14
14
|
private
|
15
|
-
|
16
15
|
def require_local!
|
17
16
|
unless local_request?
|
18
17
|
render html: "<p>For security purposes, this information is only available to local requests.</p>".html_safe, status: :forbidden
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/dependencies/zeitwerk_integration"
|
4
|
+
|
5
|
+
module Rails
|
6
|
+
module Autoloaders # :nodoc:
|
7
|
+
class << self
|
8
|
+
include Enumerable
|
9
|
+
|
10
|
+
def main
|
11
|
+
if zeitwerk_enabled?
|
12
|
+
@main ||= Zeitwerk::Loader.new.tap do |loader|
|
13
|
+
loader.tag = "rails.main"
|
14
|
+
loader.inflector = ActiveSupport::Dependencies::ZeitwerkIntegration::Inflector
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def once
|
20
|
+
if zeitwerk_enabled?
|
21
|
+
@once ||= Zeitwerk::Loader.new.tap do |loader|
|
22
|
+
loader.tag = "rails.once"
|
23
|
+
loader.inflector = ActiveSupport::Dependencies::ZeitwerkIntegration::Inflector
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def each
|
29
|
+
if zeitwerk_enabled?
|
30
|
+
yield main
|
31
|
+
yield once
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def logger=(logger)
|
36
|
+
each { |loader| loader.logger = logger }
|
37
|
+
end
|
38
|
+
|
39
|
+
def log!
|
40
|
+
each(&:log!)
|
41
|
+
end
|
42
|
+
|
43
|
+
def zeitwerk_enabled?
|
44
|
+
Rails.configuration.autoloader == :zeitwerk
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -1,34 +1,27 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "active_support/backtrace_cleaner"
|
4
|
+
require "active_support/core_ext/string/access"
|
4
5
|
|
5
6
|
module Rails
|
6
7
|
class BacktraceCleaner < ActiveSupport::BacktraceCleaner
|
7
|
-
APP_DIRS_PATTERN =
|
8
|
-
RENDER_TEMPLATE_PATTERN = /:in
|
9
|
-
EMPTY_STRING = "".freeze
|
10
|
-
SLASH = "/".freeze
|
11
|
-
DOT_SLASH = "./".freeze
|
8
|
+
APP_DIRS_PATTERN = /\A(?:\.\/)?(?:app|config|lib|test|\(\w*\))/
|
9
|
+
RENDER_TEMPLATE_PATTERN = /:in `.*_\w+_{2,3}\d+_\d+'/
|
12
10
|
|
13
11
|
def initialize
|
14
12
|
super
|
15
|
-
@root = "#{Rails.root}/"
|
16
|
-
add_filter
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
13
|
+
@root = "#{Rails.root}/"
|
14
|
+
add_filter do |line|
|
15
|
+
line.start_with?(@root) ? line.from(@root.size) : line
|
16
|
+
end
|
17
|
+
add_filter do |line|
|
18
|
+
if RENDER_TEMPLATE_PATTERN.match?(line)
|
19
|
+
line.sub(RENDER_TEMPLATE_PATTERN, "")
|
20
|
+
else
|
21
|
+
line
|
22
|
+
end
|
23
|
+
end
|
21
24
|
add_silencer { |line| !APP_DIRS_PATTERN.match?(line) }
|
22
25
|
end
|
23
|
-
|
24
|
-
private
|
25
|
-
def add_gem_filters
|
26
|
-
gems_paths = (Gem.path | [Gem.default_dir]).map { |p| Regexp.escape(p) }
|
27
|
-
return if gems_paths.empty?
|
28
|
-
|
29
|
-
gems_regexp = %r{(#{gems_paths.join('|')})/gems/([^/]+)-([\w.]+)/(.*)}
|
30
|
-
gems_result = '\2 (\3) \4'.freeze
|
31
|
-
add_filter { |line| line.sub(gems_regexp, gems_result) }
|
32
|
-
end
|
33
26
|
end
|
34
27
|
end
|
@@ -8,6 +8,8 @@ class CodeStatistics #:nodoc:
|
|
8
8
|
"Helper tests",
|
9
9
|
"Model tests",
|
10
10
|
"Mailer tests",
|
11
|
+
"Mailbox tests",
|
12
|
+
"Channel tests",
|
11
13
|
"Job tests",
|
12
14
|
"Integration tests",
|
13
15
|
"System tests"]
|
@@ -38,15 +40,15 @@ class CodeStatistics #:nodoc:
|
|
38
40
|
Hash[@pairs.map { |pair| [pair.first, calculate_directory_statistics(pair.last)] }]
|
39
41
|
end
|
40
42
|
|
41
|
-
def calculate_directory_statistics(directory, pattern = /^(?!\.).*?\.(rb|js|coffee|rake)$/)
|
43
|
+
def calculate_directory_statistics(directory, pattern = /^(?!\.).*?\.(rb|js|ts|coffee|rake)$/)
|
42
44
|
stats = CodeStatisticsCalculator.new
|
43
45
|
|
44
46
|
Dir.foreach(directory) do |file_name|
|
45
47
|
path = "#{directory}/#{file_name}"
|
46
48
|
|
47
|
-
if File.directory?(path) && (
|
49
|
+
if File.directory?(path) && !file_name.start_with?(".")
|
48
50
|
stats.add(calculate_directory_statistics(path, pattern))
|
49
|
-
elsif file_name
|
51
|
+
elsif file_name&.match?(pattern)
|
50
52
|
stats.add_by_file_path(path)
|
51
53
|
end
|
52
54
|
end
|
@@ -73,7 +75,7 @@ class CodeStatistics #:nodoc:
|
|
73
75
|
end
|
74
76
|
|
75
77
|
def width_for(label)
|
76
|
-
[@statistics.values.sum { |s| s.
|
78
|
+
[@statistics.values.sum { |s| s.public_send(label) }.to_s.size, HEADERS[label].length].max
|
77
79
|
end
|
78
80
|
|
79
81
|
def print_header
|
@@ -95,8 +97,8 @@ class CodeStatistics #:nodoc:
|
|
95
97
|
end
|
96
98
|
|
97
99
|
def print_line(name, statistics)
|
98
|
-
m_over_c = (statistics.methods / statistics.classes) rescue
|
99
|
-
loc_over_m = (statistics.code_lines / statistics.methods) - 2 rescue
|
100
|
+
m_over_c = (statistics.methods / statistics.classes) rescue 0
|
101
|
+
loc_over_m = (statistics.code_lines / statistics.methods) - 2 rescue 0
|
100
102
|
|
101
103
|
print "| #{name.ljust(20)} "
|
102
104
|
HEADERS.each_key do |k|
|
@@ -58,20 +58,20 @@ class CodeStatisticsCalculator #:nodoc:
|
|
58
58
|
@lines += 1
|
59
59
|
|
60
60
|
if comment_started
|
61
|
-
if patterns[:end_block_comment] &&
|
61
|
+
if patterns[:end_block_comment] && patterns[:end_block_comment].match?(line)
|
62
62
|
comment_started = false
|
63
63
|
end
|
64
64
|
next
|
65
65
|
else
|
66
|
-
if patterns[:begin_block_comment] &&
|
66
|
+
if patterns[:begin_block_comment] && patterns[:begin_block_comment].match?(line)
|
67
67
|
comment_started = true
|
68
68
|
next
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
|
-
@classes += 1 if patterns[:class] &&
|
73
|
-
@methods += 1 if patterns[:method] &&
|
74
|
-
if line
|
72
|
+
@classes += 1 if patterns[:class] && patterns[:class].match?(line)
|
73
|
+
@methods += 1 if patterns[:method] && patterns[:method].match?(line)
|
74
|
+
if !line.match?(/^\s*$/) && (patterns[:line_comment].nil? || !line.match?(patterns[:line_comment]))
|
75
75
|
@code_lines += 1
|
76
76
|
end
|
77
77
|
end
|
@@ -82,7 +82,7 @@ class CodeStatisticsCalculator #:nodoc:
|
|
82
82
|
if file_path.end_with? "_test.rb"
|
83
83
|
:minitest
|
84
84
|
else
|
85
|
-
File.extname(file_path).
|
85
|
+
File.extname(file_path).delete_prefix(".").downcase.to_sym
|
86
86
|
end
|
87
87
|
end
|
88
88
|
end
|
data/lib/rails/command/base.rb
CHANGED
@@ -56,7 +56,7 @@ module Rails
|
|
56
56
|
def inherited(base) #:nodoc:
|
57
57
|
super
|
58
58
|
|
59
|
-
if base.name && base.name
|
59
|
+
if base.name && !base.name.end_with?("Base")
|
60
60
|
Rails::Command.subclasses << base
|
61
61
|
end
|
62
62
|
end
|
@@ -74,7 +74,7 @@ module Rails
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def executable
|
77
|
-
"
|
77
|
+
"rails #{command_name}"
|
78
78
|
end
|
79
79
|
|
80
80
|
# Use Rails' default banner.
|
@@ -119,7 +119,7 @@ module Rails
|
|
119
119
|
# For a Rails::Command::TestCommand placed in <tt>rails/command/test_command.rb</tt>
|
120
120
|
# would return <tt>rails/test</tt>.
|
121
121
|
def default_command_root
|
122
|
-
path = File.expand_path(
|
122
|
+
path = File.expand_path(relative_command_path, __dir__)
|
123
123
|
path if File.exist?(path)
|
124
124
|
end
|
125
125
|
|
@@ -139,12 +139,20 @@ module Rails
|
|
139
139
|
end
|
140
140
|
|
141
141
|
def command_root_namespace
|
142
|
-
(namespace.split(":") - %w(
|
142
|
+
(namespace.split(":") - %w(rails)).join(":")
|
143
|
+
end
|
144
|
+
|
145
|
+
def relative_command_path
|
146
|
+
File.join("../commands", *command_root_namespace.split(":"))
|
143
147
|
end
|
144
148
|
|
145
149
|
def namespaced_commands
|
146
150
|
commands.keys.map do |key|
|
147
|
-
|
151
|
+
if command_root_namespace.match?(/(\A|\:)#{key}\z/)
|
152
|
+
command_root_namespace
|
153
|
+
else
|
154
|
+
"#{command_root_namespace}:#{key}"
|
155
|
+
end
|
148
156
|
end
|
149
157
|
end
|
150
158
|
end
|
@@ -19,46 +19,6 @@ module Rails
|
|
19
19
|
end
|
20
20
|
|
21
21
|
private
|
22
|
-
|
23
|
-
# This code is based directly on the Text gem implementation.
|
24
|
-
# Copyright (c) 2006-2013 Paul Battley, Michael Neumann, Tim Fletcher.
|
25
|
-
#
|
26
|
-
# Returns a value representing the "cost" of transforming str1 into str2.
|
27
|
-
def levenshtein_distance(str1, str2) # :doc:
|
28
|
-
s = str1
|
29
|
-
t = str2
|
30
|
-
n = s.length
|
31
|
-
m = t.length
|
32
|
-
|
33
|
-
return m if (0 == n)
|
34
|
-
return n if (0 == m)
|
35
|
-
|
36
|
-
d = (0..m).to_a
|
37
|
-
x = nil
|
38
|
-
|
39
|
-
# avoid duplicating an enumerable object in the loop
|
40
|
-
str2_codepoint_enumerable = str2.each_codepoint
|
41
|
-
|
42
|
-
str1.each_codepoint.with_index do |char1, i|
|
43
|
-
e = i + 1
|
44
|
-
|
45
|
-
str2_codepoint_enumerable.with_index do |char2, j|
|
46
|
-
cost = (char1 == char2) ? 0 : 1
|
47
|
-
x = [
|
48
|
-
d[j + 1] + 1, # insertion
|
49
|
-
e + 1, # deletion
|
50
|
-
d[j] + cost # substitution
|
51
|
-
].min
|
52
|
-
d[j] = e
|
53
|
-
e = x
|
54
|
-
end
|
55
|
-
|
56
|
-
d[m] = x
|
57
|
-
end
|
58
|
-
|
59
|
-
x
|
60
|
-
end
|
61
|
-
|
62
22
|
# Prints a list of generators.
|
63
23
|
def print_list(base, namespaces)
|
64
24
|
return if namespaces.empty?
|
@@ -84,7 +44,7 @@ module Rails
|
|
84
44
|
require path
|
85
45
|
return
|
86
46
|
rescue LoadError => e
|
87
|
-
raise unless
|
47
|
+
raise unless /#{Regexp.escape(path)}$/.match?(e.message)
|
88
48
|
rescue Exception => e
|
89
49
|
warn "[WARNING] Could not load #{command_type} #{path.inspect}. Error: #{e.message}.\n#{e.backtrace.join("\n")}"
|
90
50
|
end
|
@@ -96,12 +56,10 @@ module Rails
|
|
96
56
|
def lookup!
|
97
57
|
$LOAD_PATH.each do |base|
|
98
58
|
Dir[File.join(base, *file_lookup_paths)].each do |path|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
# No problem
|
104
|
-
end
|
59
|
+
path = path.delete_prefix("#{base}/")
|
60
|
+
require path
|
61
|
+
rescue Exception
|
62
|
+
# No problem
|
105
63
|
end
|
106
64
|
end
|
107
65
|
end
|
@@ -113,8 +71,9 @@ module Rails
|
|
113
71
|
paths = []
|
114
72
|
namespaces.each do |namespace|
|
115
73
|
pieces = namespace.split(":")
|
116
|
-
|
117
|
-
paths << pieces.
|
74
|
+
path = pieces.join("/")
|
75
|
+
paths << "#{path}/#{pieces.last}"
|
76
|
+
paths << path
|
118
77
|
end
|
119
78
|
paths.uniq!
|
120
79
|
paths
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "active_support"
|
4
|
+
require "active_support/core_ext/class/attribute"
|
4
5
|
|
5
6
|
module Rails
|
6
7
|
module Command
|
@@ -8,26 +9,18 @@ module Rails
|
|
8
9
|
extend ActiveSupport::Concern
|
9
10
|
|
10
11
|
included do
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
no_commands do
|
13
|
+
class_attribute :environment_desc, default: "Specifies the environment to run this #{self.command_name} under (test/development/production)."
|
14
|
+
end
|
15
|
+
class_option :environment, aliases: "-e", type: :string, desc: environment_desc
|
15
16
|
end
|
16
17
|
|
17
18
|
private
|
18
|
-
def extract_environment_option_from_argument
|
19
|
-
if environment
|
20
|
-
self.options = options.merge(environment: acceptable_environment(environment))
|
21
|
-
|
22
|
-
ActiveSupport::Deprecation.warn "Passing the environment's name as a " \
|
23
|
-
"regular argument is deprecated and " \
|
24
|
-
"will be removed in the next Rails " \
|
25
|
-
"version. Please, use the -e option " \
|
26
|
-
"instead."
|
27
|
-
elsif options[:environment]
|
19
|
+
def extract_environment_option_from_argument(default_environment: Rails::Command.environment)
|
20
|
+
if options[:environment]
|
28
21
|
self.options = options.merge(environment: acceptable_environment(options[:environment]))
|
29
22
|
else
|
30
|
-
self.options = options.merge(environment:
|
23
|
+
self.options = options.merge(environment: default_environment)
|
31
24
|
end
|
32
25
|
end
|
33
26
|
|
@@ -35,7 +28,7 @@ module Rails
|
|
35
28
|
if available_environments.include? env
|
36
29
|
env
|
37
30
|
else
|
38
|
-
%w( production development test ).detect { |e|
|
31
|
+
%w( production development test ).detect { |e| /^#{env}/.match?(e) } || env
|
39
32
|
end
|
40
33
|
end
|
41
34
|
|