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,274 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/time"
|
4
|
+
require "active_support/core_ext/string/starts_ends_with"
|
5
|
+
|
6
|
+
module Rails
|
7
|
+
module Generators
|
8
|
+
class GeneratedAttribute # :nodoc:
|
9
|
+
INDEX_OPTIONS = %w(index uniq)
|
10
|
+
UNIQ_INDEX_OPTIONS = %w(uniq)
|
11
|
+
DEFAULT_TYPES = %w(
|
12
|
+
attachment
|
13
|
+
attachments
|
14
|
+
belongs_to
|
15
|
+
boolean
|
16
|
+
date
|
17
|
+
datetime
|
18
|
+
decimal
|
19
|
+
digest
|
20
|
+
float
|
21
|
+
integer
|
22
|
+
references
|
23
|
+
rich_text
|
24
|
+
string
|
25
|
+
text
|
26
|
+
time
|
27
|
+
timestamp
|
28
|
+
token
|
29
|
+
)
|
30
|
+
|
31
|
+
attr_accessor :name, :type
|
32
|
+
attr_reader :attr_options
|
33
|
+
attr_writer :index_name
|
34
|
+
|
35
|
+
class << self
|
36
|
+
def parse(column_definition)
|
37
|
+
name, type, index_type = column_definition.split(":")
|
38
|
+
|
39
|
+
# if user provided "name:index" instead of "name:string:index"
|
40
|
+
# type should be set blank so GeneratedAttribute's constructor
|
41
|
+
# could set it to :string
|
42
|
+
index_type, type = type, nil if valid_index_type?(type)
|
43
|
+
|
44
|
+
type, attr_options = *parse_type_and_options(type)
|
45
|
+
type = type.to_sym if type
|
46
|
+
|
47
|
+
if dangerous_name?(name)
|
48
|
+
raise Error, "Could not generate field '#{name}', as it is already defined by Active Record."
|
49
|
+
end
|
50
|
+
|
51
|
+
if type && !valid_type?(type)
|
52
|
+
raise Error, "Could not generate field '#{name}' with unknown type '#{type}'."
|
53
|
+
end
|
54
|
+
|
55
|
+
if index_type && !valid_index_type?(index_type)
|
56
|
+
raise Error, "Could not generate field '#{name}' with unknown index '#{index_type}'."
|
57
|
+
end
|
58
|
+
|
59
|
+
if type && reference?(type)
|
60
|
+
if UNIQ_INDEX_OPTIONS.include?(index_type)
|
61
|
+
attr_options[:index] = { unique: true }
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
new(name, type, index_type, attr_options)
|
66
|
+
end
|
67
|
+
|
68
|
+
def dangerous_name?(name)
|
69
|
+
defined?(ActiveRecord::Base) &&
|
70
|
+
ActiveRecord::Base.dangerous_attribute_method?(name)
|
71
|
+
end
|
72
|
+
|
73
|
+
def valid_type?(type)
|
74
|
+
DEFAULT_TYPES.include?(type.to_s) ||
|
75
|
+
!defined?(ActiveRecord::Base) ||
|
76
|
+
ActiveRecord::Base.lease_connection.valid_type?(type)
|
77
|
+
end
|
78
|
+
|
79
|
+
def valid_index_type?(index_type)
|
80
|
+
INDEX_OPTIONS.include?(index_type.to_s)
|
81
|
+
end
|
82
|
+
|
83
|
+
def reference?(type)
|
84
|
+
[:references, :belongs_to].include? type
|
85
|
+
end
|
86
|
+
|
87
|
+
private
|
88
|
+
# parse possible attribute options like :limit for string/text/binary/integer, :precision/:scale for decimals or :polymorphic for references/belongs_to
|
89
|
+
# when declaring options curly brackets should be used
|
90
|
+
def parse_type_and_options(type)
|
91
|
+
case type
|
92
|
+
when /(text|binary)\{([a-z]+)\}/
|
93
|
+
parsed_type, parsed_options = $1, { size: $2.to_sym }
|
94
|
+
when /(string|text|binary|integer)\{(\d+)\}/
|
95
|
+
parsed_type, parsed_options = $1, { limit: $2.to_i }
|
96
|
+
when /decimal\{(\d+)[,.-](\d+)\}/
|
97
|
+
parsed_type, parsed_options = :decimal, { precision: $1.to_i, scale: $2.to_i }
|
98
|
+
when /(references|belongs_to)\{(.+)\}/
|
99
|
+
parsed_type = $1
|
100
|
+
provided_options = $2.split(/[,.-]/)
|
101
|
+
parsed_options = Hash[provided_options.map { |opt| [opt.to_sym, true] }]
|
102
|
+
else
|
103
|
+
parsed_type, parsed_options = type&.remove("!"), {}
|
104
|
+
end
|
105
|
+
|
106
|
+
if type&.ends_with?("!")
|
107
|
+
parsed_options[:null] = false
|
108
|
+
end
|
109
|
+
|
110
|
+
return parsed_type, parsed_options
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def initialize(name, type = nil, index_type = false, attr_options = {})
|
115
|
+
@name = name
|
116
|
+
@type = type || :string
|
117
|
+
@has_index = INDEX_OPTIONS.include?(index_type)
|
118
|
+
@has_uniq_index = UNIQ_INDEX_OPTIONS.include?(index_type)
|
119
|
+
@attr_options = attr_options
|
120
|
+
end
|
121
|
+
|
122
|
+
def field_type
|
123
|
+
@field_type ||= case type
|
124
|
+
when :integer then :number_field
|
125
|
+
when :float, :decimal then :text_field
|
126
|
+
when :time then :time_field
|
127
|
+
when :datetime, :timestamp then :datetime_field
|
128
|
+
when :date then :date_field
|
129
|
+
when :text then :textarea
|
130
|
+
when :rich_text then :rich_textarea
|
131
|
+
when :boolean then :checkbox
|
132
|
+
when :attachment, :attachments then :file_field
|
133
|
+
else
|
134
|
+
:text_field
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
def default
|
139
|
+
@default ||= case type
|
140
|
+
when :integer then 1
|
141
|
+
when :float then 1.5
|
142
|
+
when :decimal then "9.99"
|
143
|
+
when :datetime, :timestamp, :time then Time.now.to_fs(:db)
|
144
|
+
when :date then Date.today.to_fs(:db)
|
145
|
+
when :string then name == "type" ? "" : "MyString"
|
146
|
+
when :text then "MyText"
|
147
|
+
when :boolean then false
|
148
|
+
when :references, :belongs_to,
|
149
|
+
:attachment, :attachments,
|
150
|
+
:rich_text then nil
|
151
|
+
else
|
152
|
+
""
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
def plural_name
|
157
|
+
name.delete_suffix("_id").pluralize
|
158
|
+
end
|
159
|
+
|
160
|
+
def singular_name
|
161
|
+
name.delete_suffix("_id").singularize
|
162
|
+
end
|
163
|
+
|
164
|
+
def human_name
|
165
|
+
name.humanize
|
166
|
+
end
|
167
|
+
|
168
|
+
def index_name
|
169
|
+
@index_name ||= if polymorphic?
|
170
|
+
%w(id type).map { |t| "#{name}_#{t}" }
|
171
|
+
else
|
172
|
+
column_name
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
def column_name
|
177
|
+
@column_name ||= reference? ? "#{name}_id" : name
|
178
|
+
end
|
179
|
+
|
180
|
+
def foreign_key?
|
181
|
+
name.end_with?("_id")
|
182
|
+
end
|
183
|
+
|
184
|
+
def reference?
|
185
|
+
self.class.reference?(type)
|
186
|
+
end
|
187
|
+
|
188
|
+
def polymorphic?
|
189
|
+
attr_options[:polymorphic]
|
190
|
+
end
|
191
|
+
|
192
|
+
def required?
|
193
|
+
reference? && Rails.application.config.active_record.belongs_to_required_by_default
|
194
|
+
end
|
195
|
+
|
196
|
+
def has_index?
|
197
|
+
@has_index
|
198
|
+
end
|
199
|
+
|
200
|
+
def has_uniq_index?
|
201
|
+
@has_uniq_index
|
202
|
+
end
|
203
|
+
|
204
|
+
def password_digest?
|
205
|
+
name == "password" && type == :digest
|
206
|
+
end
|
207
|
+
|
208
|
+
def token?
|
209
|
+
type == :token
|
210
|
+
end
|
211
|
+
|
212
|
+
def rich_text?
|
213
|
+
type == :rich_text
|
214
|
+
end
|
215
|
+
|
216
|
+
def attachment?
|
217
|
+
type == :attachment
|
218
|
+
end
|
219
|
+
|
220
|
+
def attachments?
|
221
|
+
type == :attachments
|
222
|
+
end
|
223
|
+
|
224
|
+
def virtual?
|
225
|
+
rich_text? || attachment? || attachments?
|
226
|
+
end
|
227
|
+
|
228
|
+
def inject_options
|
229
|
+
(+"").tap { |s| options_for_migration.each { |k, v| s << ", #{k}: #{v.inspect}" } }
|
230
|
+
end
|
231
|
+
|
232
|
+
def inject_index_options
|
233
|
+
has_uniq_index? ? ", unique: true" : ""
|
234
|
+
end
|
235
|
+
|
236
|
+
def options_for_migration
|
237
|
+
@attr_options.dup.tap do |options|
|
238
|
+
if required?
|
239
|
+
options[:null] = false
|
240
|
+
end
|
241
|
+
|
242
|
+
if reference? && !polymorphic?
|
243
|
+
options[:foreign_key] = true
|
244
|
+
end
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
def to_s
|
249
|
+
if has_uniq_index?
|
250
|
+
"#{name}:#{type}#{print_attribute_options}:uniq"
|
251
|
+
elsif has_index?
|
252
|
+
"#{name}:#{type}#{print_attribute_options}:index"
|
253
|
+
else
|
254
|
+
"#{name}:#{type}#{print_attribute_options}"
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
private
|
259
|
+
def print_attribute_options
|
260
|
+
if attr_options.empty?
|
261
|
+
""
|
262
|
+
elsif attr_options[:size]
|
263
|
+
"{#{attr_options[:size]}}"
|
264
|
+
elsif attr_options[:limit]
|
265
|
+
"{#{attr_options[:limit]}}"
|
266
|
+
elsif attr_options[:precision] && attr_options[:scale]
|
267
|
+
"{#{attr_options[:precision]},#{attr_options[:scale]}}"
|
268
|
+
else
|
269
|
+
"{#{attr_options.keys.join(",")}}"
|
270
|
+
end
|
271
|
+
end
|
272
|
+
end
|
273
|
+
end
|
274
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/concern"
|
4
|
+
require "rails/generators/actions/create_migration"
|
5
|
+
|
6
|
+
module Rails
|
7
|
+
module Generators
|
8
|
+
# Holds common methods for migrations. It assumes that migrations have the
|
9
|
+
# [0-9]*_name format and can be used by other frameworks (like Sequel)
|
10
|
+
# just by implementing the +next_migration_number+ method.
|
11
|
+
module Migration
|
12
|
+
extend ActiveSupport::Concern
|
13
|
+
attr_reader :migration_number, :migration_file_name, :migration_class_name
|
14
|
+
|
15
|
+
module ClassMethods # :nodoc:
|
16
|
+
def migration_lookup_at(dirname)
|
17
|
+
Dir.glob("#{dirname}/[0-9]*_*.rb")
|
18
|
+
end
|
19
|
+
|
20
|
+
def migration_exists?(dirname, file_name)
|
21
|
+
migration_lookup_at(dirname).grep(/\d+_#{file_name}.rb$/).first
|
22
|
+
end
|
23
|
+
|
24
|
+
def current_migration_number(dirname)
|
25
|
+
migration_lookup_at(dirname).collect do |file|
|
26
|
+
File.basename(file).split("_").first.to_i
|
27
|
+
end.max.to_i
|
28
|
+
end
|
29
|
+
|
30
|
+
def next_migration_number(dirname)
|
31
|
+
raise NotImplementedError
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def create_migration(destination, data, config = {}, &block)
|
36
|
+
action Rails::Generators::Actions::CreateMigration.new(self, destination, block || data.to_s, config)
|
37
|
+
end
|
38
|
+
|
39
|
+
def set_migration_assigns!(destination)
|
40
|
+
destination = File.expand_path(destination, destination_root)
|
41
|
+
|
42
|
+
migration_dir = File.dirname(destination)
|
43
|
+
@migration_number = self.class.next_migration_number(migration_dir)
|
44
|
+
@migration_file_name = File.basename(destination, ".rb")
|
45
|
+
@migration_class_name = @migration_file_name.camelize
|
46
|
+
end
|
47
|
+
|
48
|
+
# Creates a migration template at the given destination. The difference
|
49
|
+
# to the default template method is that the migration number is prepended
|
50
|
+
# to the destination file name.
|
51
|
+
#
|
52
|
+
# The migration number, migration file name, migration class name are
|
53
|
+
# available as instance variables in the template to be rendered.
|
54
|
+
#
|
55
|
+
# migration_template "migration.rb", "db/migrate/add_foo_to_bar.rb"
|
56
|
+
def migration_template(source, destination, config = {})
|
57
|
+
source = File.expand_path(find_in_source_paths(source.to_s))
|
58
|
+
|
59
|
+
set_migration_assigns!(destination)
|
60
|
+
|
61
|
+
dir, base = File.split(destination)
|
62
|
+
numbered_destination = File.join(dir, ["%migration_number%", base].join("_"))
|
63
|
+
|
64
|
+
file = create_migration numbered_destination, nil, config do
|
65
|
+
ERB.new(::File.binread(source), trim_mode: "-", eoutvar: "@output_buffer").result(binding)
|
66
|
+
end
|
67
|
+
Rails::Generators.add_generated_file(file)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rails/generators/active_model"
|
4
|
+
|
5
|
+
module Rails
|
6
|
+
module Generators
|
7
|
+
module ModelHelpers # :nodoc:
|
8
|
+
PLURAL_MODEL_NAME_WARN_MESSAGE = "[WARNING] The model name '%s' was recognized as a plural, using the singular '%s' instead. " \
|
9
|
+
"Override with --force-plural or setup custom inflection rules for this noun before running the generator."
|
10
|
+
IRREGULAR_MODEL_NAME_WARN_MESSAGE = <<~WARNING
|
11
|
+
[WARNING] Rails cannot recover singular form from its plural form '%s'.
|
12
|
+
Please setup custom inflection rules for this noun before running the generator in config/initializers/inflections.rb.
|
13
|
+
WARNING
|
14
|
+
INFLECTION_IMPOSSIBLE_ERROR_MESSAGE = <<~ERROR
|
15
|
+
Rails cannot recover the underscored form from its camelcase form '%s'.
|
16
|
+
Please use an underscored name instead, either '%s' or '%s'.
|
17
|
+
Or setup custom inflection rules for this noun before running the generator in config/initializers/inflections.rb.
|
18
|
+
ERROR
|
19
|
+
mattr_accessor :skip_warn
|
20
|
+
|
21
|
+
def self.included(base) # :nodoc:
|
22
|
+
base.class_option :force_plural, type: :boolean, default: false,
|
23
|
+
desc: "Do not singularize the model name, even if it appears plural"
|
24
|
+
end
|
25
|
+
|
26
|
+
def initialize(args, *_options)
|
27
|
+
super
|
28
|
+
if plural_model_name?(name) && !options[:force_plural]
|
29
|
+
singular = name.singularize
|
30
|
+
unless ModelHelpers.skip_warn
|
31
|
+
say PLURAL_MODEL_NAME_WARN_MESSAGE % [name, singular]
|
32
|
+
end
|
33
|
+
name.replace singular
|
34
|
+
assign_names!(name)
|
35
|
+
end
|
36
|
+
if inflection_impossible?(name)
|
37
|
+
option1 = name.singularize.underscore
|
38
|
+
option2 = name.pluralize.underscore.singularize
|
39
|
+
raise Error, INFLECTION_IMPOSSIBLE_ERROR_MESSAGE % [name, option1, option2]
|
40
|
+
end
|
41
|
+
if irregular_model_name?(name) && ! ModelHelpers.skip_warn
|
42
|
+
say IRREGULAR_MODEL_NAME_WARN_MESSAGE % [name.pluralize]
|
43
|
+
end
|
44
|
+
ModelHelpers.skip_warn = true
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
def plural_model_name?(name)
|
49
|
+
name == name.pluralize && name.singularize != name.pluralize
|
50
|
+
end
|
51
|
+
|
52
|
+
def irregular_model_name?(name)
|
53
|
+
name.singularize != name.pluralize.singularize
|
54
|
+
end
|
55
|
+
|
56
|
+
def inflection_impossible?(name)
|
57
|
+
name != name.underscore &&
|
58
|
+
name.singularize.underscore != name.pluralize.underscore.singularize
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,227 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rails/generators/base"
|
4
|
+
require "rails/generators/generated_attribute"
|
5
|
+
|
6
|
+
module Rails
|
7
|
+
module Generators
|
8
|
+
class NamedBase < Base
|
9
|
+
argument :name, type: :string
|
10
|
+
|
11
|
+
def initialize(args, *options) # :nodoc:
|
12
|
+
@inside_template = nil
|
13
|
+
# Unfreeze name in case it's given as a frozen string
|
14
|
+
args[0] = args[0].dup if args[0].is_a?(String) && args[0].frozen?
|
15
|
+
super
|
16
|
+
assign_names!(name)
|
17
|
+
parse_attributes! if respond_to?(:attributes)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Overrides <tt>Thor::Actions#template</tt> so it can tell if
|
21
|
+
# a template is currently being created.
|
22
|
+
no_tasks do
|
23
|
+
def template(source, *args, &block)
|
24
|
+
inside_template do
|
25
|
+
Rails::Generators.add_generated_file(super)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def js_template(source, destination)
|
30
|
+
template(source + ".js", destination + ".js")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
attr_reader :file_name
|
36
|
+
|
37
|
+
# FIXME: We are avoiding to use alias because a bug on thor that make
|
38
|
+
# this method public and add it to the task list.
|
39
|
+
def singular_name # :doc:
|
40
|
+
file_name
|
41
|
+
end
|
42
|
+
|
43
|
+
def inside_template # :doc:
|
44
|
+
@inside_template = true
|
45
|
+
yield
|
46
|
+
ensure
|
47
|
+
@inside_template = false
|
48
|
+
end
|
49
|
+
|
50
|
+
def inside_template? # :doc:
|
51
|
+
@inside_template
|
52
|
+
end
|
53
|
+
|
54
|
+
def file_path # :doc:
|
55
|
+
@file_path ||= (class_path + [file_name]).join("/")
|
56
|
+
end
|
57
|
+
|
58
|
+
def class_path # :doc:
|
59
|
+
inside_template? || !namespaced? ? regular_class_path : namespaced_class_path
|
60
|
+
end
|
61
|
+
|
62
|
+
def regular_class_path # :doc:
|
63
|
+
@class_path
|
64
|
+
end
|
65
|
+
|
66
|
+
def namespaced_class_path # :doc:
|
67
|
+
@namespaced_class_path ||= namespace_dirs + @class_path
|
68
|
+
end
|
69
|
+
|
70
|
+
def class_name # :doc:
|
71
|
+
(class_path + [file_name]).map!(&:camelize).join("::")
|
72
|
+
end
|
73
|
+
|
74
|
+
def human_name # :doc:
|
75
|
+
@human_name ||= singular_name.humanize
|
76
|
+
end
|
77
|
+
|
78
|
+
def plural_name # :doc:
|
79
|
+
@plural_name ||= singular_name.pluralize
|
80
|
+
end
|
81
|
+
|
82
|
+
def i18n_scope # :doc:
|
83
|
+
@i18n_scope ||= file_path.tr("/", ".")
|
84
|
+
end
|
85
|
+
|
86
|
+
def table_name # :doc:
|
87
|
+
@table_name ||= begin
|
88
|
+
base = pluralize_table_names? ? plural_name : singular_name
|
89
|
+
(class_path + [base]).join("_")
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def uncountable? # :doc:
|
94
|
+
singular_name == plural_name
|
95
|
+
end
|
96
|
+
|
97
|
+
def index_helper(type: nil) # :doc:
|
98
|
+
[plural_route_name, ("index" if uncountable?), type].compact.join("_")
|
99
|
+
end
|
100
|
+
|
101
|
+
def show_helper(arg = "@#{singular_table_name}", type: :url) # :doc:
|
102
|
+
"#{singular_route_name}_#{type}(#{arg})"
|
103
|
+
end
|
104
|
+
|
105
|
+
def edit_helper(...) # :doc:
|
106
|
+
"edit_#{show_helper(...)}"
|
107
|
+
end
|
108
|
+
|
109
|
+
def new_helper(type: :url) # :doc:
|
110
|
+
"new_#{singular_route_name}_#{type}"
|
111
|
+
end
|
112
|
+
|
113
|
+
def singular_table_name # :doc:
|
114
|
+
@singular_table_name ||= (pluralize_table_names? ? table_name.singularize : table_name)
|
115
|
+
end
|
116
|
+
|
117
|
+
def plural_table_name # :doc:
|
118
|
+
@plural_table_name ||= (pluralize_table_names? ? table_name : table_name.pluralize)
|
119
|
+
end
|
120
|
+
|
121
|
+
def plural_file_name # :doc:
|
122
|
+
@plural_file_name ||= file_name.pluralize
|
123
|
+
end
|
124
|
+
|
125
|
+
def fixture_file_name # :doc:
|
126
|
+
@fixture_file_name ||= (pluralize_table_names? ? plural_file_name : file_name)
|
127
|
+
end
|
128
|
+
|
129
|
+
def route_url # :doc:
|
130
|
+
@route_url ||= controller_class_path.collect { |dname| "/" + dname }.join + "/" + plural_file_name
|
131
|
+
end
|
132
|
+
|
133
|
+
def url_helper_prefix # :doc:
|
134
|
+
@url_helper_prefix ||= (class_path + [file_name]).join("_")
|
135
|
+
end
|
136
|
+
|
137
|
+
# Tries to retrieve the application name or simply return application.
|
138
|
+
def application_name # :doc:
|
139
|
+
if defined?(Rails) && Rails.application
|
140
|
+
Rails.application.class.name.split("::").first.underscore
|
141
|
+
else
|
142
|
+
"application"
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
def redirect_resource_name # :doc:
|
147
|
+
model_resource_name(prefix: "@")
|
148
|
+
end
|
149
|
+
|
150
|
+
def model_resource_name(base_name = singular_table_name, prefix: "") # :doc:
|
151
|
+
resource_name = "#{prefix}#{base_name}"
|
152
|
+
if options[:model_name]
|
153
|
+
"[#{controller_class_path.map { |name| ":" + name }.join(", ")}, #{resource_name}]"
|
154
|
+
else
|
155
|
+
resource_name
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
def singular_route_name # :doc:
|
160
|
+
if options[:model_name]
|
161
|
+
"#{controller_class_path.join('_')}_#{singular_table_name}"
|
162
|
+
else
|
163
|
+
singular_table_name
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
def plural_route_name # :doc:
|
168
|
+
if options[:model_name]
|
169
|
+
"#{controller_class_path.join('_')}_#{plural_table_name}"
|
170
|
+
else
|
171
|
+
plural_table_name
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
def assign_names!(name)
|
176
|
+
@class_path = name.include?("/") ? name.split("/") : name.split("::")
|
177
|
+
@class_path.map!(&:underscore)
|
178
|
+
@file_name = @class_path.pop
|
179
|
+
end
|
180
|
+
|
181
|
+
# Convert attributes array into GeneratedAttribute objects.
|
182
|
+
def parse_attributes!
|
183
|
+
self.attributes = (attributes || []).map do |attr|
|
184
|
+
Rails::Generators::GeneratedAttribute.parse(attr)
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
def attributes_names # :doc:
|
189
|
+
@attributes_names ||= attributes.each_with_object([]) do |a, names|
|
190
|
+
names << a.column_name
|
191
|
+
names << "password_confirmation" if a.password_digest?
|
192
|
+
names << "#{a.name}_type" if a.polymorphic?
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
def pluralize_table_names? # :doc:
|
197
|
+
!defined?(ActiveRecord::Base) || ActiveRecord::Base.pluralize_table_names
|
198
|
+
end
|
199
|
+
|
200
|
+
def mountable_engine? # :doc:
|
201
|
+
defined?(ENGINE_ROOT) && namespaced?
|
202
|
+
end
|
203
|
+
|
204
|
+
# Add a class collisions name to be checked on class initialization. You
|
205
|
+
# can supply a hash with a +:prefix+ or +:suffix+ to be tested.
|
206
|
+
#
|
207
|
+
# ==== Examples
|
208
|
+
#
|
209
|
+
# check_class_collision suffix: "Decorator"
|
210
|
+
#
|
211
|
+
# If the generator is invoked with class name Admin, it will check for
|
212
|
+
# the presence of "AdminDecorator".
|
213
|
+
#
|
214
|
+
def self.check_class_collision(options = {}) # :doc:
|
215
|
+
define_method :check_class_collision do
|
216
|
+
name = if respond_to?(:controller_class_name, true) # for ResourceHelpers
|
217
|
+
controller_class_name
|
218
|
+
else
|
219
|
+
class_name
|
220
|
+
end
|
221
|
+
|
222
|
+
class_collisions "#{options[:prefix]}#{name}#{options[:suffix]}"
|
223
|
+
end
|
224
|
+
end
|
225
|
+
end
|
226
|
+
end
|
227
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
Description:
|
2
|
+
The `rails new` command creates a new Rails application with a default
|
3
|
+
directory structure and configuration at the path you specify.
|
4
|
+
|
5
|
+
You can specify extra command-line arguments to be used every time
|
6
|
+
`rails new` runs in the .railsrc configuration file in your home directory,
|
7
|
+
or in $XDG_CONFIG_HOME/rails/railsrc if XDG_CONFIG_HOME is set.
|
8
|
+
|
9
|
+
Note that the arguments specified in the .railsrc file don't affect the
|
10
|
+
default values shown above in this help message.
|
11
|
+
|
12
|
+
You can specify which version to use when creating a new rails application
|
13
|
+
using `rails _<version>_ new`.
|
14
|
+
|
15
|
+
Examples:
|
16
|
+
`rails new ~/Code/Ruby/weblog`
|
17
|
+
|
18
|
+
This generates a new Rails app in ~/Code/Ruby/weblog.
|
19
|
+
|
20
|
+
`rails _<version>_ new weblog`
|
21
|
+
|
22
|
+
This generates a new Rails app with the provided version in ./weblog.
|
23
|
+
|
24
|
+
`rails new weblog --api`
|
25
|
+
|
26
|
+
This generates a new Rails app in API mode in ./weblog.
|
27
|
+
|
28
|
+
`rails new weblog --skip-action-mailer`
|
29
|
+
|
30
|
+
This generates a new Rails app without Action Mailer in ./weblog.
|
31
|
+
Any part of Rails can be skipped during app generation.
|