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,327 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "thor/group"
|
4
|
+
require "rails/command"
|
5
|
+
|
6
|
+
require "active_support/core_ext/array/extract_options"
|
7
|
+
require "active_support/core_ext/enumerable"
|
8
|
+
require "active_support/core_ext/hash/deep_merge"
|
9
|
+
require "active_support/core_ext/module/attribute_accessors"
|
10
|
+
require "active_support/core_ext/string/indent"
|
11
|
+
require "active_support/core_ext/string/inflections"
|
12
|
+
|
13
|
+
module Rails
|
14
|
+
module Generators
|
15
|
+
include Rails::Command::Behavior
|
16
|
+
|
17
|
+
autoload :Actions, "rails/generators/actions"
|
18
|
+
autoload :ActiveModel, "rails/generators/active_model"
|
19
|
+
autoload :Base, "rails/generators/base"
|
20
|
+
autoload :Migration, "rails/generators/migration"
|
21
|
+
autoload :Database, "rails/generators/database"
|
22
|
+
autoload :AppName, "rails/generators/app_name"
|
23
|
+
autoload :NamedBase, "rails/generators/named_base"
|
24
|
+
autoload :ResourceHelpers, "rails/generators/resource_helpers"
|
25
|
+
autoload :TestCase, "rails/generators/test_case"
|
26
|
+
|
27
|
+
mattr_accessor :namespace
|
28
|
+
|
29
|
+
DEFAULT_ALIASES = {
|
30
|
+
rails: {
|
31
|
+
actions: "-a",
|
32
|
+
orm: "-o",
|
33
|
+
javascripts: ["-j", "--js"],
|
34
|
+
resource_controller: "-c",
|
35
|
+
scaffold_controller: "-c",
|
36
|
+
stylesheets: "-y",
|
37
|
+
template_engine: "-e",
|
38
|
+
test_framework: "-t"
|
39
|
+
},
|
40
|
+
|
41
|
+
test_unit: {
|
42
|
+
fixture_replacement: "-r",
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
DEFAULT_OPTIONS = {
|
47
|
+
rails: {
|
48
|
+
api: false,
|
49
|
+
assets: true,
|
50
|
+
force_plural: false,
|
51
|
+
helper: true,
|
52
|
+
integration_tool: nil,
|
53
|
+
orm: false,
|
54
|
+
resource_controller: :controller,
|
55
|
+
resource_route: true,
|
56
|
+
scaffold_controller: :scaffold_controller,
|
57
|
+
system_tests: nil,
|
58
|
+
test_framework: nil,
|
59
|
+
template_engine: :erb
|
60
|
+
}
|
61
|
+
}
|
62
|
+
|
63
|
+
# We need to store the RAILS_DEV_PATH in a constant, otherwise the path
|
64
|
+
# can change when we FileUtils.cd.
|
65
|
+
RAILS_DEV_PATH = File.expand_path("../../..", __dir__) # :nodoc:
|
66
|
+
|
67
|
+
class << self
|
68
|
+
def configure!(config) # :nodoc:
|
69
|
+
api_only! if config.api_only
|
70
|
+
no_color! unless config.colorize_logging
|
71
|
+
aliases.deep_merge! config.aliases
|
72
|
+
options.deep_merge! config.options
|
73
|
+
fallbacks.merge! config.fallbacks
|
74
|
+
templates_path.concat config.templates
|
75
|
+
templates_path.uniq!
|
76
|
+
hide_namespaces(*config.hidden_namespaces)
|
77
|
+
after_generate_callbacks.replace config.after_generate_callbacks
|
78
|
+
end
|
79
|
+
|
80
|
+
def templates_path # :nodoc:
|
81
|
+
@templates_path ||= []
|
82
|
+
end
|
83
|
+
|
84
|
+
def aliases # :nodoc:
|
85
|
+
@aliases ||= DEFAULT_ALIASES.dup
|
86
|
+
end
|
87
|
+
|
88
|
+
def options # :nodoc:
|
89
|
+
@options ||= DEFAULT_OPTIONS.dup
|
90
|
+
end
|
91
|
+
|
92
|
+
def after_generate_callbacks # :nodoc:
|
93
|
+
@after_generate_callbacks ||= []
|
94
|
+
end
|
95
|
+
|
96
|
+
# Hold configured generators fallbacks. If a plugin developer wants a
|
97
|
+
# generator group to fall back to another group in case of missing generators,
|
98
|
+
# they can add a fallback.
|
99
|
+
#
|
100
|
+
# For example, shoulda is considered a test_framework and is an extension
|
101
|
+
# of test_unit. However, most part of shoulda generators are similar to
|
102
|
+
# test_unit ones.
|
103
|
+
#
|
104
|
+
# Shoulda then can tell generators to search for test_unit generators when
|
105
|
+
# some of them are not available by adding a fallback:
|
106
|
+
#
|
107
|
+
# Rails::Generators.fallbacks[:shoulda] = :test_unit
|
108
|
+
def fallbacks
|
109
|
+
@fallbacks ||= {}
|
110
|
+
end
|
111
|
+
|
112
|
+
# Configure generators for API only applications. It basically hides
|
113
|
+
# everything that is usually browser related, such as assets and session
|
114
|
+
# migration generators, and completely disable helpers and assets
|
115
|
+
# so generators such as scaffold won't create them.
|
116
|
+
def api_only!
|
117
|
+
hide_namespaces "assets", "helper", "css", "js"
|
118
|
+
|
119
|
+
options[:rails].merge!(
|
120
|
+
api: true,
|
121
|
+
assets: false,
|
122
|
+
helper: false,
|
123
|
+
template_engine: nil
|
124
|
+
)
|
125
|
+
|
126
|
+
options[:mailer] ||= {}
|
127
|
+
options[:mailer][:template_engine] ||= :erb
|
128
|
+
end
|
129
|
+
|
130
|
+
# Returns an array of generator namespaces that are hidden.
|
131
|
+
# Generator namespaces may be hidden for a variety of reasons.
|
132
|
+
# Some are aliased such as "rails:migration" and can be
|
133
|
+
# invoked with the shorter "migration".
|
134
|
+
def hidden_namespaces
|
135
|
+
@hidden_namespaces ||= begin
|
136
|
+
orm = options[:rails][:orm]
|
137
|
+
test = options[:rails][:test_framework]
|
138
|
+
template = options[:rails][:template_engine]
|
139
|
+
|
140
|
+
[
|
141
|
+
"rails",
|
142
|
+
"resource_route",
|
143
|
+
"#{orm}:migration",
|
144
|
+
"#{orm}:model",
|
145
|
+
"#{test}:controller",
|
146
|
+
"#{test}:helper",
|
147
|
+
"#{test}:integration",
|
148
|
+
"#{test}:system",
|
149
|
+
"#{test}:mailer",
|
150
|
+
"#{test}:model",
|
151
|
+
"#{test}:scaffold",
|
152
|
+
"#{test}:view",
|
153
|
+
"#{test}:job",
|
154
|
+
"#{template}:controller",
|
155
|
+
"#{template}:scaffold",
|
156
|
+
"#{template}:mailer",
|
157
|
+
"action_text:install",
|
158
|
+
"action_mailbox:install",
|
159
|
+
"devcontainer"
|
160
|
+
]
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
def hide_namespaces(*namespaces)
|
165
|
+
hidden_namespaces.concat(namespaces)
|
166
|
+
end
|
167
|
+
alias hide_namespace hide_namespaces
|
168
|
+
|
169
|
+
# Show help message with available generators.
|
170
|
+
def help(command = "generate")
|
171
|
+
puts "Usage:"
|
172
|
+
puts " bin/rails #{command} GENERATOR [args] [options]"
|
173
|
+
puts
|
174
|
+
puts "General options:"
|
175
|
+
puts " -h, [--help] # Print generator's options and usage"
|
176
|
+
puts " -p, [--pretend] # Run but do not make any changes"
|
177
|
+
puts " -f, [--force] # Overwrite files that already exist"
|
178
|
+
puts " -s, [--skip] # Skip files that already exist"
|
179
|
+
puts " -q, [--quiet] # Suppress status output"
|
180
|
+
puts
|
181
|
+
puts "Please choose a generator below."
|
182
|
+
puts
|
183
|
+
|
184
|
+
print_generators
|
185
|
+
end
|
186
|
+
|
187
|
+
def public_namespaces
|
188
|
+
lookup!
|
189
|
+
subclasses.map(&:namespace)
|
190
|
+
end
|
191
|
+
|
192
|
+
def print_generators
|
193
|
+
sorted_groups.each { |b, n| print_list(b, n) }
|
194
|
+
end
|
195
|
+
|
196
|
+
def sorted_groups
|
197
|
+
namespaces = public_namespaces
|
198
|
+
namespaces.sort!
|
199
|
+
|
200
|
+
groups = Hash.new { |h, k| h[k] = [] }
|
201
|
+
namespaces.each do |namespace|
|
202
|
+
base = namespace.split(":").first
|
203
|
+
groups[base] << namespace
|
204
|
+
end
|
205
|
+
|
206
|
+
rails = groups.delete("rails")
|
207
|
+
rails.map! { |n| n.delete_prefix("rails:") }
|
208
|
+
rails.delete("app")
|
209
|
+
rails.delete("plugin")
|
210
|
+
rails.delete("encrypted_file")
|
211
|
+
rails.delete("encryption_key_file")
|
212
|
+
rails.delete("master_key")
|
213
|
+
rails.delete("credentials")
|
214
|
+
rails.delete("db:system:change")
|
215
|
+
|
216
|
+
hidden_namespaces.each { |n| groups.delete(n.to_s) }
|
217
|
+
|
218
|
+
[[ "rails", rails ]] + groups.sort.to_a
|
219
|
+
end
|
220
|
+
|
221
|
+
# Rails finds namespaces similar to Thor, it only adds one rule:
|
222
|
+
#
|
223
|
+
# Generators names must end with "_generator.rb". This is required because Rails
|
224
|
+
# looks in load paths and loads the generator just before it's going to be used.
|
225
|
+
#
|
226
|
+
# find_by_namespace :webrat, :rails, :integration
|
227
|
+
#
|
228
|
+
# Will search for the following generators:
|
229
|
+
#
|
230
|
+
# "rails:webrat", "webrat:integration", "webrat"
|
231
|
+
#
|
232
|
+
# Notice that "rails:generators:webrat" could be loaded as well, what
|
233
|
+
# Rails looks for is the first and last parts of the namespace.
|
234
|
+
def find_by_namespace(name, base = nil, context = nil) # :nodoc:
|
235
|
+
lookups = []
|
236
|
+
lookups << "#{base}:#{name}" if base
|
237
|
+
lookups << "#{name}:#{context}" if context
|
238
|
+
|
239
|
+
unless base || context
|
240
|
+
unless name.to_s.include?(?:)
|
241
|
+
lookups << "#{name}:#{name}"
|
242
|
+
lookups << "rails:#{name}"
|
243
|
+
end
|
244
|
+
lookups << "#{name}"
|
245
|
+
end
|
246
|
+
|
247
|
+
lookup(lookups)
|
248
|
+
|
249
|
+
namespaces = subclasses.index_by(&:namespace)
|
250
|
+
lookups.each do |namespace|
|
251
|
+
klass = namespaces[namespace]
|
252
|
+
return klass if klass
|
253
|
+
end
|
254
|
+
|
255
|
+
invoke_fallbacks_for(name, base) || invoke_fallbacks_for(context, name)
|
256
|
+
end
|
257
|
+
|
258
|
+
# Receives a namespace, arguments, and the behavior to invoke the generator.
|
259
|
+
# It's used as the default entry point for generate, destroy, and update
|
260
|
+
# commands.
|
261
|
+
def invoke(namespace, args = ARGV, config = {})
|
262
|
+
names = namespace.to_s.split(":")
|
263
|
+
if klass = find_by_namespace(names.pop, names.any? && names.join(":"))
|
264
|
+
args << "--help" if args.empty? && klass.arguments.any?(&:required?)
|
265
|
+
klass.start(args, config)
|
266
|
+
run_after_generate_callback if config[:behavior] == :invoke
|
267
|
+
else
|
268
|
+
options = sorted_groups.flat_map(&:last)
|
269
|
+
error = Command::CorrectableNameError.new("Could not find generator '#{namespace}'.", namespace, options)
|
270
|
+
|
271
|
+
puts <<~MSG
|
272
|
+
#{error.detailed_message}
|
273
|
+
Run `bin/rails generate --help` for more options.
|
274
|
+
MSG
|
275
|
+
end
|
276
|
+
end
|
277
|
+
|
278
|
+
def add_generated_file(file) # :nodoc:
|
279
|
+
(@@generated_files ||= []) << file
|
280
|
+
file
|
281
|
+
end
|
282
|
+
|
283
|
+
private
|
284
|
+
def print_list(base, namespaces) # :doc:
|
285
|
+
namespaces = namespaces.reject { |n| hidden_namespaces.include?(n) }
|
286
|
+
super
|
287
|
+
end
|
288
|
+
|
289
|
+
# Try fallbacks for the given base.
|
290
|
+
def invoke_fallbacks_for(name, base)
|
291
|
+
return nil unless base && fallbacks[base.to_sym]
|
292
|
+
invoked_fallbacks = []
|
293
|
+
|
294
|
+
Array(fallbacks[base.to_sym]).each do |fallback|
|
295
|
+
next if invoked_fallbacks.include?(fallback)
|
296
|
+
invoked_fallbacks << fallback
|
297
|
+
|
298
|
+
klass = find_by_namespace(name, fallback)
|
299
|
+
return klass if klass
|
300
|
+
end
|
301
|
+
|
302
|
+
nil
|
303
|
+
end
|
304
|
+
|
305
|
+
def command_type # :doc:
|
306
|
+
@command_type ||= "generator"
|
307
|
+
end
|
308
|
+
|
309
|
+
def lookup_paths # :doc:
|
310
|
+
@lookup_paths ||= %w( rails/generators generators )
|
311
|
+
end
|
312
|
+
|
313
|
+
def file_lookup_paths # :doc:
|
314
|
+
@file_lookup_paths ||= [ "{#{lookup_paths.join(',')}}", "**", "*_generator.rb" ]
|
315
|
+
end
|
316
|
+
|
317
|
+
def run_after_generate_callback
|
318
|
+
if defined?(@@generated_files) && !@@generated_files.empty?
|
319
|
+
@after_generate_callbacks.each do |callback|
|
320
|
+
callback.call(@@generated_files)
|
321
|
+
end
|
322
|
+
@@generated_files = []
|
323
|
+
end
|
324
|
+
end
|
325
|
+
end
|
326
|
+
end
|
327
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rails
|
4
|
+
# Built-in Health Check Endpoint
|
5
|
+
#
|
6
|
+
# \Rails also comes with a built-in health check endpoint that is reachable at
|
7
|
+
# the +/up+ path. This endpoint will return a 200 status code if the app has
|
8
|
+
# booted with no exceptions, and a 500 status code otherwise.
|
9
|
+
#
|
10
|
+
# In production, many applications are required to report their status upstream,
|
11
|
+
# whether it's to an uptime monitor that will page an engineer when things go
|
12
|
+
# wrong, or a load balancer or Kubernetes controller used to determine a pod's
|
13
|
+
# health. This health check is designed to be a one-size fits all that will work
|
14
|
+
# in many situations.
|
15
|
+
#
|
16
|
+
# While any newly generated \Rails applications will have the health check at
|
17
|
+
# +/up+, you can configure the path to be anything you'd like in your
|
18
|
+
# <tt>"config/routes.rb"</tt>:
|
19
|
+
#
|
20
|
+
# Rails.application.routes.draw do
|
21
|
+
# get "healthz" => "rails/health#show", as: :rails_health_check
|
22
|
+
# end
|
23
|
+
#
|
24
|
+
# The health check will now be accessible via the +/healthz+ path.
|
25
|
+
#
|
26
|
+
# NOTE: This endpoint does not reflect the status of all of your application's
|
27
|
+
# dependencies, such as the database or Redis cluster. Replace
|
28
|
+
# <tt>"rails/health#show"</tt> with your own controller action if you have
|
29
|
+
# application specific needs.
|
30
|
+
#
|
31
|
+
# Think carefully about what you want to check as it can lead to situations
|
32
|
+
# where your application is being restarted due to a third-party service going
|
33
|
+
# bad. Ideally, you should design your application to handle those outages
|
34
|
+
# gracefully.
|
35
|
+
class HealthController < ActionController::Base
|
36
|
+
rescue_from(Exception) { render_down }
|
37
|
+
|
38
|
+
def show
|
39
|
+
render_up
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
def render_up
|
44
|
+
render html: html_status(color: "green")
|
45
|
+
end
|
46
|
+
|
47
|
+
def render_down
|
48
|
+
render html: html_status(color: "red"), status: 500
|
49
|
+
end
|
50
|
+
|
51
|
+
def html_status(color:)
|
52
|
+
%(<!DOCTYPE html><html><body style="background-color: #{color}"></body></html>).html_safe
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/lib/rails/info.rb
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "cgi"
|
4
|
+
|
5
|
+
module Rails
|
6
|
+
# This module helps build the runtime properties that are displayed in
|
7
|
+
# Rails::InfoController responses. These include the active \Rails version,
|
8
|
+
# Ruby version, Rack version, and so on.
|
9
|
+
module Info
|
10
|
+
mattr_accessor :properties, default: []
|
11
|
+
|
12
|
+
class << @@properties
|
13
|
+
def names
|
14
|
+
map(&:first)
|
15
|
+
end
|
16
|
+
|
17
|
+
def value_for(property_name)
|
18
|
+
if property = assoc(property_name)
|
19
|
+
property.last
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class << self # :nodoc:
|
25
|
+
def property(name, value = nil)
|
26
|
+
value ||= yield
|
27
|
+
properties << [name, value] if value
|
28
|
+
rescue Exception
|
29
|
+
end
|
30
|
+
|
31
|
+
def to_s
|
32
|
+
column_width = properties.names.map(&:length).max
|
33
|
+
info = properties.map do |name, value|
|
34
|
+
value = value.join(", ") if value.is_a?(Array)
|
35
|
+
"%-#{column_width}s %s" % [name, value]
|
36
|
+
end
|
37
|
+
info.unshift "About your application's environment"
|
38
|
+
info * "\n"
|
39
|
+
end
|
40
|
+
|
41
|
+
alias inspect to_s
|
42
|
+
|
43
|
+
def to_html
|
44
|
+
(+"<table>").tap do |table|
|
45
|
+
properties.each do |(name, value)|
|
46
|
+
table << %(<tr><td class="name">#{CGI.escapeHTML(name.to_s)}</td>)
|
47
|
+
formatted_value = if value.kind_of?(Array)
|
48
|
+
"<ul>" + value.map { |v| "<li>#{CGI.escapeHTML(v.to_s)}</li>" }.join + "</ul>"
|
49
|
+
else
|
50
|
+
CGI.escapeHTML(value.to_s)
|
51
|
+
end
|
52
|
+
table << %(<td class="value">#{formatted_value}</td></tr>)
|
53
|
+
end
|
54
|
+
table << "</table>"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# The Rails version.
|
60
|
+
property "Rails version" do
|
61
|
+
Rails.version.to_s
|
62
|
+
end
|
63
|
+
|
64
|
+
# The Ruby version and platform, e.g. "2.0.0-p247 (x86_64-darwin12.4.0)".
|
65
|
+
property "Ruby version" do
|
66
|
+
RUBY_DESCRIPTION
|
67
|
+
end
|
68
|
+
|
69
|
+
# The RubyGems version, if it's installed.
|
70
|
+
property "RubyGems version" do
|
71
|
+
Gem::VERSION
|
72
|
+
end
|
73
|
+
|
74
|
+
property "Rack version" do
|
75
|
+
::Rack.release
|
76
|
+
end
|
77
|
+
|
78
|
+
property "JavaScript Runtime" do
|
79
|
+
ExecJS.runtime.name
|
80
|
+
end
|
81
|
+
|
82
|
+
property "Middleware" do
|
83
|
+
Rails.configuration.middleware.map(&:inspect)
|
84
|
+
end
|
85
|
+
|
86
|
+
# The application's location on the filesystem.
|
87
|
+
property "Application root" do
|
88
|
+
File.expand_path(Rails.root)
|
89
|
+
end
|
90
|
+
|
91
|
+
# The current Rails environment (development, test, or production).
|
92
|
+
property "Environment" do
|
93
|
+
Rails.env
|
94
|
+
end
|
95
|
+
|
96
|
+
# The name of the database adapter for the current environment.
|
97
|
+
property "Database adapter" do
|
98
|
+
ActiveRecord::Base.connection_pool.db_config.adapter
|
99
|
+
end
|
100
|
+
|
101
|
+
property "Database schema version" do
|
102
|
+
ActiveRecord::Base.connection_pool.migration_context.current_version rescue nil
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rails/application_controller"
|
4
|
+
require "action_dispatch/routing/inspector"
|
5
|
+
|
6
|
+
class Rails::InfoController < Rails::ApplicationController # :nodoc:
|
7
|
+
prepend_view_path ActionDispatch::DebugView::RESCUES_TEMPLATE_PATHS
|
8
|
+
layout -> { request.xhr? ? false : "application" }
|
9
|
+
|
10
|
+
before_action :require_local!
|
11
|
+
|
12
|
+
def index
|
13
|
+
redirect_to action: :routes
|
14
|
+
end
|
15
|
+
|
16
|
+
def properties
|
17
|
+
@info = Rails::Info.to_html
|
18
|
+
@page_title = "Properties"
|
19
|
+
end
|
20
|
+
|
21
|
+
def routes
|
22
|
+
if query = params[:query]
|
23
|
+
query = URI::RFC2396_PARSER.escape query
|
24
|
+
|
25
|
+
render json: {
|
26
|
+
exact: matching_routes(query: query, exact_match: true),
|
27
|
+
fuzzy: matching_routes(query: query, exact_match: false)
|
28
|
+
}
|
29
|
+
else
|
30
|
+
@routes_inspector = ActionDispatch::Routing::RoutesInspector.new(_routes.routes)
|
31
|
+
@page_title = "Routes"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def notes
|
36
|
+
@annotations = Rails::SourceAnnotationExtractor.new(
|
37
|
+
Rails::SourceAnnotationExtractor::Annotation.tags.join("|")
|
38
|
+
).find(
|
39
|
+
Rails::SourceAnnotationExtractor::Annotation.directories
|
40
|
+
)
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
def matching_routes(query:, exact_match:)
|
45
|
+
return [] if query.blank?
|
46
|
+
|
47
|
+
normalized_path = ("/" + query).squeeze("/")
|
48
|
+
query_without_url_or_path_suffix = query.gsub(/(\w)(_path$)/, '\1').gsub(/(\w)(_url$)/, '\1')
|
49
|
+
|
50
|
+
_routes.routes.filter_map do |route|
|
51
|
+
route_wrapper = ActionDispatch::Routing::RouteWrapper.new(route)
|
52
|
+
|
53
|
+
if exact_match
|
54
|
+
match = route.path.match(normalized_path)
|
55
|
+
match ||= (query_without_url_or_path_suffix === route_wrapper.name)
|
56
|
+
else
|
57
|
+
match = route_wrapper.path.match(query)
|
58
|
+
match ||= route_wrapper.name.include?(query_without_url_or_path_suffix)
|
59
|
+
end
|
60
|
+
|
61
|
+
match ||= (query === route_wrapper.verb)
|
62
|
+
|
63
|
+
unless match
|
64
|
+
controller_action = URI::RFC2396_PARSER.escape(route_wrapper.reqs)
|
65
|
+
match = exact_match ? (query === controller_action) : controller_action.include?(query)
|
66
|
+
end
|
67
|
+
|
68
|
+
route_wrapper.path if match
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "tsort"
|
4
|
+
|
5
|
+
module Rails
|
6
|
+
module Initializable
|
7
|
+
def self.included(base) # :nodoc:
|
8
|
+
base.extend ClassMethods
|
9
|
+
end
|
10
|
+
|
11
|
+
class Initializer
|
12
|
+
attr_reader :name, :block
|
13
|
+
|
14
|
+
def initialize(name, context, options, &block)
|
15
|
+
options[:group] ||= :default
|
16
|
+
@name, @context, @options, @block = name, context, options, block
|
17
|
+
end
|
18
|
+
|
19
|
+
def before
|
20
|
+
@options[:before]
|
21
|
+
end
|
22
|
+
|
23
|
+
def after
|
24
|
+
@options[:after]
|
25
|
+
end
|
26
|
+
|
27
|
+
def belongs_to?(group)
|
28
|
+
@options[:group] == group || @options[:group] == :all
|
29
|
+
end
|
30
|
+
|
31
|
+
def run(*args)
|
32
|
+
@context.instance_exec(*args, &block)
|
33
|
+
end
|
34
|
+
|
35
|
+
def bind(context)
|
36
|
+
return self if @context
|
37
|
+
Initializer.new(@name, context, @options, &block)
|
38
|
+
end
|
39
|
+
|
40
|
+
def context_class
|
41
|
+
@context.class
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
class Collection < Array
|
46
|
+
include TSort
|
47
|
+
|
48
|
+
alias :tsort_each_node :each
|
49
|
+
def tsort_each_child(initializer, &block)
|
50
|
+
select { |i| i.before == initializer.name || i.name == initializer.after }.each(&block)
|
51
|
+
end
|
52
|
+
|
53
|
+
def +(other)
|
54
|
+
Collection.new(to_a + other.to_a)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def run_initializers(group = :default, *args)
|
59
|
+
return if instance_variable_defined?(:@ran)
|
60
|
+
initializers.tsort_each do |initializer|
|
61
|
+
initializer.run(*args) if initializer.belongs_to?(group)
|
62
|
+
end
|
63
|
+
@ran = true
|
64
|
+
end
|
65
|
+
|
66
|
+
def initializers
|
67
|
+
@initializers ||= self.class.initializers_for(self)
|
68
|
+
end
|
69
|
+
|
70
|
+
module ClassMethods
|
71
|
+
def initializers
|
72
|
+
@initializers ||= Collection.new
|
73
|
+
end
|
74
|
+
|
75
|
+
def initializers_chain
|
76
|
+
initializers = Collection.new
|
77
|
+
ancestors.reverse_each do |klass|
|
78
|
+
next unless klass.respond_to?(:initializers)
|
79
|
+
initializers = initializers + klass.initializers
|
80
|
+
end
|
81
|
+
initializers
|
82
|
+
end
|
83
|
+
|
84
|
+
def initializers_for(binding)
|
85
|
+
Collection.new(initializers_chain.map { |i| i.bind(binding) })
|
86
|
+
end
|
87
|
+
|
88
|
+
def initializer(name, opts = {}, &blk)
|
89
|
+
raise ArgumentError, "A block must be passed when defining an initializer" unless blk
|
90
|
+
opts[:after] ||= initializers.last.name unless initializers.empty? || initializers.find { |i| i.name == opts[:before] }
|
91
|
+
initializers << Initializer.new(name, nil, opts, &blk)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|