railties 5.1.7 → 5.2.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +77 -241
- data/RDOC_MAIN.rdoc +61 -43
- data/README.rdoc +1 -2
- data/exe/rails +3 -2
- data/lib/minitest/rails_plugin.rb +9 -13
- data/lib/rails.rb +4 -2
- data/lib/rails/all.rb +3 -0
- data/lib/rails/api/generator.rb +10 -1
- data/lib/rails/api/task.rb +11 -1
- data/lib/rails/app_loader.rb +18 -5
- data/lib/rails/app_updater.rb +34 -0
- data/lib/rails/application.rb +90 -18
- data/lib/rails/application/bootstrap.rb +2 -0
- data/lib/rails/application/configuration.rb +79 -36
- data/lib/rails/application/default_middleware_stack.rb +7 -1
- data/lib/rails/application/finisher.rb +3 -1
- data/lib/rails/application/routes_reloader.rb +21 -3
- data/lib/rails/application_controller.rb +3 -1
- data/lib/rails/backtrace_cleaner.rb +3 -1
- data/lib/rails/cli.rb +2 -0
- data/lib/rails/code_statistics.rb +2 -0
- data/lib/rails/code_statistics_calculator.rb +2 -0
- data/lib/rails/command.rb +3 -1
- data/lib/rails/command/actions.rb +6 -4
- data/lib/rails/command/base.rb +5 -3
- data/lib/rails/command/behavior.rb +2 -0
- data/lib/rails/command/environment_argument.rb +14 -1
- data/lib/rails/command/helpers/editor.rb +35 -0
- data/lib/rails/commands.rb +2 -0
- data/lib/rails/commands/application/application_command.rb +2 -0
- data/lib/rails/commands/console/console_command.rb +2 -3
- data/lib/rails/commands/credentials/USAGE +40 -0
- data/lib/rails/commands/credentials/credentials_command.rb +72 -0
- data/lib/rails/commands/dbconsole/dbconsole_command.rb +18 -7
- data/lib/rails/commands/destroy/destroy_command.rb +2 -0
- data/lib/rails/commands/encrypted/encrypted_command.rb +77 -0
- data/lib/rails/commands/generate/generate_command.rb +2 -0
- data/lib/rails/commands/help/help_command.rb +2 -0
- data/lib/rails/commands/new/new_command.rb +2 -0
- data/lib/rails/commands/plugin/plugin_command.rb +2 -0
- data/lib/rails/commands/rake/rake_command.rb +2 -0
- data/lib/rails/commands/runner/USAGE +3 -0
- data/lib/rails/commands/runner/runner_command.rb +7 -3
- data/lib/rails/commands/secrets/secrets_command.rb +15 -10
- data/lib/rails/commands/server/server_command.rb +24 -3
- data/lib/rails/commands/test/test_command.rb +18 -23
- data/lib/rails/commands/version/version_command.rb +2 -0
- data/lib/rails/configuration.rb +2 -0
- data/lib/rails/console/app.rb +2 -0
- data/lib/rails/console/helpers.rb +2 -0
- data/lib/rails/dev_caching.rb +2 -1
- data/lib/rails/engine.rb +3 -1
- data/lib/rails/engine/commands.rb +2 -0
- data/lib/rails/engine/configuration.rb +2 -0
- data/lib/rails/engine/railties.rb +2 -0
- data/lib/rails/engine/updater.rb +3 -1
- data/lib/rails/gem_version.rb +5 -3
- data/lib/rails/generators.rb +8 -3
- data/lib/rails/generators/actions.rb +53 -24
- data/lib/rails/generators/actions/create_migration.rb +2 -0
- data/lib/rails/generators/active_model.rb +2 -0
- data/lib/rails/generators/app_base.rb +94 -57
- data/lib/rails/generators/base.rb +40 -1
- data/lib/rails/generators/css/assets/assets_generator.rb +3 -1
- data/lib/rails/generators/css/scaffold/scaffold_generator.rb +5 -3
- data/lib/rails/generators/erb.rb +2 -0
- data/lib/rails/generators/erb/controller/controller_generator.rb +2 -0
- data/lib/rails/generators/erb/controller/templates/{view.html.erb → view.html.erb.tt} +0 -0
- data/lib/rails/generators/erb/mailer/mailer_generator.rb +2 -0
- data/lib/rails/generators/erb/mailer/templates/{view.html.erb → view.html.erb.tt} +0 -0
- data/lib/rails/generators/erb/mailer/templates/{view.text.erb → view.text.erb.tt} +0 -0
- data/lib/rails/generators/erb/scaffold/scaffold_generator.rb +2 -0
- data/lib/rails/generators/erb/scaffold/templates/{_form.html.erb → _form.html.erb.tt} +4 -4
- data/lib/rails/generators/erb/scaffold/templates/{edit.html.erb → edit.html.erb.tt} +0 -0
- data/lib/rails/generators/erb/scaffold/templates/{index.html.erb → index.html.erb.tt} +4 -4
- data/lib/rails/generators/erb/scaffold/templates/{new.html.erb → new.html.erb.tt} +0 -0
- data/lib/rails/generators/erb/scaffold/templates/{show.html.erb → show.html.erb.tt} +0 -0
- data/lib/rails/generators/generated_attribute.rb +3 -1
- data/lib/rails/generators/js/assets/assets_generator.rb +3 -1
- data/lib/rails/generators/migration.rb +2 -0
- data/lib/rails/generators/model_helpers.rb +2 -0
- data/lib/rails/generators/named_base.rb +35 -45
- data/lib/rails/generators/rails/app/app_generator.rb +64 -23
- data/lib/rails/generators/rails/app/templates/{Gemfile → Gemfile.tt} +17 -6
- data/lib/rails/generators/rails/app/templates/{README.md → README.md.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/{Rakefile → Rakefile.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt +3 -0
- data/lib/rails/generators/rails/app/templates/app/assets/javascripts/{cable.js → cable.js.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/app/assets/stylesheets/{application.css → application.css.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/app/channels/application_cable/{channel.rb → channel.rb.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/app/channels/application_cable/{connection.rb → connection.rb.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/app/controllers/application_controller.rb.tt +1 -4
- data/lib/rails/generators/rails/app/templates/app/helpers/{application_helper.rb → application_helper.rb.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/app/jobs/{application_job.rb → application_job.rb.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/app/mailers/{application_mailer.rb → application_mailer.rb.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/app/models/{application_record.rb → application_record.rb.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/bin/bundle.tt +2 -0
- data/lib/rails/generators/rails/app/templates/bin/{rails → rails.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/bin/{rake → rake.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/bin/setup.tt +5 -5
- data/lib/rails/generators/rails/app/templates/bin/update.tt +7 -3
- data/lib/rails/generators/rails/app/templates/bin/{yarn → yarn.tt} +3 -3
- data/lib/rails/generators/rails/app/templates/{config.ru → config.ru.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/config/{application.rb → application.rb.tt} +2 -1
- data/lib/rails/generators/rails/app/templates/config/{boot.rb → boot.rb.tt} +1 -0
- data/lib/rails/generators/rails/app/templates/config/{cable.yml → cable.yml.tt} +1 -1
- data/lib/rails/generators/rails/app/templates/config/databases/{frontbase.yml → frontbase.yml.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/config/databases/{ibm_db.yml → ibm_db.yml.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/config/databases/{jdbc.yml → jdbc.yml.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/config/databases/{jdbcmysql.yml → jdbcmysql.yml.tt} +1 -1
- data/lib/rails/generators/rails/app/templates/config/databases/{jdbcpostgresql.yml → jdbcpostgresql.yml.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/config/databases/{jdbcsqlite3.yml → jdbcsqlite3.yml.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/config/databases/{mysql.yml → mysql.yml.tt} +1 -1
- data/lib/rails/generators/rails/app/templates/config/databases/{oracle.yml → oracle.yml.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/config/databases/{postgresql.yml → postgresql.yml.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/config/databases/{sqlite3.yml → sqlite3.yml.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/config/databases/{sqlserver.yml → sqlserver.yml.tt} +2 -2
- data/lib/rails/generators/rails/app/templates/config/{environment.rb → environment.rb.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +7 -1
- data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +12 -7
- data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +8 -2
- data/lib/rails/generators/rails/app/templates/config/initializers/{application_controller_renderer.rb → application_controller_renderer.rb.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/{backtrace_silencers.rb → backtrace_silencers.rb.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/content_security_policy.rb.tt +20 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/{cookies_serializer.rb → cookies_serializer.rb.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/{cors.rb → cors.rb.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/{filter_parameter_logging.rb → filter_parameter_logging.rb.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/{inflections.rb → inflections.rb.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/{mime_types.rb → mime_types.rb.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_5_2.rb.tt +27 -0
- data/lib/rails/generators/rails/app/templates/config/{puma.rb → puma.rb.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/config/{routes.rb → routes.rb.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/config/{spring.rb → spring.rb.tt} +2 -2
- data/lib/rails/generators/rails/app/templates/config/storage.yml.tt +35 -0
- data/lib/rails/generators/rails/app/templates/{gitignore → gitignore.tt} +9 -1
- data/lib/rails/generators/rails/app/templates/{package.json → package.json.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/ruby-version.tt +1 -0
- data/lib/rails/generators/rails/app/templates/test/{application_system_test_case.rb → application_system_test_case.rb.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/test/{test_helper.rb → test_helper.rb.tt} +1 -2
- data/lib/rails/generators/rails/application_record/application_record_generator.rb +9 -0
- data/lib/rails/generators/rails/assets/assets_generator.rb +2 -0
- data/lib/rails/generators/rails/assets/templates/stylesheet.css +1 -1
- data/lib/rails/generators/rails/controller/controller_generator.rb +11 -9
- data/lib/rails/generators/rails/controller/templates/{controller.rb → controller.rb.tt} +0 -0
- data/lib/rails/generators/rails/credentials/credentials_generator.rb +48 -0
- data/lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb +38 -0
- data/lib/rails/generators/rails/encryption_key_file/encryption_key_file_generator.rb +57 -0
- data/lib/rails/generators/rails/generator/generator_generator.rb +2 -0
- data/lib/rails/generators/rails/generator/templates/%file_name%_generator.rb.tt +1 -1
- data/lib/rails/generators/rails/helper/helper_generator.rb +2 -0
- data/lib/rails/generators/rails/helper/templates/{helper.rb → helper.rb.tt} +0 -0
- data/lib/rails/generators/rails/integration_test/integration_test_generator.rb +2 -0
- data/lib/rails/generators/rails/master_key/master_key_generator.rb +51 -0
- data/lib/rails/generators/rails/migration/migration_generator.rb +2 -0
- data/lib/rails/generators/rails/model/model_generator.rb +2 -0
- data/lib/rails/generators/rails/plugin/plugin_generator.rb +18 -9
- data/lib/rails/generators/rails/plugin/templates/%name%.gemspec.tt +24 -0
- data/lib/rails/generators/rails/plugin/templates/{Gemfile → Gemfile.tt} +1 -0
- data/lib/rails/generators/rails/plugin/templates/{MIT-LICENSE → MIT-LICENSE.tt} +0 -0
- data/lib/rails/generators/rails/plugin/templates/{README.md → README.md.tt} +1 -1
- data/lib/rails/generators/rails/plugin/templates/{Rakefile → Rakefile.tt} +6 -7
- data/lib/rails/generators/rails/plugin/templates/bin/rails.tt +21 -4
- data/lib/rails/generators/rails/plugin/templates/bin/test.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/config/{routes.rb → routes.rb.tt} +0 -0
- data/lib/rails/generators/rails/plugin/templates/gitignore.tt +18 -0
- data/lib/rails/generators/rails/plugin/templates/lib/{%namespaced_name%.rb → %namespaced_name%.rb.tt} +3 -1
- data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/{engine.rb → engine.rb.tt} +0 -0
- data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/railtie.rb.tt +5 -0
- data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/{version.rb → version.rb.tt} +0 -0
- data/lib/rails/generators/rails/plugin/templates/lib/tasks/{%namespaced_name%_tasks.rake → %namespaced_name%_tasks.rake.tt} +0 -0
- data/lib/rails/generators/rails/plugin/templates/rails/{application.rb → application.rb.tt} +6 -3
- data/lib/rails/generators/rails/plugin/templates/rails/{boot.rb → boot.rb.tt} +0 -0
- data/lib/rails/generators/rails/plugin/templates/rails/{dummy_manifest.js → dummy_manifest.js.tt} +0 -1
- data/lib/rails/generators/rails/plugin/templates/rails/{engine_manifest.js → engine_manifest.js.tt} +0 -0
- data/lib/rails/generators/rails/plugin/templates/rails/{javascripts.js → javascripts.js.tt} +3 -0
- data/lib/rails/generators/rails/plugin/templates/rails/{routes.rb → routes.rb.tt} +0 -0
- data/lib/rails/generators/rails/plugin/templates/test/{%namespaced_name%_test.rb → %namespaced_name%_test.rb.tt} +0 -0
- data/lib/rails/generators/rails/plugin/templates/test/{application_system_test_case.rb → application_system_test_case.rb.tt} +0 -0
- data/lib/rails/generators/rails/plugin/templates/test/integration/{navigation_test.rb → navigation_test.rb.tt} +0 -1
- data/lib/rails/generators/rails/plugin/templates/test/{test_helper.rb → test_helper.rb.tt} +7 -6
- data/lib/rails/generators/rails/resource/USAGE +1 -1
- data/lib/rails/generators/rails/resource/resource_generator.rb +2 -0
- data/lib/rails/generators/rails/resource_route/resource_route_generator.rb +21 -24
- data/lib/rails/generators/rails/scaffold/scaffold_generator.rb +2 -3
- data/lib/rails/generators/rails/scaffold_controller/USAGE +1 -1
- data/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb +2 -0
- data/lib/rails/generators/rails/scaffold_controller/templates/{api_controller.rb → api_controller.rb.tt} +0 -0
- data/lib/rails/generators/rails/scaffold_controller/templates/{controller.rb → controller.rb.tt} +2 -2
- data/lib/rails/generators/rails/system_test/system_test_generator.rb +2 -0
- data/lib/rails/generators/rails/task/task_generator.rb +2 -0
- data/lib/rails/generators/rails/task/templates/{task.rb → task.rb.tt} +0 -0
- data/lib/rails/generators/resource_helpers.rb +2 -0
- data/lib/rails/generators/test_case.rb +4 -2
- data/lib/rails/generators/test_unit.rb +2 -0
- data/lib/rails/generators/test_unit/controller/controller_generator.rb +2 -0
- data/lib/rails/generators/test_unit/controller/templates/{functional_test.rb → functional_test.rb.tt} +0 -0
- data/lib/rails/generators/test_unit/generator/generator_generator.rb +2 -0
- data/lib/rails/generators/test_unit/generator/templates/{generator_test.rb → generator_test.rb.tt} +0 -0
- data/lib/rails/generators/test_unit/helper/helper_generator.rb +2 -0
- data/lib/rails/generators/test_unit/integration/integration_generator.rb +2 -0
- data/lib/rails/generators/test_unit/integration/templates/{integration_test.rb → integration_test.rb.tt} +0 -0
- data/lib/rails/generators/test_unit/job/job_generator.rb +3 -1
- data/lib/rails/generators/test_unit/job/templates/{unit_test.rb.erb → unit_test.rb.tt} +0 -0
- data/lib/rails/generators/test_unit/mailer/mailer_generator.rb +2 -0
- data/lib/rails/generators/test_unit/mailer/templates/{functional_test.rb → functional_test.rb.tt} +0 -0
- data/lib/rails/generators/test_unit/mailer/templates/{preview.rb → preview.rb.tt} +0 -0
- data/lib/rails/generators/test_unit/model/model_generator.rb +2 -0
- data/lib/rails/generators/test_unit/model/templates/{fixtures.yml → fixtures.yml.tt} +0 -0
- data/lib/rails/generators/test_unit/model/templates/{unit_test.rb → unit_test.rb.tt} +0 -0
- data/lib/rails/generators/test_unit/plugin/plugin_generator.rb +2 -0
- data/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb +17 -4
- data/lib/rails/generators/test_unit/scaffold/templates/{api_functional_test.rb → api_functional_test.rb.tt} +2 -2
- data/lib/rails/generators/test_unit/scaffold/templates/{functional_test.rb → functional_test.rb.tt} +2 -2
- data/lib/rails/generators/test_unit/scaffold/templates/system_test.rb.tt +49 -0
- data/lib/rails/generators/test_unit/system/system_generator.rb +3 -1
- data/lib/rails/generators/test_unit/system/templates/{application_system_test_case.rb → application_system_test_case.rb.tt} +0 -0
- data/lib/rails/generators/test_unit/system/templates/{system_test.rb → system_test.rb.tt} +0 -0
- data/lib/rails/generators/testing/assertions.rb +7 -1
- data/lib/rails/generators/testing/behaviour.rb +8 -6
- data/lib/rails/generators/testing/setup_and_teardown.rb +2 -0
- data/lib/rails/info.rb +6 -3
- data/lib/rails/info_controller.rb +2 -0
- data/lib/rails/initializable.rb +2 -0
- data/lib/rails/mailers_controller.rb +9 -1
- data/lib/rails/paths.rb +2 -0
- data/lib/rails/plugin/test.rb +4 -2
- data/lib/rails/rack.rb +2 -0
- data/lib/rails/rack/logger.rb +5 -3
- data/lib/rails/railtie.rb +9 -4
- data/lib/rails/railtie/configurable.rb +2 -0
- data/lib/rails/railtie/configuration.rb +2 -0
- data/lib/rails/ruby_version_check.rb +3 -1
- data/lib/rails/secrets.rb +2 -17
- data/lib/rails/source_annotation_extractor.rb +4 -2
- data/lib/rails/tasks.rb +2 -0
- data/lib/rails/tasks/annotations.rake +2 -0
- data/lib/rails/tasks/dev.rake +2 -0
- data/lib/rails/tasks/engine.rake +7 -2
- data/lib/rails/tasks/framework.rake +9 -24
- data/lib/rails/tasks/initializers.rake +2 -0
- data/lib/rails/tasks/log.rake +2 -0
- data/lib/rails/tasks/middleware.rake +2 -0
- data/lib/rails/tasks/misc.rake +2 -0
- data/lib/rails/tasks/restart.rake +2 -1
- data/lib/rails/tasks/routes.rake +2 -0
- data/lib/rails/tasks/statistics.rake +2 -0
- data/lib/rails/tasks/tmp.rake +11 -2
- data/lib/rails/tasks/yarn.rake +3 -1
- data/lib/rails/templates/rails/mailers/email.html.erb +3 -3
- data/lib/rails/templates/rails/welcome/index.html.erb +14 -4
- data/lib/rails/test_help.rb +2 -0
- data/lib/rails/test_unit/line_filtering.rb +2 -1
- data/lib/rails/test_unit/railtie.rb +2 -0
- data/lib/rails/test_unit/reporter.rb +5 -10
- data/lib/rails/test_unit/runner.rb +3 -3
- data/lib/rails/test_unit/testing.rake +3 -1
- data/lib/rails/version.rb +2 -0
- data/lib/rails/welcome_controller.rb +2 -0
- metadata +121 -107
- data/lib/rails/generators/rails/app/templates/bin/bundle +0 -2
- data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_5_1.rb.tt +0 -16
- data/lib/rails/generators/rails/app/templates/config/secrets.yml +0 -32
- data/lib/rails/generators/rails/encrypted_secrets/encrypted_secrets_generator.rb +0 -70
- data/lib/rails/generators/rails/plugin/templates/%name%.gemspec +0 -33
- data/lib/rails/generators/rails/plugin/templates/gitignore +0 -9
@@ -0,0 +1,77 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "pathname"
|
4
|
+
require "active_support"
|
5
|
+
require "rails/command/helpers/editor"
|
6
|
+
|
7
|
+
module Rails
|
8
|
+
module Command
|
9
|
+
class EncryptedCommand < Rails::Command::Base # :nodoc:
|
10
|
+
include Helpers::Editor
|
11
|
+
|
12
|
+
class_option :key, aliases: "-k", type: :string,
|
13
|
+
default: "config/master.key", desc: "The Rails.root relative path to the encryption key"
|
14
|
+
|
15
|
+
no_commands do
|
16
|
+
def help
|
17
|
+
say "Usage:\n #{self.class.banner}"
|
18
|
+
say ""
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def edit(file_path)
|
23
|
+
require_application_and_environment!
|
24
|
+
|
25
|
+
ensure_editor_available(command: "bin/rails encrypted:edit") || (return)
|
26
|
+
ensure_encryption_key_has_been_added(options[:key])
|
27
|
+
ensure_encrypted_file_has_been_added(file_path, options[:key])
|
28
|
+
|
29
|
+
catch_editing_exceptions do
|
30
|
+
change_encrypted_file_in_system_editor(file_path, options[:key])
|
31
|
+
end
|
32
|
+
|
33
|
+
say "File encrypted and saved."
|
34
|
+
rescue ActiveSupport::MessageEncryptor::InvalidMessage
|
35
|
+
say "Couldn't decrypt #{file_path}. Perhaps you passed the wrong key?"
|
36
|
+
end
|
37
|
+
|
38
|
+
def show(file_path)
|
39
|
+
require_application_and_environment!
|
40
|
+
|
41
|
+
say Rails.application.encrypted(file_path, key_path: options[:key]).read.presence ||
|
42
|
+
"File '#{file_path}' does not exist. Use bin/rails encrypted:edit #{file_path} to change that."
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
def ensure_encryption_key_has_been_added(key_path)
|
47
|
+
encryption_key_file_generator.add_key_file(key_path)
|
48
|
+
encryption_key_file_generator.ignore_key_file(key_path)
|
49
|
+
end
|
50
|
+
|
51
|
+
def ensure_encrypted_file_has_been_added(file_path, key_path)
|
52
|
+
encrypted_file_generator.add_encrypted_file_silently(file_path, key_path)
|
53
|
+
end
|
54
|
+
|
55
|
+
def change_encrypted_file_in_system_editor(file_path, key_path)
|
56
|
+
Rails.application.encrypted(file_path, key_path: key_path).change do |tmp_path|
|
57
|
+
system("#{ENV["EDITOR"]} #{tmp_path}")
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
def encryption_key_file_generator
|
63
|
+
require "rails/generators"
|
64
|
+
require "rails/generators/rails/encryption_key_file/encryption_key_file_generator"
|
65
|
+
|
66
|
+
Rails::Generators::EncryptionKeyFileGenerator.new
|
67
|
+
end
|
68
|
+
|
69
|
+
def encrypted_file_generator
|
70
|
+
require "rails/generators"
|
71
|
+
require "rails/generators/rails/encrypted_file/encrypted_file_generator"
|
72
|
+
|
73
|
+
Rails::Generators::EncryptedFileGenerator.new
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -8,6 +8,9 @@ Run the Ruby file located at `path/to/filename.rb` after loading the app:
|
|
8
8
|
|
9
9
|
<%= executable %> path/to/filename.rb
|
10
10
|
|
11
|
+
Run the Ruby script read from stdin after loading the app:
|
12
|
+
<%= executable %> -
|
13
|
+
|
11
14
|
<% unless Gem.win_platform? %>
|
12
15
|
You can also use the runner command as a shebang line for your executables:
|
13
16
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Rails
|
2
4
|
module Command
|
3
5
|
class RunnerCommand < Base # :nodoc:
|
@@ -13,7 +15,7 @@ module Rails
|
|
13
15
|
end
|
14
16
|
|
15
17
|
def self.banner(*)
|
16
|
-
"#{super} [<'Some.ruby(code)'> | <filename.rb>]"
|
18
|
+
"#{super} [<'Some.ruby(code)'> | <filename.rb> | -]"
|
17
19
|
end
|
18
20
|
|
19
21
|
def perform(code_or_file = nil, *command_argv)
|
@@ -29,12 +31,14 @@ module Rails
|
|
29
31
|
|
30
32
|
ARGV.replace(command_argv)
|
31
33
|
|
32
|
-
if
|
34
|
+
if code_or_file == "-"
|
35
|
+
eval($stdin.read, TOPLEVEL_BINDING, "stdin")
|
36
|
+
elsif File.exist?(code_or_file)
|
33
37
|
$0 = code_or_file
|
34
38
|
Kernel.load code_or_file
|
35
39
|
else
|
36
40
|
begin
|
37
|
-
eval(code_or_file,
|
41
|
+
eval(code_or_file, TOPLEVEL_BINDING, __FILE__, __LINE__)
|
38
42
|
rescue SyntaxError, NameError => error
|
39
43
|
$stderr.puts "Please specify a valid ruby command or the path of a script to run."
|
40
44
|
$stderr.puts "Run '#{self.class.executable} -h' for help."
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "active_support"
|
2
4
|
require "rails/secrets"
|
3
5
|
|
@@ -13,7 +15,7 @@ module Rails
|
|
13
15
|
end
|
14
16
|
|
15
17
|
def setup
|
16
|
-
|
18
|
+
deprecate_in_favor_of_credentials_and_exit
|
17
19
|
end
|
18
20
|
|
19
21
|
def edit
|
@@ -40,20 +42,23 @@ module Rails
|
|
40
42
|
rescue Rails::Secrets::MissingKeyError => error
|
41
43
|
say error.message
|
42
44
|
rescue Errno::ENOENT => error
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
generator.skip_secrets_file { setup }
|
45
|
+
if error.message =~ /secrets\.yml\.enc/
|
46
|
+
deprecate_in_favor_of_credentials_and_exit
|
47
|
+
else
|
48
|
+
raise
|
48
49
|
end
|
49
50
|
end
|
50
51
|
|
52
|
+
def show
|
53
|
+
say Rails::Secrets.read
|
54
|
+
end
|
55
|
+
|
51
56
|
private
|
52
|
-
def
|
53
|
-
|
54
|
-
|
57
|
+
def deprecate_in_favor_of_credentials_and_exit
|
58
|
+
say "Encrypted secrets is deprecated in favor of credentials. Run:"
|
59
|
+
say "bin/rails credentials --help"
|
55
60
|
|
56
|
-
|
61
|
+
exit 1
|
57
62
|
end
|
58
63
|
end
|
59
64
|
end
|
@@ -1,7 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "fileutils"
|
2
4
|
require "optparse"
|
3
5
|
require "action_dispatch"
|
4
6
|
require "rails"
|
7
|
+
require "active_support/deprecation"
|
8
|
+
require "active_support/core_ext/string/filters"
|
5
9
|
require "rails/dev_caching"
|
6
10
|
|
7
11
|
module Rails
|
@@ -18,10 +22,15 @@ module Rails
|
|
18
22
|
set_environment
|
19
23
|
end
|
20
24
|
|
21
|
-
# TODO: this is no longer required but we keep it for the moment to support older config.ru files.
|
22
25
|
def app
|
23
26
|
@app ||= begin
|
24
27
|
app = super
|
28
|
+
if app.is_a?(Class)
|
29
|
+
ActiveSupport::Deprecation.warn(<<-MSG.squish)
|
30
|
+
Use `Rails::Application` subclass to start the server is deprecated and will be removed in Rails 6.0.
|
31
|
+
Please change `run #{app}` to `run Rails.application` in config.ru.
|
32
|
+
MSG
|
33
|
+
end
|
25
34
|
app.respond_to?(:to_app) ? app.to_app : app
|
26
35
|
end
|
27
36
|
end
|
@@ -117,6 +126,8 @@ module Rails
|
|
117
126
|
desc: "Specifies the PID file."
|
118
127
|
class_option "dev-caching", aliases: "-C", type: :boolean, default: nil,
|
119
128
|
desc: "Specifies whether to perform caching in development."
|
129
|
+
class_option "restart", type: :boolean, default: nil, hide: true
|
130
|
+
class_option "early_hints", type: :boolean, default: nil, desc: "Enables HTTP/2 early hints."
|
120
131
|
|
121
132
|
def initialize(args = [], local_options = {}, config = {})
|
122
133
|
@original_options = local_options
|
@@ -127,6 +138,7 @@ module Rails
|
|
127
138
|
|
128
139
|
def perform
|
129
140
|
set_application_directory!
|
141
|
+
prepare_restart
|
130
142
|
Rails::Server.new(server_options).tap do |server|
|
131
143
|
# Require application after server sets environment to propagate
|
132
144
|
# the --environment option.
|
@@ -150,7 +162,8 @@ module Rails
|
|
150
162
|
daemonize: options[:daemon],
|
151
163
|
pid: pid,
|
152
164
|
caching: options["dev-caching"],
|
153
|
-
restart_cmd: restart_command
|
165
|
+
restart_cmd: restart_command,
|
166
|
+
early_hints: early_hints
|
154
167
|
}
|
155
168
|
end
|
156
169
|
end
|
@@ -213,7 +226,11 @@ module Rails
|
|
213
226
|
end
|
214
227
|
|
215
228
|
def restart_command
|
216
|
-
"bin/rails server #{@server} #{@original_options.join(" ")}"
|
229
|
+
"bin/rails server #{@server} #{@original_options.join(" ")} --restart"
|
230
|
+
end
|
231
|
+
|
232
|
+
def early_hints
|
233
|
+
options[:early_hints]
|
217
234
|
end
|
218
235
|
|
219
236
|
def pid
|
@@ -223,6 +240,10 @@ module Rails
|
|
223
240
|
def self.banner(*)
|
224
241
|
"rails server [puma, thin etc] [options]"
|
225
242
|
end
|
243
|
+
|
244
|
+
def prepare_restart
|
245
|
+
FileUtils.rm_f(options[:pid]) if options[:restart]
|
246
|
+
end
|
226
247
|
end
|
227
248
|
end
|
228
249
|
end
|
@@ -1,33 +1,28 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rails/command"
|
4
|
+
require "rails/test_unit/runner"
|
5
|
+
require "rails/test_unit/reporter"
|
3
6
|
|
4
7
|
module Rails
|
5
8
|
module Command
|
6
9
|
class TestCommand < Base # :nodoc:
|
7
10
|
no_commands do
|
8
11
|
def help
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
opts.separator " #{Rails::TestUnitReporter.executable} test/controllers test/integration/login_test.rb"
|
22
|
-
opts.separator ""
|
23
|
-
opts.separator "By default test failures and errors are reported inline during a run."
|
24
|
-
opts.separator ""
|
25
|
-
|
26
|
-
opts.separator "Rails options:"
|
27
|
-
Rails::TestUnit::Runner.options(opts)
|
28
|
-
Minitest.plugin_rails_options(opts, {})
|
12
|
+
say "Usage: #{Rails::TestUnitReporter.executable} [options] [files or directories]"
|
13
|
+
say ""
|
14
|
+
say "You can run a single test by appending a line number to a filename:"
|
15
|
+
say ""
|
16
|
+
say " #{Rails::TestUnitReporter.executable} test/models/user_test.rb:27"
|
17
|
+
say ""
|
18
|
+
say "You can run multiple files and directories at the same time:"
|
19
|
+
say ""
|
20
|
+
say " #{Rails::TestUnitReporter.executable} test/controllers test/integration/login_test.rb"
|
21
|
+
say ""
|
22
|
+
say "By default test failures and errors are reported inline during a run."
|
23
|
+
say ""
|
29
24
|
|
30
|
-
|
25
|
+
Minitest.run(%w(--help))
|
31
26
|
end
|
32
27
|
end
|
33
28
|
|
data/lib/rails/configuration.rb
CHANGED
data/lib/rails/console/app.rb
CHANGED
data/lib/rails/dev_caching.rb
CHANGED
data/lib/rails/engine.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "rails/railtie"
|
2
4
|
require "rails/engine/railties"
|
3
5
|
require "active_support/core_ext/module/delegation"
|
@@ -40,7 +42,7 @@ module Rails
|
|
40
42
|
#
|
41
43
|
# class MyEngine < Rails::Engine
|
42
44
|
# # Add a load path for this specific Engine
|
43
|
-
# config.autoload_paths << File.expand_path("
|
45
|
+
# config.autoload_paths << File.expand_path("lib/some/path", __dir__)
|
44
46
|
#
|
45
47
|
# initializer "my_engine.add_middleware" do |app|
|
46
48
|
# app.middleware.use MyEngine::Middleware
|
data/lib/rails/engine/updater.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "rails/generators"
|
2
4
|
require "rails/generators/rails/plugin/plugin_generator"
|
3
5
|
|
@@ -7,7 +9,7 @@ module Rails
|
|
7
9
|
class << self
|
8
10
|
def generator
|
9
11
|
@generator ||= Rails::Generators::PluginGenerator.new ["plugin"],
|
10
|
-
{ engine: true }, destination_root: ENGINE_ROOT
|
12
|
+
{ engine: true }, { destination_root: ENGINE_ROOT }
|
11
13
|
end
|
12
14
|
|
13
15
|
def run(action)
|
data/lib/rails/gem_version.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Rails
|
2
4
|
# Returns the version of the currently loaded Rails as a <tt>Gem::Version</tt>
|
3
5
|
def self.gem_version
|
@@ -6,9 +8,9 @@ module Rails
|
|
6
8
|
|
7
9
|
module VERSION
|
8
10
|
MAJOR = 5
|
9
|
-
MINOR =
|
10
|
-
TINY =
|
11
|
-
PRE =
|
11
|
+
MINOR = 2
|
12
|
+
TINY = 0
|
13
|
+
PRE = "beta1"
|
12
14
|
|
13
15
|
STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
|
14
16
|
end
|