omg-railties 8.0.0.alpha3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (351) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +171 -0
  3. data/MIT-LICENSE +20 -0
  4. data/RDOC_MAIN.md +99 -0
  5. data/README.rdoc +39 -0
  6. data/exe/rails +10 -0
  7. data/lib/minitest/rails_plugin.rb +140 -0
  8. data/lib/rails/all.rb +21 -0
  9. data/lib/rails/api/generator.rb +38 -0
  10. data/lib/rails/api/task.rb +235 -0
  11. data/lib/rails/app_loader.rb +77 -0
  12. data/lib/rails/application/bootstrap.rb +118 -0
  13. data/lib/rails/application/configuration.rb +659 -0
  14. data/lib/rails/application/default_middleware_stack.rb +140 -0
  15. data/lib/rails/application/dummy_config.rb +19 -0
  16. data/lib/rails/application/finisher.rb +238 -0
  17. data/lib/rails/application/routes_reloader.rb +79 -0
  18. data/lib/rails/application.rb +658 -0
  19. data/lib/rails/application_controller.rb +28 -0
  20. data/lib/rails/autoloaders/inflector.rb +21 -0
  21. data/lib/rails/autoloaders.rb +48 -0
  22. data/lib/rails/backtrace_cleaner.rb +42 -0
  23. data/lib/rails/cli.rb +21 -0
  24. data/lib/rails/code_statistics.rb +159 -0
  25. data/lib/rails/code_statistics_calculator.rb +99 -0
  26. data/lib/rails/command/actions.rb +52 -0
  27. data/lib/rails/command/base.rb +185 -0
  28. data/lib/rails/command/behavior.rb +84 -0
  29. data/lib/rails/command/environment_argument.rb +56 -0
  30. data/lib/rails/command/helpers/editor.rb +40 -0
  31. data/lib/rails/command.rb +172 -0
  32. data/lib/rails/commands/about/about_command.rb +14 -0
  33. data/lib/rails/commands/app/update_command.rb +94 -0
  34. data/lib/rails/commands/application/application_command.rb +33 -0
  35. data/lib/rails/commands/boot/boot_command.rb +14 -0
  36. data/lib/rails/commands/console/console_command.rb +91 -0
  37. data/lib/rails/commands/console/irb_console.rb +136 -0
  38. data/lib/rails/commands/credentials/USAGE +73 -0
  39. data/lib/rails/commands/credentials/credentials_command/diffing.rb +53 -0
  40. data/lib/rails/commands/credentials/credentials_command.rb +139 -0
  41. data/lib/rails/commands/db/system/change/change_command.rb +26 -0
  42. data/lib/rails/commands/dbconsole/dbconsole_command.rb +88 -0
  43. data/lib/rails/commands/destroy/destroy_command.rb +29 -0
  44. data/lib/rails/commands/dev/dev_command.rb +14 -0
  45. data/lib/rails/commands/devcontainer/devcontainer_command.rb +39 -0
  46. data/lib/rails/commands/encrypted/USAGE +23 -0
  47. data/lib/rails/commands/encrypted/encrypted_command.rb +98 -0
  48. data/lib/rails/commands/gem_help/USAGE +16 -0
  49. data/lib/rails/commands/gem_help/gem_help_command.rb +13 -0
  50. data/lib/rails/commands/generate/generate_command.rb +30 -0
  51. data/lib/rails/commands/help/USAGE +17 -0
  52. data/lib/rails/commands/help/help_command.rb +34 -0
  53. data/lib/rails/commands/initializers/initializers_command.rb +20 -0
  54. data/lib/rails/commands/middleware/middleware_command.rb +17 -0
  55. data/lib/rails/commands/new/new_command.rb +21 -0
  56. data/lib/rails/commands/notes/notes_command.rb +30 -0
  57. data/lib/rails/commands/plugin/plugin_command.rb +47 -0
  58. data/lib/rails/commands/rake/rake_command.rb +55 -0
  59. data/lib/rails/commands/restart/restart_command.rb +14 -0
  60. data/lib/rails/commands/routes/routes_command.rb +49 -0
  61. data/lib/rails/commands/runner/USAGE +22 -0
  62. data/lib/rails/commands/runner/runner_command.rb +81 -0
  63. data/lib/rails/commands/secret/secret_command.rb +13 -0
  64. data/lib/rails/commands/server/server_command.rb +290 -0
  65. data/lib/rails/commands/stats/stats_command.rb +19 -0
  66. data/lib/rails/commands/test/USAGE +14 -0
  67. data/lib/rails/commands/test/test_command.rb +81 -0
  68. data/lib/rails/commands/unused_routes/unused_routes_command.rb +75 -0
  69. data/lib/rails/commands/version/version_command.rb +12 -0
  70. data/lib/rails/commands.rb +18 -0
  71. data/lib/rails/configuration.rb +170 -0
  72. data/lib/rails/console/app.rb +8 -0
  73. data/lib/rails/console/helpers.rb +8 -0
  74. data/lib/rails/console/methods.rb +23 -0
  75. data/lib/rails/deprecator.rb +7 -0
  76. data/lib/rails/dev_caching.rb +44 -0
  77. data/lib/rails/engine/commands.rb +9 -0
  78. data/lib/rails/engine/configuration.rb +138 -0
  79. data/lib/rails/engine/lazy_route_set.rb +109 -0
  80. data/lib/rails/engine/railties.rb +23 -0
  81. data/lib/rails/engine/updater.rb +21 -0
  82. data/lib/rails/engine.rb +760 -0
  83. data/lib/rails/gem_version.rb +17 -0
  84. data/lib/rails/generators/actions/create_migration.rb +75 -0
  85. data/lib/rails/generators/actions.rb +528 -0
  86. data/lib/rails/generators/active_model.rb +94 -0
  87. data/lib/rails/generators/app_base.rb +806 -0
  88. data/lib/rails/generators/app_name.rb +39 -0
  89. data/lib/rails/generators/base.rb +432 -0
  90. data/lib/rails/generators/database.rb +287 -0
  91. data/lib/rails/generators/erb/authentication/authentication_generator.rb +15 -0
  92. data/lib/rails/generators/erb/authentication/templates/views/passwords/edit.html.erb +9 -0
  93. data/lib/rails/generators/erb/authentication/templates/views/passwords/new.html.erb +8 -0
  94. data/lib/rails/generators/erb/authentication/templates/views/sessions/new.html.erb +11 -0
  95. data/lib/rails/generators/erb/controller/controller_generator.rb +24 -0
  96. data/lib/rails/generators/erb/controller/templates/view.html.erb.tt +2 -0
  97. data/lib/rails/generators/erb/mailer/mailer_generator.rb +41 -0
  98. data/lib/rails/generators/erb/mailer/templates/layout.html.erb.tt +13 -0
  99. data/lib/rails/generators/erb/mailer/templates/layout.text.erb.tt +1 -0
  100. data/lib/rails/generators/erb/mailer/templates/view.html.erb.tt +5 -0
  101. data/lib/rails/generators/erb/mailer/templates/view.text.erb.tt +3 -0
  102. data/lib/rails/generators/erb/scaffold/scaffold_generator.rb +34 -0
  103. data/lib/rails/generators/erb/scaffold/templates/_form.html.erb.tt +37 -0
  104. data/lib/rails/generators/erb/scaffold/templates/edit.html.erb.tt +12 -0
  105. data/lib/rails/generators/erb/scaffold/templates/index.html.erb.tt +16 -0
  106. data/lib/rails/generators/erb/scaffold/templates/new.html.erb.tt +11 -0
  107. data/lib/rails/generators/erb/scaffold/templates/partial.html.erb.tt +17 -0
  108. data/lib/rails/generators/erb/scaffold/templates/show.html.erb.tt +10 -0
  109. data/lib/rails/generators/erb.rb +26 -0
  110. data/lib/rails/generators/generated_attribute.rb +274 -0
  111. data/lib/rails/generators/migration.rb +71 -0
  112. data/lib/rails/generators/model_helpers.rb +62 -0
  113. data/lib/rails/generators/named_base.rb +227 -0
  114. data/lib/rails/generators/rails/app/USAGE +31 -0
  115. data/lib/rails/generators/rails/app/app_generator.rb +678 -0
  116. data/lib/rails/generators/rails/app/templates/Dockerfile.tt +119 -0
  117. data/lib/rails/generators/rails/app/templates/Gemfile.tt +83 -0
  118. data/lib/rails/generators/rails/app/templates/README.md.tt +24 -0
  119. data/lib/rails/generators/rails/app/templates/Rakefile.tt +6 -0
  120. data/lib/rails/generators/rails/app/templates/app/assets/stylesheets/application.css.tt +15 -0
  121. data/lib/rails/generators/rails/app/templates/app/controllers/application_controller.rb.tt +6 -0
  122. data/lib/rails/generators/rails/app/templates/app/helpers/application_helper.rb.tt +2 -0
  123. data/lib/rails/generators/rails/app/templates/app/jobs/application_job.rb.tt +7 -0
  124. data/lib/rails/generators/rails/app/templates/app/mailers/application_mailer.rb.tt +4 -0
  125. data/lib/rails/generators/rails/app/templates/app/models/application_record.rb.tt +3 -0
  126. data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +33 -0
  127. data/lib/rails/generators/rails/app/templates/app/views/layouts/mailer.html.erb.tt +13 -0
  128. data/lib/rails/generators/rails/app/templates/app/views/layouts/mailer.text.erb.tt +1 -0
  129. data/lib/rails/generators/rails/app/templates/app/views/pwa/manifest.json.erb.tt +22 -0
  130. data/lib/rails/generators/rails/app/templates/app/views/pwa/service-worker.js +26 -0
  131. data/lib/rails/generators/rails/app/templates/bin/brakeman.tt +6 -0
  132. data/lib/rails/generators/rails/app/templates/bin/dev.tt +1 -0
  133. data/lib/rails/generators/rails/app/templates/bin/rails.tt +3 -0
  134. data/lib/rails/generators/rails/app/templates/bin/rake.tt +3 -0
  135. data/lib/rails/generators/rails/app/templates/bin/rubocop.tt +7 -0
  136. data/lib/rails/generators/rails/app/templates/bin/setup.tt +45 -0
  137. data/lib/rails/generators/rails/app/templates/bin/thrust.tt +4 -0
  138. data/lib/rails/generators/rails/app/templates/config/application.rb.tt +42 -0
  139. data/lib/rails/generators/rails/app/templates/config/boot.rb.tt +6 -0
  140. data/lib/rails/generators/rails/app/templates/config/cable.yml.tt +10 -0
  141. data/lib/rails/generators/rails/app/templates/config/databases/mysql.yml.tt +82 -0
  142. data/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml.tt +114 -0
  143. data/lib/rails/generators/rails/app/templates/config/databases/sqlite3.yml.tt +72 -0
  144. data/lib/rails/generators/rails/app/templates/config/databases/trilogy.yml.tt +82 -0
  145. data/lib/rails/generators/rails/app/templates/config/deploy.yml.tt +107 -0
  146. data/lib/rails/generators/rails/app/templates/config/environment.rb.tt +5 -0
  147. data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +89 -0
  148. data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +125 -0
  149. data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +62 -0
  150. data/lib/rails/generators/rails/app/templates/config/initializers/assets.rb.tt +7 -0
  151. data/lib/rails/generators/rails/app/templates/config/initializers/content_security_policy.rb.tt +25 -0
  152. data/lib/rails/generators/rails/app/templates/config/initializers/cors.rb.tt +16 -0
  153. data/lib/rails/generators/rails/app/templates/config/initializers/filter_parameter_logging.rb.tt +8 -0
  154. data/lib/rails/generators/rails/app/templates/config/initializers/inflections.rb.tt +16 -0
  155. data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_8_0.rb.tt +25 -0
  156. data/lib/rails/generators/rails/app/templates/config/locales/en.yml +31 -0
  157. data/lib/rails/generators/rails/app/templates/config/puma.rb.tt +43 -0
  158. data/lib/rails/generators/rails/app/templates/config/routes.rb.tt +16 -0
  159. data/lib/rails/generators/rails/app/templates/config/storage.yml.tt +34 -0
  160. data/lib/rails/generators/rails/app/templates/config.ru.tt +6 -0
  161. data/lib/rails/generators/rails/app/templates/db/seeds.rb.tt +9 -0
  162. data/lib/rails/generators/rails/app/templates/docker-entrypoint.tt +16 -0
  163. data/lib/rails/generators/rails/app/templates/dockerignore.tt +56 -0
  164. data/lib/rails/generators/rails/app/templates/env.erb.tt +5 -0
  165. data/lib/rails/generators/rails/app/templates/gitattributes.tt +9 -0
  166. data/lib/rails/generators/rails/app/templates/github/ci.yml.tt +138 -0
  167. data/lib/rails/generators/rails/app/templates/github/dependabot.yml +12 -0
  168. data/lib/rails/generators/rails/app/templates/gitignore.tt +38 -0
  169. data/lib/rails/generators/rails/app/templates/node-version.tt +1 -0
  170. data/lib/rails/generators/rails/app/templates/public/400.html +67 -0
  171. data/lib/rails/generators/rails/app/templates/public/404.html +67 -0
  172. data/lib/rails/generators/rails/app/templates/public/406-unsupported-browser.html +66 -0
  173. data/lib/rails/generators/rails/app/templates/public/422.html +67 -0
  174. data/lib/rails/generators/rails/app/templates/public/500.html +66 -0
  175. data/lib/rails/generators/rails/app/templates/public/icon.png +0 -0
  176. data/lib/rails/generators/rails/app/templates/public/icon.svg +3 -0
  177. data/lib/rails/generators/rails/app/templates/public/robots.txt +1 -0
  178. data/lib/rails/generators/rails/app/templates/rubocop.yml.tt +8 -0
  179. data/lib/rails/generators/rails/app/templates/ruby-version.tt +1 -0
  180. data/lib/rails/generators/rails/app/templates/test/application_system_test_case.rb.tt +5 -0
  181. data/lib/rails/generators/rails/app/templates/test/test_helper.rb.tt +21 -0
  182. data/lib/rails/generators/rails/application_record/application_record_generator.rb +13 -0
  183. data/lib/rails/generators/rails/authentication/USAGE +6 -0
  184. data/lib/rails/generators/rails/authentication/authentication_generator.rb +54 -0
  185. data/lib/rails/generators/rails/authentication/templates/controllers/concerns/authentication.rb +55 -0
  186. data/lib/rails/generators/rails/authentication/templates/controllers/passwords_controller.rb +33 -0
  187. data/lib/rails/generators/rails/authentication/templates/controllers/sessions_controller.rb +21 -0
  188. data/lib/rails/generators/rails/authentication/templates/mailers/passwords_mailer.rb +6 -0
  189. data/lib/rails/generators/rails/authentication/templates/models/current.rb +4 -0
  190. data/lib/rails/generators/rails/authentication/templates/models/session.rb +3 -0
  191. data/lib/rails/generators/rails/authentication/templates/models/user.rb +6 -0
  192. data/lib/rails/generators/rails/authentication/templates/test/mailers/previews/passwords_mailer_preview.rb +7 -0
  193. data/lib/rails/generators/rails/authentication/templates/views/passwords_mailer/reset.html.erb +4 -0
  194. data/lib/rails/generators/rails/authentication/templates/views/passwords_mailer/reset.text.erb +2 -0
  195. data/lib/rails/generators/rails/benchmark/USAGE +19 -0
  196. data/lib/rails/generators/rails/benchmark/benchmark_generator.rb +30 -0
  197. data/lib/rails/generators/rails/benchmark/templates/benchmark.rb.tt +15 -0
  198. data/lib/rails/generators/rails/controller/USAGE +26 -0
  199. data/lib/rails/generators/rails/controller/controller_generator.rb +42 -0
  200. data/lib/rails/generators/rails/controller/templates/controller.rb.tt +9 -0
  201. data/lib/rails/generators/rails/credentials/credentials_generator.rb +61 -0
  202. data/lib/rails/generators/rails/credentials/templates/credentials.yml.tt +12 -0
  203. data/lib/rails/generators/rails/db/system/change/change_generator.rb +206 -0
  204. data/lib/rails/generators/rails/devcontainer/devcontainer_generator.rb +168 -0
  205. data/lib/rails/generators/rails/devcontainer/templates/devcontainer/Dockerfile.tt +3 -0
  206. data/lib/rails/generators/rails/devcontainer/templates/devcontainer/compose.yaml.tt +47 -0
  207. data/lib/rails/generators/rails/devcontainer/templates/devcontainer/devcontainer.json.tt +37 -0
  208. data/lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb +31 -0
  209. data/lib/rails/generators/rails/encryption_key_file/encryption_key_file_generator.rb +57 -0
  210. data/lib/rails/generators/rails/generator/USAGE +13 -0
  211. data/lib/rails/generators/rails/generator/generator_generator.rb +27 -0
  212. data/lib/rails/generators/rails/generator/templates/%file_name%_generator.rb.tt +3 -0
  213. data/lib/rails/generators/rails/generator/templates/USAGE.tt +8 -0
  214. data/lib/rails/generators/rails/generator/templates/templates/.empty_directory +0 -0
  215. data/lib/rails/generators/rails/helper/USAGE +12 -0
  216. data/lib/rails/generators/rails/helper/helper_generator.rb +20 -0
  217. data/lib/rails/generators/rails/helper/templates/helper.rb.tt +4 -0
  218. data/lib/rails/generators/rails/integration_test/USAGE +10 -0
  219. data/lib/rails/generators/rails/integration_test/integration_test_generator.rb +9 -0
  220. data/lib/rails/generators/rails/master_key/master_key_generator.rb +53 -0
  221. data/lib/rails/generators/rails/migration/USAGE +45 -0
  222. data/lib/rails/generators/rails/migration/migration_generator.rb +14 -0
  223. data/lib/rails/generators/rails/model/model_generator.rb +18 -0
  224. data/lib/rails/generators/rails/plugin/USAGE +21 -0
  225. data/lib/rails/generators/rails/plugin/plugin_generator.rb +499 -0
  226. data/lib/rails/generators/rails/plugin/templates/%name%.gemspec.tt +28 -0
  227. data/lib/rails/generators/rails/plugin/templates/Gemfile.tt +23 -0
  228. data/lib/rails/generators/rails/plugin/templates/MIT-LICENSE.tt +20 -0
  229. data/lib/rails/generators/rails/plugin/templates/README.md.tt +28 -0
  230. data/lib/rails/generators/rails/plugin/templates/Rakefile.tt +14 -0
  231. data/lib/rails/generators/rails/plugin/templates/app/controllers/%namespaced_name%/application_controller.rb.tt +5 -0
  232. data/lib/rails/generators/rails/plugin/templates/app/helpers/%namespaced_name%/application_helper.rb.tt +5 -0
  233. data/lib/rails/generators/rails/plugin/templates/app/jobs/%namespaced_name%/application_job.rb.tt +5 -0
  234. data/lib/rails/generators/rails/plugin/templates/app/mailers/%namespaced_name%/application_mailer.rb.tt +7 -0
  235. data/lib/rails/generators/rails/plugin/templates/app/models/%namespaced_name%/application_record.rb.tt +6 -0
  236. data/lib/rails/generators/rails/plugin/templates/app/views/layouts/%namespaced_name%/application.html.erb.tt +17 -0
  237. data/lib/rails/generators/rails/plugin/templates/bin/rails.tt +15 -0
  238. data/lib/rails/generators/rails/plugin/templates/bin/rubocop.tt +7 -0
  239. data/lib/rails/generators/rails/plugin/templates/bin/test.tt +4 -0
  240. data/lib/rails/generators/rails/plugin/templates/config/routes.rb.tt +6 -0
  241. data/lib/rails/generators/rails/plugin/templates/github/ci.yml.tt +103 -0
  242. data/lib/rails/generators/rails/plugin/templates/github/dependabot.yml +12 -0
  243. data/lib/rails/generators/rails/plugin/templates/gitignore.tt +14 -0
  244. data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/engine.rb.tt +7 -0
  245. data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/railtie.rb.tt +5 -0
  246. data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/version.rb.tt +1 -0
  247. data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%.rb.tt +8 -0
  248. data/lib/rails/generators/rails/plugin/templates/lib/tasks/%namespaced_name%_tasks.rake.tt +4 -0
  249. data/lib/rails/generators/rails/plugin/templates/rails/boot.rb.tt +5 -0
  250. data/lib/rails/generators/rails/plugin/templates/rails/routes.rb.tt +3 -0
  251. data/lib/rails/generators/rails/plugin/templates/rails/stylesheets.css +15 -0
  252. data/lib/rails/generators/rails/plugin/templates/rubocop.yml.tt +8 -0
  253. data/lib/rails/generators/rails/plugin/templates/test/%namespaced_name%_test.rb.tt +7 -0
  254. data/lib/rails/generators/rails/plugin/templates/test/application_system_test_case.rb.tt +5 -0
  255. data/lib/rails/generators/rails/plugin/templates/test/integration/navigation_test.rb.tt +7 -0
  256. data/lib/rails/generators/rails/plugin/templates/test/test_helper.rb.tt +21 -0
  257. data/lib/rails/generators/rails/resource/USAGE +23 -0
  258. data/lib/rails/generators/rails/resource/resource_generator.rb +27 -0
  259. data/lib/rails/generators/rails/resource_route/resource_route_generator.rb +23 -0
  260. data/lib/rails/generators/rails/scaffold/USAGE +41 -0
  261. data/lib/rails/generators/rails/scaffold/scaffold_generator.rb +18 -0
  262. data/lib/rails/generators/rails/scaffold_controller/USAGE +19 -0
  263. data/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb +56 -0
  264. data/lib/rails/generators/rails/scaffold_controller/templates/api_controller.rb.tt +57 -0
  265. data/lib/rails/generators/rails/scaffold_controller/templates/controller.rb.tt +64 -0
  266. data/lib/rails/generators/rails/script/USAGE +18 -0
  267. data/lib/rails/generators/rails/script/script_generator.rb +18 -0
  268. data/lib/rails/generators/rails/script/templates/script.rb.tt +3 -0
  269. data/lib/rails/generators/rails/system_test/USAGE +10 -0
  270. data/lib/rails/generators/rails/system_test/system_test_generator.rb +9 -0
  271. data/lib/rails/generators/rails/task/USAGE +9 -0
  272. data/lib/rails/generators/rails/task/task_generator.rb +13 -0
  273. data/lib/rails/generators/rails/task/templates/task.rb.tt +8 -0
  274. data/lib/rails/generators/resource_helpers.rb +82 -0
  275. data/lib/rails/generators/test_case.rb +37 -0
  276. data/lib/rails/generators/test_unit/controller/controller_generator.rb +19 -0
  277. data/lib/rails/generators/test_unit/controller/templates/functional_test.rb.tt +23 -0
  278. data/lib/rails/generators/test_unit/generator/generator_generator.rb +27 -0
  279. data/lib/rails/generators/test_unit/generator/templates/generator_test.rb.tt +16 -0
  280. data/lib/rails/generators/test_unit/helper/helper_generator.rb +11 -0
  281. data/lib/rails/generators/test_unit/integration/integration_generator.rb +20 -0
  282. data/lib/rails/generators/test_unit/integration/templates/integration_test.rb.tt +9 -0
  283. data/lib/rails/generators/test_unit/job/job_generator.rb +20 -0
  284. data/lib/rails/generators/test_unit/job/templates/unit_test.rb.tt +9 -0
  285. data/lib/rails/generators/test_unit/mailer/mailer_generator.rb +28 -0
  286. data/lib/rails/generators/test_unit/mailer/templates/functional_test.rb.tt +23 -0
  287. data/lib/rails/generators/test_unit/mailer/templates/preview.rb.tt +14 -0
  288. data/lib/rails/generators/test_unit/model/model_generator.rb +37 -0
  289. data/lib/rails/generators/test_unit/model/templates/fixtures.yml.tt +29 -0
  290. data/lib/rails/generators/test_unit/model/templates/unit_test.rb.tt +9 -0
  291. data/lib/rails/generators/test_unit/plugin/plugin_generator.rb +15 -0
  292. data/lib/rails/generators/test_unit/plugin/templates/%file_name%_test.rb.tt +7 -0
  293. data/lib/rails/generators/test_unit/plugin/templates/test_helper.rb +2 -0
  294. data/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb +82 -0
  295. data/lib/rails/generators/test_unit/scaffold/templates/api_functional_test.rb.tt +44 -0
  296. data/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb.tt +54 -0
  297. data/lib/rails/generators/test_unit/scaffold/templates/system_test.rb.tt +57 -0
  298. data/lib/rails/generators/test_unit/system/system_generator.rb +24 -0
  299. data/lib/rails/generators/test_unit/system/templates/application_system_test_case.rb.tt +5 -0
  300. data/lib/rails/generators/test_unit/system/templates/system_test.rb.tt +9 -0
  301. data/lib/rails/generators/test_unit.rb +10 -0
  302. data/lib/rails/generators/testing/assertions.rb +147 -0
  303. data/lib/rails/generators/testing/behavior.rb +116 -0
  304. data/lib/rails/generators/testing/setup_and_teardown.rb +20 -0
  305. data/lib/rails/generators.rb +327 -0
  306. data/lib/rails/health_controller.rb +55 -0
  307. data/lib/rails/info.rb +105 -0
  308. data/lib/rails/info_controller.rb +71 -0
  309. data/lib/rails/initializable.rb +95 -0
  310. data/lib/rails/mailers_controller.rb +122 -0
  311. data/lib/rails/paths.rb +246 -0
  312. data/lib/rails/plugin/test.rb +9 -0
  313. data/lib/rails/pwa_controller.rb +15 -0
  314. data/lib/rails/rack/logger.rb +88 -0
  315. data/lib/rails/rack/silence_request.rb +33 -0
  316. data/lib/rails/rack.rb +8 -0
  317. data/lib/rails/rackup/server.rb +15 -0
  318. data/lib/rails/railtie/configurable.rb +36 -0
  319. data/lib/rails/railtie/configuration.rb +114 -0
  320. data/lib/rails/railtie.rb +302 -0
  321. data/lib/rails/source_annotation_extractor.rb +214 -0
  322. data/lib/rails/tasks/engine.rake +85 -0
  323. data/lib/rails/tasks/framework.rake +34 -0
  324. data/lib/rails/tasks/log.rake +41 -0
  325. data/lib/rails/tasks/misc.rake +68 -0
  326. data/lib/rails/tasks/statistics.rake +23 -0
  327. data/lib/rails/tasks/tmp.rake +51 -0
  328. data/lib/rails/tasks/yarn.rake +29 -0
  329. data/lib/rails/tasks/zeitwerk.rake +41 -0
  330. data/lib/rails/tasks.rb +17 -0
  331. data/lib/rails/templates/layouts/application.html.erb +51 -0
  332. data/lib/rails/templates/rails/info/notes.html.erb +65 -0
  333. data/lib/rails/templates/rails/info/properties.html.erb +1 -0
  334. data/lib/rails/templates/rails/info/routes.html.erb +9 -0
  335. data/lib/rails/templates/rails/mailers/email.html.erb +201 -0
  336. data/lib/rails/templates/rails/mailers/index.html.erb +15 -0
  337. data/lib/rails/templates/rails/mailers/mailer.html.erb +12 -0
  338. data/lib/rails/templates/rails/welcome/index.html.erb +93 -0
  339. data/lib/rails/test_help.rb +47 -0
  340. data/lib/rails/test_unit/line_filtering.rb +13 -0
  341. data/lib/rails/test_unit/railtie.rb +25 -0
  342. data/lib/rails/test_unit/reporter.rb +121 -0
  343. data/lib/rails/test_unit/runner.rb +209 -0
  344. data/lib/rails/test_unit/test_parser.rb +133 -0
  345. data/lib/rails/test_unit/testing.rake +39 -0
  346. data/lib/rails/testing/maintain_test_schema.rb +16 -0
  347. data/lib/rails/version.rb +10 -0
  348. data/lib/rails/welcome_controller.rb +11 -0
  349. data/lib/rails/zeitwerk_checker.rb +15 -0
  350. data/lib/rails.rb +130 -0
  351. metadata +518 -0
@@ -0,0 +1,290 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "fileutils"
4
+ require "action_dispatch"
5
+ require "rails"
6
+ require "rails/dev_caching"
7
+ require "rails/command/environment_argument"
8
+ require "rails/rackup/server"
9
+
10
+ module Rails
11
+ class Server < Rackup::Server
12
+ class Options
13
+ def parse!(args)
14
+ Rails::Command::ServerCommand.new([], args).server_options
15
+ end
16
+ end
17
+
18
+ def initialize(options = nil)
19
+ @default_options = options || {}
20
+ super(@default_options)
21
+ set_environment
22
+ end
23
+
24
+ def opt_parser
25
+ Options.new
26
+ end
27
+
28
+ def set_environment
29
+ ENV["RAILS_ENV"] ||= options[:environment]
30
+ end
31
+
32
+ def start(after_stop_callback = nil)
33
+ trap(:INT) { exit }
34
+ create_tmp_directories
35
+ setup_dev_caching
36
+ log_to_stdout if options[:log_stdout]
37
+
38
+ super()
39
+ ensure
40
+ after_stop_callback.call if after_stop_callback
41
+ end
42
+
43
+ def serveable? # :nodoc:
44
+ server
45
+ true
46
+ rescue LoadError, NameError
47
+ false
48
+ end
49
+
50
+ def middleware
51
+ Hash.new([])
52
+ end
53
+
54
+ def default_options
55
+ super.merge(@default_options)
56
+ end
57
+
58
+ def served_url
59
+ "#{options[:SSLEnable] ? 'https' : 'http'}://#{options[:Host]}:#{options[:Port]}" unless use_puma?
60
+ end
61
+
62
+ private
63
+ def setup_dev_caching
64
+ if options[:environment] == "development"
65
+ Rails::DevCaching.enable_by_argument(options[:caching])
66
+ end
67
+ end
68
+
69
+ def create_tmp_directories
70
+ %w(cache pids sockets).each do |dir_to_make|
71
+ FileUtils.mkdir_p(File.join(Rails.root, "tmp", dir_to_make))
72
+ end
73
+ end
74
+
75
+ def log_to_stdout
76
+ wrapped_app # touch the app so the logger is set up
77
+
78
+ console = ActiveSupport::Logger.new(STDOUT)
79
+ console.formatter = Rails.logger.formatter
80
+ console.level = Rails.logger.level
81
+
82
+ unless ActiveSupport::Logger.logger_outputs_to?(Rails.logger, STDERR, STDOUT)
83
+ Rails.logger.broadcast_to(console)
84
+ end
85
+ end
86
+
87
+ def use_puma?
88
+ server.to_s.end_with?("Handler::Puma")
89
+ end
90
+ end
91
+
92
+ module Command
93
+ class ServerCommand < Base # :nodoc:
94
+ include EnvironmentArgument
95
+
96
+ RACK_HANDLER_GEMS = %w(cgi webrick scgi thin puma unicorn falcon)
97
+ # Hard-coding a bunch of handlers here as we don't have a public way of
98
+ # querying them from the Rackup::Handler registry.
99
+ RACK_HANDLERS = RACK_HANDLER_GEMS + %w(fastcgi lsws)
100
+ RECOMMENDED_SERVER = "puma"
101
+
102
+ DEFAULT_PORT = 3000
103
+ DEFAULT_PIDFILE = "tmp/pids/server.pid"
104
+
105
+ class_option :port, aliases: "-p", type: :numeric,
106
+ desc: "Run Rails on the specified port - defaults to 3000.", banner: :port
107
+ class_option :binding, aliases: "-b", type: :string,
108
+ desc: "Bind Rails to the specified IP - defaults to 'localhost' in development and '0.0.0.0' in other environments'.",
109
+ banner: :IP
110
+ class_option :config, aliases: "-c", type: :string, default: "config.ru",
111
+ desc: "Use a custom rackup configuration.", banner: :file
112
+ class_option :daemon, aliases: "-d", type: :boolean, default: false,
113
+ desc: "Run server as a Daemon."
114
+ class_option :using, aliases: "-u", type: :string,
115
+ desc: "Specify the Rack server used to run the application (thin/puma/webrick).", banner: :name
116
+ class_option :pid, aliases: "-P", type: :string,
117
+ desc: "Specify the PID file. Defaults to #{DEFAULT_PIDFILE} in development."
118
+ class_option :dev_caching, aliases: "-C", type: :boolean, default: nil,
119
+ desc: "Specify whether to perform caching in development."
120
+ class_option :restart, type: :boolean, default: nil, hide: true
121
+ class_option :early_hints, type: :boolean, default: nil, desc: "Enable HTTP/2 early hints."
122
+ class_option :log_to_stdout, type: :boolean, default: nil, optional: true,
123
+ desc: "Whether to log to stdout. Enabled by default in development when not daemonized."
124
+
125
+ def initialize(args, local_options, *)
126
+ super
127
+
128
+ @original_options = local_options - %w( --restart )
129
+ end
130
+
131
+ desc "server", "Start the Rails server"
132
+ def perform
133
+ set_application_directory!
134
+ prepare_restart
135
+
136
+ Rails::Server.new(server_options).tap do |server|
137
+ # Require application after server sets environment to propagate
138
+ # the --environment option.
139
+ require APP_PATH
140
+ Dir.chdir(Rails.application.root)
141
+
142
+ if server.serveable?
143
+ print_boot_information(server.server, server.served_url)
144
+ after_stop_callback = -> { say "Exiting" unless options[:daemon] }
145
+ server.start(after_stop_callback)
146
+ else
147
+ say rack_server_suggestion(options[:using])
148
+ end
149
+ end
150
+ end
151
+
152
+ no_commands do
153
+ def server_options
154
+ {
155
+ user_supplied_options: user_supplied_options,
156
+ server: options[:using],
157
+ log_stdout: log_to_stdout?,
158
+ Port: port,
159
+ Host: host,
160
+ DoNotReverseLookup: true,
161
+ config: options[:config],
162
+ environment: environment,
163
+ daemonize: options[:daemon],
164
+ pid: pid,
165
+ caching: options[:dev_caching],
166
+ restart_cmd: restart_command,
167
+ early_hints: early_hints
168
+ }
169
+ end
170
+ end
171
+
172
+ private
173
+ def user_supplied_options
174
+ @user_supplied_options ||= begin
175
+ # Convert incoming options array to a hash of flags
176
+ # ["-p3001", "-C", "--binding", "127.0.0.1"] # => {"-p"=>true, "-C"=>true, "--binding"=>true}
177
+ user_flag = {}
178
+ @original_options.each do |command|
179
+ if command.start_with?("--")
180
+ option = command.split("=")[0]
181
+ user_flag[option] = true
182
+ elsif command =~ /\A(-.)/
183
+ user_flag[Regexp.last_match[0]] = true
184
+ end
185
+ end
186
+
187
+ # Collect all options that the user has explicitly defined so we can
188
+ # differentiate them from defaults
189
+ user_supplied_options = []
190
+ self.class.class_options.select do |key, option|
191
+ if option.aliases.any? { |name| user_flag[name] } || user_flag["--#{option.name}"]
192
+ name = option.name.to_sym
193
+ case name
194
+ when :port
195
+ name = :Port
196
+ when :binding
197
+ name = :Host
198
+ when :dev_caching
199
+ name = :caching
200
+ when :daemonize
201
+ name = :daemon
202
+ end
203
+ user_supplied_options << name
204
+ end
205
+ end
206
+ user_supplied_options << :Host if ENV["HOST"] || ENV["BINDING"]
207
+ user_supplied_options << :Port if ENV["PORT"]
208
+ user_supplied_options << :pid if ENV["PIDFILE"]
209
+ user_supplied_options.uniq
210
+ end
211
+ end
212
+
213
+ def port
214
+ options[:port] || ENV.fetch("PORT", DEFAULT_PORT).to_i
215
+ end
216
+
217
+ def host
218
+ if options[:binding]
219
+ options[:binding]
220
+ else
221
+ default_host = environment == "development" ? "localhost" : "0.0.0.0"
222
+
223
+ ENV.fetch("BINDING", default_host)
224
+ end
225
+ end
226
+
227
+ def environment
228
+ options[:environment] || Rails::Command.environment
229
+ end
230
+
231
+ def restart_command
232
+ "#{executable} #{@original_options.join(" ")} --restart"
233
+ end
234
+
235
+ def early_hints
236
+ options[:early_hints]
237
+ end
238
+
239
+ def log_to_stdout?
240
+ options.fetch(:log_to_stdout) do
241
+ options[:daemon].blank? && environment == "development"
242
+ end
243
+ end
244
+
245
+ def pid
246
+ default_pidfile = environment == "development" ? DEFAULT_PIDFILE : nil
247
+ pid = options[:pid] || ENV["PIDFILE"] || default_pidfile
248
+ File.expand_path(pid) if pid
249
+ end
250
+
251
+ def prepare_restart
252
+ FileUtils.rm_f(pid) if pid && options[:restart]
253
+ end
254
+
255
+ def rack_server_suggestion(server)
256
+ if server.nil?
257
+ <<~MSG
258
+ Could not find a server gem. Maybe you need to add one to the Gemfile?
259
+
260
+ gem "#{RECOMMENDED_SERVER}"
261
+
262
+ Run `#{executable} --help` for more options.
263
+ MSG
264
+ elsif server.in?(RACK_HANDLER_GEMS)
265
+ <<~MSG
266
+ Could not load server "#{server}". Maybe you need to the add it to the Gemfile?
267
+
268
+ gem "#{server}"
269
+
270
+ Run `#{executable} --help` for more options.
271
+ MSG
272
+ else
273
+ error = CorrectableNameError.new("Could not find server '#{server}'.", server, RACK_HANDLERS)
274
+ <<~MSG
275
+ #{error.detailed_message}
276
+ Run `#{executable} --help` for more options.
277
+ MSG
278
+ end
279
+ end
280
+
281
+ def print_boot_information(server, url)
282
+ say <<~MSG
283
+ => Booting #{ActiveSupport::Inflector.demodulize(server)}
284
+ => Rails #{Rails.version} application starting in #{Rails.env} #{url}
285
+ => Run `#{executable} --help` for more startup options
286
+ MSG
287
+ end
288
+ end
289
+ end
290
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rails
4
+ module Command
5
+ class StatsCommand < Base # :nodoc:
6
+ desc "stats", "Report code statistics (KLOCs, etc) from the application or engine"
7
+ def perform
8
+ require "rails/code_statistics"
9
+ boot_application!
10
+
11
+ stat_directories = Rails::CodeStatistics.directories.map do |name, dir|
12
+ [name, Rails::Command.application_root.join(dir)]
13
+ end.select { |name, dir| File.directory?(dir) }
14
+
15
+ Rails::CodeStatistics.new(*stat_directories).to_s
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,14 @@
1
+ Examples:
2
+ You can run a single test by appending a line number to a filename:
3
+
4
+ <%= executable %> test/models/user_test.rb:27
5
+
6
+ You can run multiple tests with in a line range by appending the line range to a filename:
7
+
8
+ <%= executable %> test/models/user_test.rb:10-20
9
+
10
+ You can run multiple files and directories at the same time:
11
+
12
+ <%= executable %> test/controllers test/integration/login_test.rb
13
+
14
+ By default test failures and errors are reported inline during a run.
@@ -0,0 +1,81 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails/command"
4
+ require "rails/commands/rake/rake_command"
5
+ require "rails/test_unit/runner"
6
+ require "rails/test_unit/reporter"
7
+
8
+ module Rails
9
+ module Command
10
+ class TestCommand < Base # :nodoc:
11
+ def self.executable(*args)
12
+ args.empty? ? Rails::TestUnitReporter.executable : super
13
+ end
14
+
15
+ no_commands do
16
+ def help(command_name = nil, *)
17
+ super
18
+ if command_name == "test"
19
+ say ""
20
+ say self.class.class_usage
21
+ end
22
+ say ""
23
+ Minitest.run(%w(--help))
24
+ end
25
+ end
26
+
27
+ desc "test [PATHS...]", "Run tests except system tests"
28
+ def perform(*args)
29
+ $LOAD_PATH << Rails::Command.root.join("test").to_s
30
+
31
+ Rails::TestUnit::Runner.parse_options(args)
32
+ run_prepare_task if self.args.none?(EXACT_TEST_ARGUMENT_PATTERN)
33
+ Rails::TestUnit::Runner.run(args)
34
+ rescue Rails::TestUnit::InvalidTestError => error
35
+ raise ArgumentError, error.message
36
+ end
37
+
38
+ # Define Thor tasks to avoid going through Rake and booting twice when using bin/rails test:*
39
+ Rails::TestUnit::Runner::TEST_FOLDERS.each do |name|
40
+ desc name, "Run tests in test/#{name}"
41
+ define_method(name) do |*args|
42
+ perform("test/#{name}", *args)
43
+ end
44
+ end
45
+
46
+ desc "all", "Run all tests, including system tests"
47
+ def all(*args)
48
+ perform("test/**/*_test.rb", *args)
49
+ end
50
+
51
+ desc "functionals", "Run tests in test/controllers, test/mailers, and test/functional"
52
+ def functionals(*args)
53
+ perform("test/controllers", "test/mailers", "test/functional", *args)
54
+ end
55
+
56
+ desc "units", "Run tests in test/models, test/helpers, and test/unit"
57
+ def units(*args)
58
+ perform("test/models", "test/helpers", "test/unit", *args)
59
+ end
60
+
61
+ desc "system", "Run system tests only"
62
+ def system(*args)
63
+ perform("test/system", *args)
64
+ end
65
+
66
+ desc "generators", "Run tests in test/lib/generators"
67
+ def generators(*args)
68
+ perform("test/lib/generators", *args)
69
+ end
70
+
71
+ private
72
+ EXACT_TEST_ARGUMENT_PATTERN = /^-n|^--name\b|#{Rails::TestUnit::Runner::PATH_ARGUMENT_PATTERN}/
73
+
74
+ def run_prepare_task
75
+ Rails::Command::RakeCommand.perform("test:prepare", [], {})
76
+ rescue UnrecognizedCommandError => error
77
+ raise unless error.name == "test:prepare"
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails/commands/routes/routes_command"
4
+
5
+ module Rails
6
+ module Command
7
+ class UnusedRoutesCommand < Rails::Command::Base # :nodoc:
8
+ hide_command!
9
+ class_option :controller, aliases: "-c", desc: "Filter by a specific controller, e.g. PostsController or Admin::PostsController."
10
+ class_option :grep, aliases: "-g", desc: "Grep routes by a specific pattern."
11
+
12
+ class RouteInfo
13
+ def initialize(route)
14
+ requirements = route.requirements
15
+ @controller_name = requirements[:controller]
16
+ @action_name = requirements[:action]
17
+ @controller_class = (@controller_name.to_s.camelize + "Controller").safe_constantize
18
+ end
19
+
20
+ def unused?
21
+ controller_class_missing? || (action_missing? && template_missing?)
22
+ end
23
+
24
+ private
25
+ def view_path(root)
26
+ File.join(root.path, @controller_name, @action_name)
27
+ end
28
+
29
+ def controller_class_missing?
30
+ @controller_name && @controller_class.nil?
31
+ end
32
+
33
+ def template_missing?
34
+ @controller_class && @controller_class.try(:view_paths).to_a.flat_map { |path| Dir["#{view_path(path)}.*"] }.none?
35
+ end
36
+
37
+ def action_missing?
38
+ @controller_class && @controller_class.instance_methods.exclude?(@action_name.to_sym)
39
+ end
40
+ end
41
+
42
+ def perform(*)
43
+ boot_application!
44
+ require "action_dispatch/routing/inspector"
45
+
46
+ say(inspector.format(formatter, routes_filter))
47
+
48
+ exit(1) if routes.any?
49
+ end
50
+
51
+ private
52
+ def inspector
53
+ ActionDispatch::Routing::RoutesInspector.new(routes)
54
+ end
55
+
56
+ def routes
57
+ @routes ||= begin
58
+ routes = Rails.application.routes.routes.select do |route|
59
+ RouteInfo.new(route).unused?
60
+ end
61
+
62
+ ActionDispatch::Journey::Routes.new(routes)
63
+ end
64
+ end
65
+
66
+ def formatter
67
+ ActionDispatch::Routing::ConsoleFormatter::Unused.new
68
+ end
69
+
70
+ def routes_filter
71
+ options.symbolize_keys.slice(:controller, :grep)
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rails
4
+ module Command
5
+ class VersionCommand < Base # :nodoc:
6
+ desc "version", "Show the Rails version"
7
+ def perform
8
+ Rails::Command.invoke :application, [ "--version" ]
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails/command"
4
+
5
+ aliases = {
6
+ "g" => "generate",
7
+ "d" => "destroy",
8
+ "c" => "console",
9
+ "s" => "server",
10
+ "db" => "dbconsole",
11
+ "r" => "runner",
12
+ "t" => "test"
13
+ }
14
+
15
+ command = ARGV.shift
16
+ command = aliases[command] || command
17
+
18
+ Rails::Command.invoke command, ARGV
@@ -0,0 +1,170 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "active_support/ordered_options"
4
+ require "active_support/core_ext/object"
5
+ require "rails/paths"
6
+ require "rails/rack"
7
+
8
+ module Rails
9
+ module Configuration
10
+ # MiddlewareStackProxy is a proxy for the \Rails middleware stack that allows
11
+ # you to configure middlewares in your application. It works basically as a
12
+ # command recorder, saving each command to be applied after initialization
13
+ # over the default middleware stack, so you can add, swap, or remove any
14
+ # middleware in \Rails.
15
+ #
16
+ # You can add your own middlewares by using the +config.middleware.use+ method:
17
+ #
18
+ # config.middleware.use Magical::Unicorns
19
+ #
20
+ # This will put the +Magical::Unicorns+ middleware on the end of the stack.
21
+ # You can use +insert_before+ if you wish to add a middleware before another:
22
+ #
23
+ # config.middleware.insert_before Rack::Head, Magical::Unicorns
24
+ #
25
+ # There's also +insert_after+ which will insert a middleware after another:
26
+ #
27
+ # config.middleware.insert_after Rack::Head, Magical::Unicorns
28
+ #
29
+ # Middlewares can also be completely swapped out and replaced with others:
30
+ #
31
+ # config.middleware.swap ActionDispatch::Flash, Magical::Unicorns
32
+ #
33
+ # Middlewares can be moved from one place to another:
34
+ #
35
+ # config.middleware.move_before ActionDispatch::Flash, Magical::Unicorns
36
+ #
37
+ # This will move the +Magical::Unicorns+ middleware before the
38
+ # +ActionDispatch::Flash+. You can also move it after:
39
+ #
40
+ # config.middleware.move_after ActionDispatch::Flash, Magical::Unicorns
41
+ #
42
+ # And finally they can also be removed from the stack completely:
43
+ #
44
+ # config.middleware.delete ActionDispatch::Flash
45
+ #
46
+ class MiddlewareStackProxy
47
+ def initialize(operations = [], delete_operations = [])
48
+ @operations = operations
49
+ @delete_operations = delete_operations
50
+ end
51
+
52
+ def insert_before(...)
53
+ @operations << -> middleware { middleware.insert_before(...) }
54
+ end
55
+
56
+ alias :insert :insert_before
57
+
58
+ def insert_after(...)
59
+ @operations << -> middleware { middleware.insert_after(...) }
60
+ end
61
+
62
+ def swap(...)
63
+ @operations << -> middleware { middleware.swap(...) }
64
+ end
65
+
66
+ def use(...)
67
+ @operations << -> middleware { middleware.use(...) }
68
+ end
69
+
70
+ def delete(...)
71
+ @delete_operations << -> middleware { middleware.delete(...) }
72
+ end
73
+
74
+ def move_before(...)
75
+ @delete_operations << -> middleware { middleware.move_before(...) }
76
+ end
77
+
78
+ alias :move :move_before
79
+
80
+ def move_after(...)
81
+ @delete_operations << -> middleware { middleware.move_after(...) }
82
+ end
83
+
84
+ def unshift(...)
85
+ @operations << -> middleware { middleware.unshift(...) }
86
+ end
87
+
88
+ def merge_into(other) # :nodoc:
89
+ (@operations + @delete_operations).each do |operation|
90
+ operation.call(other)
91
+ end
92
+
93
+ other
94
+ end
95
+
96
+ def +(other) # :nodoc:
97
+ MiddlewareStackProxy.new(@operations + other.operations, @delete_operations + other.delete_operations)
98
+ end
99
+
100
+ protected
101
+ attr_reader :operations, :delete_operations
102
+ end
103
+
104
+ class Generators # :nodoc:
105
+ attr_accessor :aliases, :options, :templates, :fallbacks, :colorize_logging, :api_only
106
+ attr_reader :hidden_namespaces, :after_generate_callbacks
107
+
108
+ def initialize
109
+ @aliases = Hash.new { |h, k| h[k] = {} }
110
+ @options = Hash.new { |h, k| h[k] = {} }
111
+ @fallbacks = {}
112
+ @templates = []
113
+ @colorize_logging = true
114
+ @api_only = false
115
+ @hidden_namespaces = []
116
+ @after_generate_callbacks = []
117
+ end
118
+
119
+ def initialize_copy(source)
120
+ @aliases = @aliases.deep_dup
121
+ @options = @options.deep_dup
122
+ @fallbacks = @fallbacks.deep_dup
123
+ @templates = @templates.dup
124
+ end
125
+
126
+ def hide_namespace(namespace)
127
+ @hidden_namespaces << namespace
128
+ end
129
+
130
+ def after_generate(&block)
131
+ @after_generate_callbacks << block
132
+ end
133
+
134
+ def apply_rubocop_autocorrect_after_generate!
135
+ after_generate do |files|
136
+ parsable_files = files.filter { |file| File.exist?(file) && file.end_with?(".rb") }
137
+ unless parsable_files.empty?
138
+ system(RbConfig.ruby, "bin/rubocop", "-A", "--fail-level=E", "--format=quiet", *parsable_files, exception: true)
139
+ end
140
+ end
141
+ end
142
+
143
+ def method_missing(method, *args)
144
+ method = method.name.delete_suffix("=").to_sym
145
+
146
+ if args.empty?
147
+ if method == :rails
148
+ return @options[method]
149
+ else
150
+ return @options[:rails][method]
151
+ end
152
+ end
153
+
154
+ if method == :rails || args.first.is_a?(Hash)
155
+ namespace, configuration = method, args.shift
156
+ else
157
+ namespace, configuration = args.shift, args.shift
158
+ namespace = namespace.to_sym if namespace.respond_to?(:to_sym)
159
+ @options[:rails][method] = namespace
160
+ end
161
+
162
+ if configuration
163
+ aliases = configuration.delete(:aliases)
164
+ @aliases[namespace].merge!(aliases) if aliases
165
+ @options[namespace].merge!(configuration)
166
+ end
167
+ end
168
+ end
169
+ end
170
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ Rails.deprecator.warn(<<~MSG, caller_locations(0..1))
4
+ `rails/console/app` has been deprecated and will be removed in Rails 8.0.
5
+ Please require `rails/console/methods` instead.
6
+ MSG
7
+
8
+ require "rails/console/methods"