omg-railties 8.0.0.alpha3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +171 -0
- data/MIT-LICENSE +20 -0
- data/RDOC_MAIN.md +99 -0
- data/README.rdoc +39 -0
- data/exe/rails +10 -0
- data/lib/minitest/rails_plugin.rb +140 -0
- data/lib/rails/all.rb +21 -0
- data/lib/rails/api/generator.rb +38 -0
- data/lib/rails/api/task.rb +235 -0
- data/lib/rails/app_loader.rb +77 -0
- data/lib/rails/application/bootstrap.rb +118 -0
- data/lib/rails/application/configuration.rb +659 -0
- data/lib/rails/application/default_middleware_stack.rb +140 -0
- data/lib/rails/application/dummy_config.rb +19 -0
- data/lib/rails/application/finisher.rb +238 -0
- data/lib/rails/application/routes_reloader.rb +79 -0
- data/lib/rails/application.rb +658 -0
- data/lib/rails/application_controller.rb +28 -0
- data/lib/rails/autoloaders/inflector.rb +21 -0
- data/lib/rails/autoloaders.rb +48 -0
- data/lib/rails/backtrace_cleaner.rb +42 -0
- data/lib/rails/cli.rb +21 -0
- data/lib/rails/code_statistics.rb +159 -0
- data/lib/rails/code_statistics_calculator.rb +99 -0
- data/lib/rails/command/actions.rb +52 -0
- data/lib/rails/command/base.rb +185 -0
- data/lib/rails/command/behavior.rb +84 -0
- data/lib/rails/command/environment_argument.rb +56 -0
- data/lib/rails/command/helpers/editor.rb +40 -0
- data/lib/rails/command.rb +172 -0
- data/lib/rails/commands/about/about_command.rb +14 -0
- data/lib/rails/commands/app/update_command.rb +94 -0
- data/lib/rails/commands/application/application_command.rb +33 -0
- data/lib/rails/commands/boot/boot_command.rb +14 -0
- data/lib/rails/commands/console/console_command.rb +91 -0
- data/lib/rails/commands/console/irb_console.rb +136 -0
- data/lib/rails/commands/credentials/USAGE +73 -0
- data/lib/rails/commands/credentials/credentials_command/diffing.rb +53 -0
- data/lib/rails/commands/credentials/credentials_command.rb +139 -0
- data/lib/rails/commands/db/system/change/change_command.rb +26 -0
- data/lib/rails/commands/dbconsole/dbconsole_command.rb +88 -0
- data/lib/rails/commands/destroy/destroy_command.rb +29 -0
- data/lib/rails/commands/dev/dev_command.rb +14 -0
- data/lib/rails/commands/devcontainer/devcontainer_command.rb +39 -0
- data/lib/rails/commands/encrypted/USAGE +23 -0
- data/lib/rails/commands/encrypted/encrypted_command.rb +98 -0
- data/lib/rails/commands/gem_help/USAGE +16 -0
- data/lib/rails/commands/gem_help/gem_help_command.rb +13 -0
- data/lib/rails/commands/generate/generate_command.rb +30 -0
- data/lib/rails/commands/help/USAGE +17 -0
- data/lib/rails/commands/help/help_command.rb +34 -0
- data/lib/rails/commands/initializers/initializers_command.rb +20 -0
- data/lib/rails/commands/middleware/middleware_command.rb +17 -0
- data/lib/rails/commands/new/new_command.rb +21 -0
- data/lib/rails/commands/notes/notes_command.rb +30 -0
- data/lib/rails/commands/plugin/plugin_command.rb +47 -0
- data/lib/rails/commands/rake/rake_command.rb +55 -0
- data/lib/rails/commands/restart/restart_command.rb +14 -0
- data/lib/rails/commands/routes/routes_command.rb +49 -0
- data/lib/rails/commands/runner/USAGE +22 -0
- data/lib/rails/commands/runner/runner_command.rb +81 -0
- data/lib/rails/commands/secret/secret_command.rb +13 -0
- data/lib/rails/commands/server/server_command.rb +290 -0
- data/lib/rails/commands/stats/stats_command.rb +19 -0
- data/lib/rails/commands/test/USAGE +14 -0
- data/lib/rails/commands/test/test_command.rb +81 -0
- data/lib/rails/commands/unused_routes/unused_routes_command.rb +75 -0
- data/lib/rails/commands/version/version_command.rb +12 -0
- data/lib/rails/commands.rb +18 -0
- data/lib/rails/configuration.rb +170 -0
- data/lib/rails/console/app.rb +8 -0
- data/lib/rails/console/helpers.rb +8 -0
- data/lib/rails/console/methods.rb +23 -0
- data/lib/rails/deprecator.rb +7 -0
- data/lib/rails/dev_caching.rb +44 -0
- data/lib/rails/engine/commands.rb +9 -0
- data/lib/rails/engine/configuration.rb +138 -0
- data/lib/rails/engine/lazy_route_set.rb +109 -0
- data/lib/rails/engine/railties.rb +23 -0
- data/lib/rails/engine/updater.rb +21 -0
- data/lib/rails/engine.rb +760 -0
- data/lib/rails/gem_version.rb +17 -0
- data/lib/rails/generators/actions/create_migration.rb +75 -0
- data/lib/rails/generators/actions.rb +528 -0
- data/lib/rails/generators/active_model.rb +94 -0
- data/lib/rails/generators/app_base.rb +806 -0
- data/lib/rails/generators/app_name.rb +39 -0
- data/lib/rails/generators/base.rb +432 -0
- data/lib/rails/generators/database.rb +287 -0
- data/lib/rails/generators/erb/authentication/authentication_generator.rb +15 -0
- data/lib/rails/generators/erb/authentication/templates/views/passwords/edit.html.erb +9 -0
- data/lib/rails/generators/erb/authentication/templates/views/passwords/new.html.erb +8 -0
- data/lib/rails/generators/erb/authentication/templates/views/sessions/new.html.erb +11 -0
- data/lib/rails/generators/erb/controller/controller_generator.rb +24 -0
- data/lib/rails/generators/erb/controller/templates/view.html.erb.tt +2 -0
- data/lib/rails/generators/erb/mailer/mailer_generator.rb +41 -0
- data/lib/rails/generators/erb/mailer/templates/layout.html.erb.tt +13 -0
- data/lib/rails/generators/erb/mailer/templates/layout.text.erb.tt +1 -0
- data/lib/rails/generators/erb/mailer/templates/view.html.erb.tt +5 -0
- data/lib/rails/generators/erb/mailer/templates/view.text.erb.tt +3 -0
- data/lib/rails/generators/erb/scaffold/scaffold_generator.rb +34 -0
- data/lib/rails/generators/erb/scaffold/templates/_form.html.erb.tt +37 -0
- data/lib/rails/generators/erb/scaffold/templates/edit.html.erb.tt +12 -0
- data/lib/rails/generators/erb/scaffold/templates/index.html.erb.tt +16 -0
- data/lib/rails/generators/erb/scaffold/templates/new.html.erb.tt +11 -0
- data/lib/rails/generators/erb/scaffold/templates/partial.html.erb.tt +17 -0
- data/lib/rails/generators/erb/scaffold/templates/show.html.erb.tt +10 -0
- data/lib/rails/generators/erb.rb +26 -0
- data/lib/rails/generators/generated_attribute.rb +274 -0
- data/lib/rails/generators/migration.rb +71 -0
- data/lib/rails/generators/model_helpers.rb +62 -0
- data/lib/rails/generators/named_base.rb +227 -0
- data/lib/rails/generators/rails/app/USAGE +31 -0
- data/lib/rails/generators/rails/app/app_generator.rb +678 -0
- data/lib/rails/generators/rails/app/templates/Dockerfile.tt +119 -0
- data/lib/rails/generators/rails/app/templates/Gemfile.tt +83 -0
- data/lib/rails/generators/rails/app/templates/README.md.tt +24 -0
- data/lib/rails/generators/rails/app/templates/Rakefile.tt +6 -0
- data/lib/rails/generators/rails/app/templates/app/assets/stylesheets/application.css.tt +15 -0
- data/lib/rails/generators/rails/app/templates/app/controllers/application_controller.rb.tt +6 -0
- data/lib/rails/generators/rails/app/templates/app/helpers/application_helper.rb.tt +2 -0
- data/lib/rails/generators/rails/app/templates/app/jobs/application_job.rb.tt +7 -0
- data/lib/rails/generators/rails/app/templates/app/mailers/application_mailer.rb.tt +4 -0
- data/lib/rails/generators/rails/app/templates/app/models/application_record.rb.tt +3 -0
- data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +33 -0
- data/lib/rails/generators/rails/app/templates/app/views/layouts/mailer.html.erb.tt +13 -0
- data/lib/rails/generators/rails/app/templates/app/views/layouts/mailer.text.erb.tt +1 -0
- data/lib/rails/generators/rails/app/templates/app/views/pwa/manifest.json.erb.tt +22 -0
- data/lib/rails/generators/rails/app/templates/app/views/pwa/service-worker.js +26 -0
- data/lib/rails/generators/rails/app/templates/bin/brakeman.tt +6 -0
- data/lib/rails/generators/rails/app/templates/bin/dev.tt +1 -0
- data/lib/rails/generators/rails/app/templates/bin/rails.tt +3 -0
- data/lib/rails/generators/rails/app/templates/bin/rake.tt +3 -0
- data/lib/rails/generators/rails/app/templates/bin/rubocop.tt +7 -0
- data/lib/rails/generators/rails/app/templates/bin/setup.tt +45 -0
- data/lib/rails/generators/rails/app/templates/bin/thrust.tt +4 -0
- data/lib/rails/generators/rails/app/templates/config/application.rb.tt +42 -0
- data/lib/rails/generators/rails/app/templates/config/boot.rb.tt +6 -0
- data/lib/rails/generators/rails/app/templates/config/cable.yml.tt +10 -0
- data/lib/rails/generators/rails/app/templates/config/databases/mysql.yml.tt +82 -0
- data/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml.tt +114 -0
- data/lib/rails/generators/rails/app/templates/config/databases/sqlite3.yml.tt +72 -0
- data/lib/rails/generators/rails/app/templates/config/databases/trilogy.yml.tt +82 -0
- data/lib/rails/generators/rails/app/templates/config/deploy.yml.tt +107 -0
- data/lib/rails/generators/rails/app/templates/config/environment.rb.tt +5 -0
- data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +89 -0
- data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +125 -0
- data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +62 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/assets.rb.tt +7 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/content_security_policy.rb.tt +25 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/cors.rb.tt +16 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/filter_parameter_logging.rb.tt +8 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/inflections.rb.tt +16 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_8_0.rb.tt +25 -0
- data/lib/rails/generators/rails/app/templates/config/locales/en.yml +31 -0
- data/lib/rails/generators/rails/app/templates/config/puma.rb.tt +43 -0
- data/lib/rails/generators/rails/app/templates/config/routes.rb.tt +16 -0
- data/lib/rails/generators/rails/app/templates/config/storage.yml.tt +34 -0
- data/lib/rails/generators/rails/app/templates/config.ru.tt +6 -0
- data/lib/rails/generators/rails/app/templates/db/seeds.rb.tt +9 -0
- data/lib/rails/generators/rails/app/templates/docker-entrypoint.tt +16 -0
- data/lib/rails/generators/rails/app/templates/dockerignore.tt +56 -0
- data/lib/rails/generators/rails/app/templates/env.erb.tt +5 -0
- data/lib/rails/generators/rails/app/templates/gitattributes.tt +9 -0
- data/lib/rails/generators/rails/app/templates/github/ci.yml.tt +138 -0
- data/lib/rails/generators/rails/app/templates/github/dependabot.yml +12 -0
- data/lib/rails/generators/rails/app/templates/gitignore.tt +38 -0
- data/lib/rails/generators/rails/app/templates/node-version.tt +1 -0
- data/lib/rails/generators/rails/app/templates/public/400.html +67 -0
- data/lib/rails/generators/rails/app/templates/public/404.html +67 -0
- data/lib/rails/generators/rails/app/templates/public/406-unsupported-browser.html +66 -0
- data/lib/rails/generators/rails/app/templates/public/422.html +67 -0
- data/lib/rails/generators/rails/app/templates/public/500.html +66 -0
- data/lib/rails/generators/rails/app/templates/public/icon.png +0 -0
- data/lib/rails/generators/rails/app/templates/public/icon.svg +3 -0
- data/lib/rails/generators/rails/app/templates/public/robots.txt +1 -0
- data/lib/rails/generators/rails/app/templates/rubocop.yml.tt +8 -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.tt +5 -0
- data/lib/rails/generators/rails/app/templates/test/test_helper.rb.tt +21 -0
- data/lib/rails/generators/rails/application_record/application_record_generator.rb +13 -0
- data/lib/rails/generators/rails/authentication/USAGE +6 -0
- data/lib/rails/generators/rails/authentication/authentication_generator.rb +54 -0
- data/lib/rails/generators/rails/authentication/templates/controllers/concerns/authentication.rb +55 -0
- data/lib/rails/generators/rails/authentication/templates/controllers/passwords_controller.rb +33 -0
- data/lib/rails/generators/rails/authentication/templates/controllers/sessions_controller.rb +21 -0
- data/lib/rails/generators/rails/authentication/templates/mailers/passwords_mailer.rb +6 -0
- data/lib/rails/generators/rails/authentication/templates/models/current.rb +4 -0
- data/lib/rails/generators/rails/authentication/templates/models/session.rb +3 -0
- data/lib/rails/generators/rails/authentication/templates/models/user.rb +6 -0
- data/lib/rails/generators/rails/authentication/templates/test/mailers/previews/passwords_mailer_preview.rb +7 -0
- data/lib/rails/generators/rails/authentication/templates/views/passwords_mailer/reset.html.erb +4 -0
- data/lib/rails/generators/rails/authentication/templates/views/passwords_mailer/reset.text.erb +2 -0
- data/lib/rails/generators/rails/benchmark/USAGE +19 -0
- data/lib/rails/generators/rails/benchmark/benchmark_generator.rb +30 -0
- data/lib/rails/generators/rails/benchmark/templates/benchmark.rb.tt +15 -0
- data/lib/rails/generators/rails/controller/USAGE +26 -0
- data/lib/rails/generators/rails/controller/controller_generator.rb +42 -0
- data/lib/rails/generators/rails/controller/templates/controller.rb.tt +9 -0
- data/lib/rails/generators/rails/credentials/credentials_generator.rb +61 -0
- data/lib/rails/generators/rails/credentials/templates/credentials.yml.tt +12 -0
- data/lib/rails/generators/rails/db/system/change/change_generator.rb +206 -0
- data/lib/rails/generators/rails/devcontainer/devcontainer_generator.rb +168 -0
- data/lib/rails/generators/rails/devcontainer/templates/devcontainer/Dockerfile.tt +3 -0
- data/lib/rails/generators/rails/devcontainer/templates/devcontainer/compose.yaml.tt +47 -0
- data/lib/rails/generators/rails/devcontainer/templates/devcontainer/devcontainer.json.tt +37 -0
- data/lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb +31 -0
- data/lib/rails/generators/rails/encryption_key_file/encryption_key_file_generator.rb +57 -0
- data/lib/rails/generators/rails/generator/USAGE +13 -0
- data/lib/rails/generators/rails/generator/generator_generator.rb +27 -0
- data/lib/rails/generators/rails/generator/templates/%file_name%_generator.rb.tt +3 -0
- data/lib/rails/generators/rails/generator/templates/USAGE.tt +8 -0
- data/lib/rails/generators/rails/generator/templates/templates/.empty_directory +0 -0
- data/lib/rails/generators/rails/helper/USAGE +12 -0
- data/lib/rails/generators/rails/helper/helper_generator.rb +20 -0
- data/lib/rails/generators/rails/helper/templates/helper.rb.tt +4 -0
- data/lib/rails/generators/rails/integration_test/USAGE +10 -0
- data/lib/rails/generators/rails/integration_test/integration_test_generator.rb +9 -0
- data/lib/rails/generators/rails/master_key/master_key_generator.rb +53 -0
- data/lib/rails/generators/rails/migration/USAGE +45 -0
- data/lib/rails/generators/rails/migration/migration_generator.rb +14 -0
- data/lib/rails/generators/rails/model/model_generator.rb +18 -0
- data/lib/rails/generators/rails/plugin/USAGE +21 -0
- data/lib/rails/generators/rails/plugin/plugin_generator.rb +499 -0
- data/lib/rails/generators/rails/plugin/templates/%name%.gemspec.tt +28 -0
- data/lib/rails/generators/rails/plugin/templates/Gemfile.tt +23 -0
- data/lib/rails/generators/rails/plugin/templates/MIT-LICENSE.tt +20 -0
- data/lib/rails/generators/rails/plugin/templates/README.md.tt +28 -0
- data/lib/rails/generators/rails/plugin/templates/Rakefile.tt +14 -0
- data/lib/rails/generators/rails/plugin/templates/app/controllers/%namespaced_name%/application_controller.rb.tt +5 -0
- data/lib/rails/generators/rails/plugin/templates/app/helpers/%namespaced_name%/application_helper.rb.tt +5 -0
- data/lib/rails/generators/rails/plugin/templates/app/jobs/%namespaced_name%/application_job.rb.tt +5 -0
- data/lib/rails/generators/rails/plugin/templates/app/mailers/%namespaced_name%/application_mailer.rb.tt +7 -0
- data/lib/rails/generators/rails/plugin/templates/app/models/%namespaced_name%/application_record.rb.tt +6 -0
- data/lib/rails/generators/rails/plugin/templates/app/views/layouts/%namespaced_name%/application.html.erb.tt +17 -0
- data/lib/rails/generators/rails/plugin/templates/bin/rails.tt +15 -0
- data/lib/rails/generators/rails/plugin/templates/bin/rubocop.tt +7 -0
- data/lib/rails/generators/rails/plugin/templates/bin/test.tt +4 -0
- data/lib/rails/generators/rails/plugin/templates/config/routes.rb.tt +6 -0
- data/lib/rails/generators/rails/plugin/templates/github/ci.yml.tt +103 -0
- data/lib/rails/generators/rails/plugin/templates/github/dependabot.yml +12 -0
- data/lib/rails/generators/rails/plugin/templates/gitignore.tt +14 -0
- data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/engine.rb.tt +7 -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.tt +1 -0
- data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%.rb.tt +8 -0
- data/lib/rails/generators/rails/plugin/templates/lib/tasks/%namespaced_name%_tasks.rake.tt +4 -0
- data/lib/rails/generators/rails/plugin/templates/rails/boot.rb.tt +5 -0
- data/lib/rails/generators/rails/plugin/templates/rails/routes.rb.tt +3 -0
- data/lib/rails/generators/rails/plugin/templates/rails/stylesheets.css +15 -0
- data/lib/rails/generators/rails/plugin/templates/rubocop.yml.tt +8 -0
- data/lib/rails/generators/rails/plugin/templates/test/%namespaced_name%_test.rb.tt +7 -0
- data/lib/rails/generators/rails/plugin/templates/test/application_system_test_case.rb.tt +5 -0
- data/lib/rails/generators/rails/plugin/templates/test/integration/navigation_test.rb.tt +7 -0
- data/lib/rails/generators/rails/plugin/templates/test/test_helper.rb.tt +21 -0
- data/lib/rails/generators/rails/resource/USAGE +23 -0
- data/lib/rails/generators/rails/resource/resource_generator.rb +27 -0
- data/lib/rails/generators/rails/resource_route/resource_route_generator.rb +23 -0
- data/lib/rails/generators/rails/scaffold/USAGE +41 -0
- data/lib/rails/generators/rails/scaffold/scaffold_generator.rb +18 -0
- data/lib/rails/generators/rails/scaffold_controller/USAGE +19 -0
- data/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb +56 -0
- data/lib/rails/generators/rails/scaffold_controller/templates/api_controller.rb.tt +57 -0
- data/lib/rails/generators/rails/scaffold_controller/templates/controller.rb.tt +64 -0
- data/lib/rails/generators/rails/script/USAGE +18 -0
- data/lib/rails/generators/rails/script/script_generator.rb +18 -0
- data/lib/rails/generators/rails/script/templates/script.rb.tt +3 -0
- data/lib/rails/generators/rails/system_test/USAGE +10 -0
- data/lib/rails/generators/rails/system_test/system_test_generator.rb +9 -0
- data/lib/rails/generators/rails/task/USAGE +9 -0
- data/lib/rails/generators/rails/task/task_generator.rb +13 -0
- data/lib/rails/generators/rails/task/templates/task.rb.tt +8 -0
- data/lib/rails/generators/resource_helpers.rb +82 -0
- data/lib/rails/generators/test_case.rb +37 -0
- data/lib/rails/generators/test_unit/controller/controller_generator.rb +19 -0
- data/lib/rails/generators/test_unit/controller/templates/functional_test.rb.tt +23 -0
- data/lib/rails/generators/test_unit/generator/generator_generator.rb +27 -0
- data/lib/rails/generators/test_unit/generator/templates/generator_test.rb.tt +16 -0
- data/lib/rails/generators/test_unit/helper/helper_generator.rb +11 -0
- data/lib/rails/generators/test_unit/integration/integration_generator.rb +20 -0
- data/lib/rails/generators/test_unit/integration/templates/integration_test.rb.tt +9 -0
- data/lib/rails/generators/test_unit/job/job_generator.rb +20 -0
- data/lib/rails/generators/test_unit/job/templates/unit_test.rb.tt +9 -0
- data/lib/rails/generators/test_unit/mailer/mailer_generator.rb +28 -0
- data/lib/rails/generators/test_unit/mailer/templates/functional_test.rb.tt +23 -0
- data/lib/rails/generators/test_unit/mailer/templates/preview.rb.tt +14 -0
- data/lib/rails/generators/test_unit/model/model_generator.rb +37 -0
- data/lib/rails/generators/test_unit/model/templates/fixtures.yml.tt +29 -0
- data/lib/rails/generators/test_unit/model/templates/unit_test.rb.tt +9 -0
- data/lib/rails/generators/test_unit/plugin/plugin_generator.rb +15 -0
- data/lib/rails/generators/test_unit/plugin/templates/%file_name%_test.rb.tt +7 -0
- data/lib/rails/generators/test_unit/plugin/templates/test_helper.rb +2 -0
- data/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb +82 -0
- data/lib/rails/generators/test_unit/scaffold/templates/api_functional_test.rb.tt +44 -0
- data/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb.tt +54 -0
- data/lib/rails/generators/test_unit/scaffold/templates/system_test.rb.tt +57 -0
- data/lib/rails/generators/test_unit/system/system_generator.rb +24 -0
- data/lib/rails/generators/test_unit/system/templates/application_system_test_case.rb.tt +5 -0
- data/lib/rails/generators/test_unit/system/templates/system_test.rb.tt +9 -0
- data/lib/rails/generators/test_unit.rb +10 -0
- data/lib/rails/generators/testing/assertions.rb +147 -0
- data/lib/rails/generators/testing/behavior.rb +116 -0
- data/lib/rails/generators/testing/setup_and_teardown.rb +20 -0
- data/lib/rails/generators.rb +327 -0
- data/lib/rails/health_controller.rb +55 -0
- data/lib/rails/info.rb +105 -0
- data/lib/rails/info_controller.rb +71 -0
- data/lib/rails/initializable.rb +95 -0
- data/lib/rails/mailers_controller.rb +122 -0
- data/lib/rails/paths.rb +246 -0
- data/lib/rails/plugin/test.rb +9 -0
- data/lib/rails/pwa_controller.rb +15 -0
- data/lib/rails/rack/logger.rb +88 -0
- data/lib/rails/rack/silence_request.rb +33 -0
- data/lib/rails/rack.rb +8 -0
- data/lib/rails/rackup/server.rb +15 -0
- data/lib/rails/railtie/configurable.rb +36 -0
- data/lib/rails/railtie/configuration.rb +114 -0
- data/lib/rails/railtie.rb +302 -0
- data/lib/rails/source_annotation_extractor.rb +214 -0
- data/lib/rails/tasks/engine.rake +85 -0
- data/lib/rails/tasks/framework.rake +34 -0
- data/lib/rails/tasks/log.rake +41 -0
- data/lib/rails/tasks/misc.rake +68 -0
- data/lib/rails/tasks/statistics.rake +23 -0
- data/lib/rails/tasks/tmp.rake +51 -0
- data/lib/rails/tasks/yarn.rake +29 -0
- data/lib/rails/tasks/zeitwerk.rake +41 -0
- data/lib/rails/tasks.rb +17 -0
- data/lib/rails/templates/layouts/application.html.erb +51 -0
- data/lib/rails/templates/rails/info/notes.html.erb +65 -0
- data/lib/rails/templates/rails/info/properties.html.erb +1 -0
- data/lib/rails/templates/rails/info/routes.html.erb +9 -0
- data/lib/rails/templates/rails/mailers/email.html.erb +201 -0
- data/lib/rails/templates/rails/mailers/index.html.erb +15 -0
- data/lib/rails/templates/rails/mailers/mailer.html.erb +12 -0
- data/lib/rails/templates/rails/welcome/index.html.erb +93 -0
- data/lib/rails/test_help.rb +47 -0
- data/lib/rails/test_unit/line_filtering.rb +13 -0
- data/lib/rails/test_unit/railtie.rb +25 -0
- data/lib/rails/test_unit/reporter.rb +121 -0
- data/lib/rails/test_unit/runner.rb +209 -0
- data/lib/rails/test_unit/test_parser.rb +133 -0
- data/lib/rails/test_unit/testing.rake +39 -0
- data/lib/rails/testing/maintain_test_schema.rb +16 -0
- data/lib/rails/version.rb +10 -0
- data/lib/rails/welcome_controller.rb +11 -0
- data/lib/rails/zeitwerk_checker.rb +15 -0
- data/lib/rails.rb +130 -0
- metadata +518 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/inflector"
|
4
|
+
|
5
|
+
module Rails
|
6
|
+
class Autoloaders
|
7
|
+
module Inflector # :nodoc:
|
8
|
+
# Concurrent::Map is not needed. This is a private class, and overrides
|
9
|
+
# must be defined while the application boots.
|
10
|
+
@overrides = {}
|
11
|
+
|
12
|
+
def self.camelize(basename, _abspath)
|
13
|
+
@overrides[basename] || basename.camelize
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.inflect(overrides)
|
17
|
+
@overrides.merge!(overrides)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rails
|
4
|
+
class Autoloaders # :nodoc:
|
5
|
+
require_relative "autoloaders/inflector"
|
6
|
+
|
7
|
+
include Enumerable
|
8
|
+
|
9
|
+
attr_reader :main, :once
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
# This `require` delays loading the library on purpose.
|
13
|
+
#
|
14
|
+
# In Rails 7.0.0, railties/lib/rails.rb loaded Zeitwerk as a side-effect,
|
15
|
+
# but a couple of edge cases related to Bundler and Bootsnap showed up.
|
16
|
+
# They had to do with order of decoration of `Kernel#require`, something
|
17
|
+
# the three of them do.
|
18
|
+
#
|
19
|
+
# Delaying this `require` up to this point is a convenient trade-off.
|
20
|
+
require "zeitwerk"
|
21
|
+
|
22
|
+
@main = Zeitwerk::Loader.new
|
23
|
+
@main.tag = "rails.main"
|
24
|
+
@main.inflector = Inflector
|
25
|
+
|
26
|
+
@once = Zeitwerk::Loader.new
|
27
|
+
@once.tag = "rails.once"
|
28
|
+
@once.inflector = Inflector
|
29
|
+
end
|
30
|
+
|
31
|
+
def each
|
32
|
+
yield main
|
33
|
+
yield once
|
34
|
+
end
|
35
|
+
|
36
|
+
def logger=(logger)
|
37
|
+
each { |loader| loader.logger = logger }
|
38
|
+
end
|
39
|
+
|
40
|
+
def log!
|
41
|
+
each(&:log!)
|
42
|
+
end
|
43
|
+
|
44
|
+
def zeitwerk_enabled?
|
45
|
+
true
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/backtrace_cleaner"
|
4
|
+
require "active_support/core_ext/string/access"
|
5
|
+
|
6
|
+
module Rails
|
7
|
+
class BacktraceCleaner < ActiveSupport::BacktraceCleaner # :nodoc:
|
8
|
+
APP_DIRS_PATTERN = /\A(?:\.\/)?(?:app|config|lib|test|\(\w*\))/
|
9
|
+
RENDER_TEMPLATE_PATTERN = /:in [`'].*_\w+_{2,3}\d+_\d+'/
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
super
|
13
|
+
add_filter do |line|
|
14
|
+
# We may be called before Rails.root is assigned.
|
15
|
+
# When that happens we fallback to not truncating.
|
16
|
+
@root ||= Rails.root && "#{Rails.root}/"
|
17
|
+
@root && line.start_with?(@root) ? line.from(@root.size) : line
|
18
|
+
end
|
19
|
+
add_filter do |line|
|
20
|
+
if RENDER_TEMPLATE_PATTERN.match?(line)
|
21
|
+
line.sub(RENDER_TEMPLATE_PATTERN, "")
|
22
|
+
else
|
23
|
+
line
|
24
|
+
end
|
25
|
+
end
|
26
|
+
add_silencer { |line| !APP_DIRS_PATTERN.match?(line) }
|
27
|
+
end
|
28
|
+
|
29
|
+
def clean(backtrace, kind = :silent)
|
30
|
+
kind = nil if ENV["BACKTRACE"]
|
31
|
+
|
32
|
+
super(backtrace, kind)
|
33
|
+
end
|
34
|
+
alias_method :filter, :clean
|
35
|
+
|
36
|
+
def clean_frame(frame, kind = :silent)
|
37
|
+
kind = nil if ENV["BACKTRACE"]
|
38
|
+
|
39
|
+
super(frame, kind)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/rails/cli.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rails/app_loader"
|
4
|
+
|
5
|
+
# If we are inside a Rails application this method performs an exec and thus
|
6
|
+
# the rest of this script is not run.
|
7
|
+
Rails::AppLoader.exec_app
|
8
|
+
|
9
|
+
Signal.trap("INT") { puts; exit(1) }
|
10
|
+
|
11
|
+
require "rails/command"
|
12
|
+
case ARGV.first
|
13
|
+
when Rails::Command::HELP_MAPPINGS, "help", nil
|
14
|
+
ARGV.shift
|
15
|
+
Rails::Command.invoke :gem_help, ARGV
|
16
|
+
when "plugin"
|
17
|
+
ARGV.shift
|
18
|
+
Rails::Command.invoke :plugin, ARGV
|
19
|
+
else
|
20
|
+
Rails::Command.invoke :application, ARGV
|
21
|
+
end
|
@@ -0,0 +1,159 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rails/code_statistics_calculator"
|
4
|
+
require "active_support/core_ext/enumerable"
|
5
|
+
|
6
|
+
module Rails
|
7
|
+
class CodeStatistics
|
8
|
+
DIRECTORIES = [
|
9
|
+
%w(Controllers app/controllers),
|
10
|
+
%w(Helpers app/helpers),
|
11
|
+
%w(Jobs app/jobs),
|
12
|
+
%w(Models app/models),
|
13
|
+
%w(Mailers app/mailers),
|
14
|
+
%w(Mailboxes app/mailboxes),
|
15
|
+
%w(Channels app/channels),
|
16
|
+
%w(Views app/views),
|
17
|
+
%w(JavaScripts app/assets/javascripts),
|
18
|
+
%w(Stylesheets app/assets/stylesheets),
|
19
|
+
%w(JavaScript app/javascript),
|
20
|
+
%w(Libraries lib/),
|
21
|
+
%w(APIs app/apis),
|
22
|
+
%w(Controller\ tests test/controllers),
|
23
|
+
%w(Helper\ tests test/helpers),
|
24
|
+
%w(Job\ tests test/jobs),
|
25
|
+
%w(Model\ tests test/models),
|
26
|
+
%w(Mailer\ tests test/mailers),
|
27
|
+
%w(Mailbox\ tests test/mailboxes),
|
28
|
+
%w(Channel\ tests test/channels),
|
29
|
+
%w(Integration\ tests test/integration),
|
30
|
+
%w(System\ tests test/system),
|
31
|
+
]
|
32
|
+
|
33
|
+
TEST_TYPES = ["Controller tests",
|
34
|
+
"Helper tests",
|
35
|
+
"Model tests",
|
36
|
+
"Mailer tests",
|
37
|
+
"Mailbox tests",
|
38
|
+
"Channel tests",
|
39
|
+
"Job tests",
|
40
|
+
"Integration tests",
|
41
|
+
"System tests"]
|
42
|
+
|
43
|
+
HEADERS = { lines: " Lines", code_lines: " LOC", classes: "Classes", methods: "Methods" }
|
44
|
+
|
45
|
+
class_attribute :directories, default: DIRECTORIES
|
46
|
+
class_attribute :test_types, default: TEST_TYPES
|
47
|
+
|
48
|
+
# Add directories to the output of the `bin/rails stats` command.
|
49
|
+
#
|
50
|
+
# Rails::CodeStatistics.register_directory("My Directory", "path/to/dir")
|
51
|
+
#
|
52
|
+
# For directories that contain test code, set the `test_directory` argument to true.
|
53
|
+
#
|
54
|
+
# Rails::CodeStatistics.register_directory("Model specs", "spec/models", test_directory: true)
|
55
|
+
def self.register_directory(label, path, test_directory: false)
|
56
|
+
self.directories << [label, path]
|
57
|
+
self.test_types << label if test_directory
|
58
|
+
end
|
59
|
+
|
60
|
+
def initialize(*pairs)
|
61
|
+
@pairs = pairs
|
62
|
+
@statistics = calculate_statistics
|
63
|
+
@total = calculate_total if pairs.length > 1
|
64
|
+
end
|
65
|
+
|
66
|
+
def to_s
|
67
|
+
print_header
|
68
|
+
@pairs.each { |pair| print_line(pair.first, @statistics[pair.first]) }
|
69
|
+
print_splitter
|
70
|
+
|
71
|
+
if @total
|
72
|
+
print_line("Total", @total)
|
73
|
+
print_splitter
|
74
|
+
end
|
75
|
+
|
76
|
+
print_code_test_stats
|
77
|
+
end
|
78
|
+
|
79
|
+
private
|
80
|
+
def calculate_statistics
|
81
|
+
Hash[@pairs.map { |pair| [pair.first, calculate_directory_statistics(pair.last)] }]
|
82
|
+
end
|
83
|
+
|
84
|
+
def calculate_directory_statistics(directory, pattern = /^(?!\.).*?\.(rb|js|ts|css|scss|coffee|rake|erb)$/)
|
85
|
+
stats = Rails::CodeStatisticsCalculator.new
|
86
|
+
|
87
|
+
Dir.foreach(directory) do |file_name|
|
88
|
+
path = "#{directory}/#{file_name}"
|
89
|
+
|
90
|
+
if File.directory?(path) && !file_name.start_with?(".")
|
91
|
+
stats.add(calculate_directory_statistics(path, pattern))
|
92
|
+
elsif file_name&.match?(pattern)
|
93
|
+
stats.add_by_file_path(path)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
stats
|
98
|
+
end
|
99
|
+
|
100
|
+
def calculate_total
|
101
|
+
@statistics.each_with_object(Rails::CodeStatisticsCalculator.new) do |pair, total|
|
102
|
+
total.add(pair.last)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def calculate_code
|
107
|
+
code_loc = 0
|
108
|
+
@statistics.each { |k, v| code_loc += v.code_lines unless test_types.include? k }
|
109
|
+
code_loc
|
110
|
+
end
|
111
|
+
|
112
|
+
def calculate_tests
|
113
|
+
test_loc = 0
|
114
|
+
@statistics.each { |k, v| test_loc += v.code_lines if test_types.include? k }
|
115
|
+
test_loc
|
116
|
+
end
|
117
|
+
|
118
|
+
def width_for(label)
|
119
|
+
[@statistics.values.sum { |s| s.public_send(label) }.to_s.size, HEADERS[label].length].max
|
120
|
+
end
|
121
|
+
|
122
|
+
def print_header
|
123
|
+
print_splitter
|
124
|
+
print "| Name "
|
125
|
+
HEADERS.each do |k, v|
|
126
|
+
print " | #{v.rjust(width_for(k))}"
|
127
|
+
end
|
128
|
+
puts " | M/C | LOC/M |"
|
129
|
+
print_splitter
|
130
|
+
end
|
131
|
+
|
132
|
+
def print_splitter
|
133
|
+
print "+----------------------"
|
134
|
+
HEADERS.each_key do |k|
|
135
|
+
print "+#{'-' * (width_for(k) + 2)}"
|
136
|
+
end
|
137
|
+
puts "+-----+-------+"
|
138
|
+
end
|
139
|
+
|
140
|
+
def print_line(name, statistics)
|
141
|
+
m_over_c = (statistics.methods / statistics.classes) rescue 0
|
142
|
+
loc_over_m = (statistics.code_lines / statistics.methods) - 2 rescue 0
|
143
|
+
|
144
|
+
print "| #{name.ljust(20)} "
|
145
|
+
HEADERS.each_key do |k|
|
146
|
+
print "| #{statistics.send(k).to_s.rjust(width_for(k))} "
|
147
|
+
end
|
148
|
+
puts "| #{m_over_c.to_s.rjust(3)} | #{loc_over_m.to_s.rjust(5)} |"
|
149
|
+
end
|
150
|
+
|
151
|
+
def print_code_test_stats
|
152
|
+
code = calculate_code
|
153
|
+
tests = calculate_tests
|
154
|
+
|
155
|
+
puts " Code LOC: #{code} Test LOC: #{tests} Code to Test Ratio: 1:#{sprintf("%.1f", tests.to_f / code)}"
|
156
|
+
puts ""
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rails
|
4
|
+
class CodeStatisticsCalculator # :nodoc:
|
5
|
+
attr_reader :lines, :code_lines, :classes, :methods
|
6
|
+
|
7
|
+
PATTERNS = {
|
8
|
+
rb: {
|
9
|
+
line_comment: /^\s*#/,
|
10
|
+
begin_block_comment: /^=begin/,
|
11
|
+
end_block_comment: /^=end/,
|
12
|
+
class: /^\s*class\s+[_A-Z]/,
|
13
|
+
method: /^\s*def\s+[_a-z]/,
|
14
|
+
},
|
15
|
+
erb: {
|
16
|
+
line_comment: %r{((^\s*<%#.*%>)|(<!--.*-->))},
|
17
|
+
},
|
18
|
+
css: {
|
19
|
+
line_comment: %r{^\s*/\*.*\*/},
|
20
|
+
},
|
21
|
+
scss: {
|
22
|
+
line_comment: %r{((^\s*/\*.*\*/)|(^\s*//))},
|
23
|
+
},
|
24
|
+
js: {
|
25
|
+
line_comment: %r{^\s*//},
|
26
|
+
begin_block_comment: %r{^\s*/\*},
|
27
|
+
end_block_comment: %r{\*/},
|
28
|
+
method: /function(\s+[_a-zA-Z][\da-zA-Z]*)?\s*\(/,
|
29
|
+
},
|
30
|
+
coffee: {
|
31
|
+
line_comment: /^\s*#/,
|
32
|
+
begin_block_comment: /^\s*###/,
|
33
|
+
end_block_comment: /^\s*###/,
|
34
|
+
class: /^\s*class\s+[_A-Z]/,
|
35
|
+
method: /[-=]>/,
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
39
|
+
PATTERNS[:minitest] = PATTERNS[:rb].merge method: /^\s*(def|test)\s+['"_a-z]/
|
40
|
+
PATTERNS[:rake] = PATTERNS[:rb]
|
41
|
+
|
42
|
+
def initialize(lines = 0, code_lines = 0, classes = 0, methods = 0)
|
43
|
+
@lines = lines
|
44
|
+
@code_lines = code_lines
|
45
|
+
@classes = classes
|
46
|
+
@methods = methods
|
47
|
+
end
|
48
|
+
|
49
|
+
def add(code_statistics_calculator)
|
50
|
+
@lines += code_statistics_calculator.lines
|
51
|
+
@code_lines += code_statistics_calculator.code_lines
|
52
|
+
@classes += code_statistics_calculator.classes
|
53
|
+
@methods += code_statistics_calculator.methods
|
54
|
+
end
|
55
|
+
|
56
|
+
def add_by_file_path(file_path)
|
57
|
+
File.open(file_path) do |f|
|
58
|
+
add_by_io(f, file_type(file_path))
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def add_by_io(io, file_type)
|
63
|
+
patterns = PATTERNS[file_type] || {}
|
64
|
+
|
65
|
+
comment_started = false
|
66
|
+
|
67
|
+
while line = io.gets
|
68
|
+
@lines += 1
|
69
|
+
|
70
|
+
if comment_started
|
71
|
+
if patterns[:end_block_comment] && patterns[:end_block_comment].match?(line)
|
72
|
+
comment_started = false
|
73
|
+
end
|
74
|
+
next
|
75
|
+
else
|
76
|
+
if patterns[:begin_block_comment] && patterns[:begin_block_comment].match?(line)
|
77
|
+
comment_started = true
|
78
|
+
next
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
@classes += 1 if patterns[:class] && patterns[:class].match?(line)
|
83
|
+
@methods += 1 if patterns[:method] && patterns[:method].match?(line)
|
84
|
+
if !line.match?(/^\s*$/) && (patterns[:line_comment].nil? || !line.match?(patterns[:line_comment]))
|
85
|
+
@code_lines += 1
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
private
|
91
|
+
def file_type(file_path)
|
92
|
+
if file_path.end_with? "_test.rb"
|
93
|
+
:minitest
|
94
|
+
else
|
95
|
+
File.extname(file_path).delete_prefix(".").downcase.to_sym
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rails
|
4
|
+
module Command
|
5
|
+
module Actions
|
6
|
+
# Change to the application's path if there is no <tt>config.ru</tt> file in current directory.
|
7
|
+
# This allows us to run <tt>rails server</tt> from other directories, but still get
|
8
|
+
# the main <tt>config.ru</tt> and properly set the <tt>tmp</tt> directory.
|
9
|
+
def set_application_directory!
|
10
|
+
Dir.chdir(File.expand_path("../..", APP_PATH)) unless File.exist?(File.expand_path("config.ru"))
|
11
|
+
end
|
12
|
+
|
13
|
+
def require_application!
|
14
|
+
require ENGINE_PATH if defined?(ENGINE_PATH)
|
15
|
+
require APP_PATH if defined?(APP_PATH)
|
16
|
+
end
|
17
|
+
|
18
|
+
def boot_application!
|
19
|
+
require_application!
|
20
|
+
Rails.application.require_environment! if defined?(APP_PATH)
|
21
|
+
end
|
22
|
+
|
23
|
+
def load_environment_config!
|
24
|
+
require_application!
|
25
|
+
# Only run initializers that are in the :all group, which includes the
|
26
|
+
# :load_environment_config initializer.
|
27
|
+
Rails.application.initialize!(:_) if defined?(APP_PATH)
|
28
|
+
end
|
29
|
+
|
30
|
+
if defined?(ENGINE_PATH)
|
31
|
+
def load_tasks
|
32
|
+
Rake.application.init("rails")
|
33
|
+
Rake.application.load_rakefile
|
34
|
+
end
|
35
|
+
|
36
|
+
def load_generators
|
37
|
+
engine = ::Rails::Engine.find(ENGINE_ROOT)
|
38
|
+
Rails::Generators.namespace = engine.railtie_namespace
|
39
|
+
engine.load_generators
|
40
|
+
end
|
41
|
+
else
|
42
|
+
def load_tasks
|
43
|
+
Rails.application.load_tasks
|
44
|
+
end
|
45
|
+
|
46
|
+
def load_generators
|
47
|
+
Rails.application.load_generators
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,185 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "thor"
|
4
|
+
require "erb"
|
5
|
+
|
6
|
+
require "active_support/core_ext/class/attribute"
|
7
|
+
require "active_support/core_ext/module/delegation"
|
8
|
+
require "active_support/core_ext/string/inflections"
|
9
|
+
|
10
|
+
require "rails/command/actions"
|
11
|
+
|
12
|
+
module Rails
|
13
|
+
module Command
|
14
|
+
class Base < Thor
|
15
|
+
class Error < Thor::Error # :nodoc:
|
16
|
+
end
|
17
|
+
|
18
|
+
include Actions
|
19
|
+
|
20
|
+
class_attribute :bin, instance_accessor: false, default: "bin/rails"
|
21
|
+
|
22
|
+
class << self
|
23
|
+
def exit_on_failure? # :nodoc:
|
24
|
+
false
|
25
|
+
end
|
26
|
+
|
27
|
+
# Returns true when the app is a \Rails engine.
|
28
|
+
def engine?
|
29
|
+
defined?(ENGINE_ROOT)
|
30
|
+
end
|
31
|
+
|
32
|
+
# Tries to get the description from a USAGE file one folder above the command
|
33
|
+
# root.
|
34
|
+
def desc(usage = nil, description = nil, options = {})
|
35
|
+
if usage
|
36
|
+
super
|
37
|
+
else
|
38
|
+
class_usage
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# Convenience method to get the namespace from the class name. It's the
|
43
|
+
# same as Thor default except that the Command at the end of the class
|
44
|
+
# is removed.
|
45
|
+
def namespace(name = nil)
|
46
|
+
if name
|
47
|
+
super
|
48
|
+
else
|
49
|
+
@namespace ||= super.chomp("_command").sub(/:command:/, ":")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# Convenience method to hide this command from the available ones when
|
54
|
+
# running rails command.
|
55
|
+
def hide_command!
|
56
|
+
Rails::Command.hidden_commands << self
|
57
|
+
end
|
58
|
+
|
59
|
+
def inherited(base) # :nodoc:
|
60
|
+
super
|
61
|
+
|
62
|
+
if base.name && !base.name.end_with?("Base")
|
63
|
+
Rails::Command.subclasses << base
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def perform(command, args, config) # :nodoc:
|
68
|
+
if Rails::Command::HELP_MAPPINGS.include?(args.first)
|
69
|
+
command, args = "help", [command]
|
70
|
+
args.clear if instance_method(:help).arity.zero?
|
71
|
+
end
|
72
|
+
|
73
|
+
dispatch(command, args.dup, nil, config)
|
74
|
+
end
|
75
|
+
|
76
|
+
def printing_commands
|
77
|
+
commands.filter_map do |name, command|
|
78
|
+
[namespaced_name(name), command.description] unless command.hidden?
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def executable(command_name = self.command_name)
|
83
|
+
"#{bin} #{namespaced_name(command_name)}"
|
84
|
+
end
|
85
|
+
|
86
|
+
def banner(command = nil, *)
|
87
|
+
if command
|
88
|
+
# Similar to Thor's banner, but show the namespace (minus the
|
89
|
+
# "rails:" prefix), and show the command's declared bin instead of
|
90
|
+
# the command runner.
|
91
|
+
command.formatted_usage(self).gsub(/^#{namespace}:(\w+)/) { executable($1) }
|
92
|
+
else
|
93
|
+
executable
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
# Override Thor's class-level help to also show the USAGE.
|
98
|
+
def help(shell, *) # :nodoc:
|
99
|
+
super
|
100
|
+
shell.say class_usage if class_usage
|
101
|
+
end
|
102
|
+
|
103
|
+
# Sets the base_name taking into account the current class namespace.
|
104
|
+
#
|
105
|
+
# Rails::Command::TestCommand.base_name # => 'rails'
|
106
|
+
def base_name
|
107
|
+
@base_name ||= if base = name.to_s.split("::").first
|
108
|
+
base.underscore
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
# Return command name without namespaces.
|
113
|
+
#
|
114
|
+
# Rails::Command::TestCommand.command_name # => 'test'
|
115
|
+
def command_name
|
116
|
+
@command_name ||= if command = name.to_s.split("::").last
|
117
|
+
command.chomp!("Command")
|
118
|
+
command.underscore
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def class_usage # :nodoc:
|
123
|
+
if usage_path
|
124
|
+
@class_usage ||= ERB.new(File.read(usage_path), trim_mode: "-").result(binding)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
# Path to lookup a USAGE description in a file.
|
129
|
+
def usage_path
|
130
|
+
@usage_path = resolve_path("USAGE") unless defined?(@usage_path)
|
131
|
+
@usage_path
|
132
|
+
end
|
133
|
+
|
134
|
+
# Default file root to place extra files a command might need, placed
|
135
|
+
# one folder above the command file.
|
136
|
+
#
|
137
|
+
# For a Rails::Command::TestCommand placed in <tt>rails/command/test_command.rb</tt>
|
138
|
+
# would return <tt>rails/test</tt>.
|
139
|
+
def default_command_root
|
140
|
+
@default_command_root = resolve_path(".") unless defined?(@default_command_root)
|
141
|
+
@default_command_root
|
142
|
+
end
|
143
|
+
|
144
|
+
private
|
145
|
+
# Allow the command method to be called perform.
|
146
|
+
def create_command(meth)
|
147
|
+
if meth == "perform"
|
148
|
+
alias_method command_name, meth
|
149
|
+
else
|
150
|
+
# Prevent exception about command without usage.
|
151
|
+
# Some commands define their documentation differently.
|
152
|
+
@usage ||= meth
|
153
|
+
@desc ||= ""
|
154
|
+
|
155
|
+
super
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
def namespaced_name(name)
|
160
|
+
*prefix, basename = namespace.delete_prefix("rails:").split(":")
|
161
|
+
prefix.concat([basename, name.to_s].uniq).join(":")
|
162
|
+
end
|
163
|
+
|
164
|
+
def resolve_path(path)
|
165
|
+
path = File.join("../commands", *namespace.delete_prefix("rails:").split(":"), path)
|
166
|
+
path = File.expand_path(path, __dir__)
|
167
|
+
path if File.exist?(path)
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
no_commands do
|
172
|
+
delegate :executable, to: :class
|
173
|
+
attr_reader :current_subcommand
|
174
|
+
|
175
|
+
def invoke_command(command, *) # :nodoc:
|
176
|
+
@current_subcommand ||= nil
|
177
|
+
original_subcommand, @current_subcommand = @current_subcommand, command.name
|
178
|
+
super
|
179
|
+
ensure
|
180
|
+
@current_subcommand = original_subcommand
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|