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,659 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "ipaddr"
4
+ require "active_support/core_ext/array/wrap"
5
+ require "active_support/core_ext/kernel/reporting"
6
+ require "active_support/file_update_checker"
7
+ require "active_support/configuration_file"
8
+ require "rails/engine/configuration"
9
+ require "rails/source_annotation_extractor"
10
+
11
+ module Rails
12
+ class Application
13
+ class Configuration < ::Rails::Engine::Configuration
14
+ attr_accessor :allow_concurrency, :asset_host, :assume_ssl, :autoflush_log,
15
+ :cache_classes, :cache_store, :consider_all_requests_local, :console,
16
+ :eager_load, :exceptions_app, :file_watcher, :filter_parameters, :precompile_filter_parameters,
17
+ :force_ssl, :helpers_paths, :hosts, :host_authorization, :logger, :log_formatter,
18
+ :log_tags, :silence_healthcheck_path, :railties_order, :relative_url_root,
19
+ :ssl_options, :public_file_server,
20
+ :session_options, :time_zone, :reload_classes_only_on_change,
21
+ :beginning_of_week, :filter_redirect, :x,
22
+ :content_security_policy_report_only,
23
+ :content_security_policy_nonce_generator, :content_security_policy_nonce_directives,
24
+ :require_master_key, :credentials, :disable_sandbox, :sandbox_by_default,
25
+ :add_autoload_paths_to_load_path, :rake_eager_load, :server_timing, :log_file_size,
26
+ :dom_testing_default_html_version, :yjit
27
+
28
+ attr_reader :encoding, :api_only, :loaded_config_version, :log_level
29
+
30
+ def initialize(*)
31
+ super
32
+ self.encoding = Encoding::UTF_8
33
+ @allow_concurrency = nil
34
+ @consider_all_requests_local = false
35
+ @filter_parameters = []
36
+ @filter_redirect = []
37
+ @helpers_paths = []
38
+ if Rails.env.development?
39
+ @hosts = ActionDispatch::HostAuthorization::ALLOWED_HOSTS_IN_DEVELOPMENT +
40
+ ENV["RAILS_DEVELOPMENT_HOSTS"].to_s.split(",").map(&:strip)
41
+ else
42
+ @hosts = []
43
+ end
44
+ @host_authorization = {}
45
+ @public_file_server = ActiveSupport::OrderedOptions.new
46
+ @public_file_server.enabled = true
47
+ @public_file_server.index_name = "index"
48
+ @assume_ssl = false
49
+ @force_ssl = false
50
+ @ssl_options = {}
51
+ @session_store = nil
52
+ @time_zone = "UTC"
53
+ @beginning_of_week = :monday
54
+ @log_level = :debug
55
+ @log_file_size = nil
56
+ @generators = app_generators
57
+ @cache_store = [ :file_store, "#{root}/tmp/cache/" ]
58
+ @railties_order = [:all]
59
+ @relative_url_root = ENV["RAILS_RELATIVE_URL_ROOT"]
60
+ @reload_classes_only_on_change = true
61
+ @file_watcher = ActiveSupport::FileUpdateChecker
62
+ @exceptions_app = nil
63
+ @autoflush_log = true
64
+ @log_formatter = ActiveSupport::Logger::SimpleFormatter.new
65
+ @silence_healthcheck_path = nil
66
+ @eager_load = nil
67
+ @secret_key_base = nil
68
+ @api_only = false
69
+ @debug_exception_response_format = nil
70
+ @x = Custom.new
71
+ @content_security_policy = nil
72
+ @content_security_policy_report_only = false
73
+ @content_security_policy_nonce_generator = nil
74
+ @content_security_policy_nonce_directives = nil
75
+ @require_master_key = false
76
+ @loaded_config_version = nil
77
+ @credentials = ActiveSupport::InheritableOptions.new(credentials_defaults)
78
+ @disable_sandbox = false
79
+ @sandbox_by_default = false
80
+ @add_autoload_paths_to_load_path = true
81
+ @permissions_policy = nil
82
+ @rake_eager_load = false
83
+ @server_timing = false
84
+ @dom_testing_default_html_version = :html4
85
+ @yjit = false
86
+ end
87
+
88
+ # Loads default configuration values for a target version. This includes
89
+ # defaults for versions prior to the target version. See the
90
+ # {configuration guide}[https://guides.rubyonrails.org/configuring.html#versioned-default-values]
91
+ # for the default values associated with a particular version.
92
+ def load_defaults(target_version)
93
+ # To introduce a change in behavior, follow these steps:
94
+ # 1. Add an accessor on the target object (e.g. the ActiveJob class for
95
+ # global Active Job config).
96
+ # 2. Set a default value there preserving existing behavior for existing
97
+ # applications.
98
+ # 3. Implement the behavior change based on the config value.
99
+ # 4. In the section below corresponding to the next release of Rails,
100
+ # configure the default value.
101
+ # 5. Add a commented out section in the `new_framework_defaults` to
102
+ # configure the default value again.
103
+ # 6. Update the guide in `configuring.md`.
104
+
105
+ # To remove configurable deprecated behavior, follow these steps:
106
+ # 1. Update or remove the entry in the guides.
107
+ # 2. Remove the references below.
108
+ # 3. Remove the legacy code paths and config check.
109
+ # 4. Remove the config accessor.
110
+
111
+ case target_version.to_s
112
+ when "5.0"
113
+ if respond_to?(:action_controller)
114
+ action_controller.per_form_csrf_tokens = true
115
+ action_controller.forgery_protection_origin_check = true
116
+ end
117
+
118
+ if respond_to?(:active_support)
119
+ active_support.to_time_preserves_timezone = :offset
120
+ end
121
+
122
+ if respond_to?(:active_record)
123
+ active_record.belongs_to_required_by_default = true
124
+ end
125
+
126
+ self.ssl_options = { hsts: { subdomains: true } }
127
+ when "5.1"
128
+ load_defaults "5.0"
129
+
130
+ if respond_to?(:assets)
131
+ assets.unknown_asset_fallback = false
132
+ end
133
+
134
+ if respond_to?(:action_view)
135
+ action_view.form_with_generates_remote_forms = true
136
+ end
137
+ when "5.2"
138
+ load_defaults "5.1"
139
+
140
+ if respond_to?(:active_record)
141
+ active_record.cache_versioning = true
142
+ end
143
+
144
+ if respond_to?(:action_dispatch)
145
+ action_dispatch.use_authenticated_cookie_encryption = true
146
+ end
147
+
148
+ if respond_to?(:active_support)
149
+ active_support.use_authenticated_message_encryption = true
150
+ active_support.hash_digest_class = OpenSSL::Digest::SHA1
151
+ end
152
+
153
+ if respond_to?(:action_controller)
154
+ action_controller.default_protect_from_forgery = true
155
+ end
156
+
157
+ if respond_to?(:action_view)
158
+ action_view.form_with_generates_ids = true
159
+ end
160
+ when "6.0"
161
+ load_defaults "5.2"
162
+
163
+ if respond_to?(:action_view)
164
+ action_view.default_enforce_utf8 = false
165
+ end
166
+
167
+ if respond_to?(:action_dispatch)
168
+ action_dispatch.use_cookies_with_metadata = true
169
+ end
170
+
171
+ if respond_to?(:action_mailer)
172
+ action_mailer.delivery_job = "ActionMailer::MailDeliveryJob"
173
+ end
174
+
175
+ if respond_to?(:active_storage)
176
+ active_storage.queues.analysis = :active_storage_analysis
177
+ active_storage.queues.purge = :active_storage_purge
178
+ end
179
+
180
+ if respond_to?(:active_record)
181
+ active_record.collection_cache_versioning = true
182
+ end
183
+ when "6.1"
184
+ load_defaults "6.0"
185
+
186
+ if respond_to?(:active_record)
187
+ active_record.has_many_inversing = true
188
+ end
189
+
190
+ if respond_to?(:active_job)
191
+ active_job.retry_jitter = 0.15
192
+ end
193
+
194
+ if respond_to?(:action_dispatch)
195
+ action_dispatch.cookies_same_site_protection = :lax
196
+ action_dispatch.ssl_default_redirect_status = 308
197
+ end
198
+
199
+ if respond_to?(:action_view)
200
+ action_view.form_with_generates_remote_forms = false
201
+ action_view.preload_links_header = true
202
+ end
203
+
204
+ if respond_to?(:active_storage)
205
+ active_storage.track_variants = true
206
+
207
+ active_storage.queues.analysis = nil
208
+ active_storage.queues.purge = nil
209
+ end
210
+
211
+ if respond_to?(:action_mailbox)
212
+ action_mailbox.queues.incineration = nil
213
+ action_mailbox.queues.routing = nil
214
+ end
215
+
216
+ if respond_to?(:action_mailer)
217
+ action_mailer.deliver_later_queue_name = nil
218
+ end
219
+
220
+ ActiveSupport.utc_to_local_returns_utc_offset_times = true
221
+ when "7.0"
222
+ load_defaults "6.1"
223
+
224
+ if respond_to?(:action_dispatch)
225
+ action_dispatch.default_headers = {
226
+ "X-Frame-Options" => "SAMEORIGIN",
227
+ "X-XSS-Protection" => "0",
228
+ "X-Content-Type-Options" => "nosniff",
229
+ "X-Download-Options" => "noopen",
230
+ "X-Permitted-Cross-Domain-Policies" => "none",
231
+ "Referrer-Policy" => "strict-origin-when-cross-origin"
232
+ }
233
+ action_dispatch.cookies_serializer = :json
234
+ end
235
+
236
+ if respond_to?(:action_view)
237
+ action_view.button_to_generates_button_tag = true
238
+ action_view.apply_stylesheet_media_default = false
239
+ end
240
+
241
+ if respond_to?(:active_support)
242
+ active_support.hash_digest_class = OpenSSL::Digest::SHA256
243
+ active_support.key_generator_hash_digest_class = OpenSSL::Digest::SHA256
244
+ active_support.cache_format_version = 7.0
245
+ active_support.executor_around_test_case = true
246
+ end
247
+
248
+ if respond_to?(:action_mailer)
249
+ action_mailer.smtp_timeout = 5
250
+ end
251
+
252
+ if respond_to?(:active_storage)
253
+ active_storage.video_preview_arguments =
254
+ "-vf 'select=eq(n\\,0)+eq(key\\,1)+gt(scene\\,0.015),loop=loop=-1:size=2,trim=start_frame=1'" \
255
+ " -frames:v 1 -f image2"
256
+
257
+ active_storage.variant_processor = :vips
258
+ active_storage.multiple_file_field_include_hidden = true
259
+ end
260
+
261
+ if respond_to?(:active_record)
262
+ active_record.verify_foreign_keys_for_fixtures = true
263
+ active_record.partial_inserts = false
264
+ active_record.automatic_scope_inversing = true
265
+ end
266
+
267
+ if respond_to?(:action_controller)
268
+ action_controller.raise_on_open_redirects = true
269
+ action_controller.wrap_parameters_by_default = true
270
+ end
271
+ when "7.1"
272
+ load_defaults "7.0"
273
+
274
+ self.add_autoload_paths_to_load_path = false
275
+ self.precompile_filter_parameters = true
276
+ self.dom_testing_default_html_version = defined?(Nokogiri::HTML5) ? :html5 : :html4
277
+
278
+ if Rails.env.local?
279
+ self.log_file_size = 100 * 1024 * 1024
280
+ end
281
+
282
+ if respond_to?(:active_record)
283
+ active_record.run_commit_callbacks_on_first_saved_instances_in_transaction = false
284
+ active_record.sqlite3_adapter_strict_strings_by_default = true
285
+ active_record.query_log_tags_format = :sqlcommenter
286
+ active_record.raise_on_assign_to_attr_readonly = true
287
+ active_record.belongs_to_required_validates_foreign_key = false
288
+ active_record.before_committed_on_all_records = true
289
+ active_record.default_column_serializer = nil
290
+ active_record.encryption.hash_digest_class = OpenSSL::Digest::SHA256
291
+ active_record.encryption.support_sha1_for_non_deterministic_encryption = false
292
+ active_record.marshalling_format_version = 7.1
293
+ active_record.run_after_transaction_callbacks_in_order_defined = true
294
+ active_record.generate_secure_token_on = :initialize
295
+ end
296
+
297
+ if respond_to?(:action_dispatch)
298
+ action_dispatch.default_headers = {
299
+ "X-Frame-Options" => "SAMEORIGIN",
300
+ "X-XSS-Protection" => "0",
301
+ "X-Content-Type-Options" => "nosniff",
302
+ "X-Permitted-Cross-Domain-Policies" => "none",
303
+ "Referrer-Policy" => "strict-origin-when-cross-origin"
304
+ }
305
+ action_dispatch.debug_exception_log_level = :error
306
+ end
307
+
308
+ if respond_to?(:active_support)
309
+ active_support.cache_format_version = 7.1
310
+ active_support.message_serializer = :json_allow_marshal
311
+ active_support.use_message_serializer_for_metadata = true
312
+ active_support.raise_on_invalid_cache_expiration_time = true
313
+ end
314
+
315
+ if respond_to?(:action_view)
316
+ require "action_view/helpers"
317
+ action_view.sanitizer_vendor = Rails::HTML::Sanitizer.best_supported_vendor
318
+ end
319
+
320
+ if respond_to?(:action_text)
321
+ require "action_view/helpers"
322
+ action_text.sanitizer_vendor = Rails::HTML::Sanitizer.best_supported_vendor
323
+ end
324
+ when "7.2"
325
+ load_defaults "7.1"
326
+
327
+ self.yjit = true
328
+
329
+ if respond_to?(:active_job)
330
+ active_job.enqueue_after_transaction_commit = :default
331
+ end
332
+
333
+ if respond_to?(:active_storage)
334
+ active_storage.web_image_content_types = %w( image/png image/jpeg image/gif image/webp )
335
+ end
336
+
337
+ if respond_to?(:active_record)
338
+ active_record.postgresql_adapter_decode_dates = true
339
+ active_record.validate_migration_timestamps = true
340
+ end
341
+ when "8.0"
342
+ load_defaults "7.2"
343
+
344
+ if respond_to?(:active_support)
345
+ active_support.to_time_preserves_timezone = :zone
346
+ end
347
+
348
+ if respond_to?(:action_dispatch)
349
+ action_dispatch.strict_freshness = true
350
+ end
351
+ else
352
+ raise "Unknown version #{target_version.to_s.inspect}"
353
+ end
354
+
355
+ @loaded_config_version = target_version
356
+ end
357
+
358
+ def reloading_enabled?
359
+ enable_reloading
360
+ end
361
+
362
+ def enable_reloading
363
+ !cache_classes
364
+ end
365
+
366
+ def enable_reloading=(value)
367
+ self.cache_classes = !value
368
+ end
369
+
370
+ def read_encrypted_secrets
371
+ Rails.deprecator.warn("'config.read_encrypted_secrets' is deprecated and will be removed in Rails 8.0.")
372
+ end
373
+
374
+ def read_encrypted_secrets=(value)
375
+ Rails.deprecator.warn("'config.read_encrypted_secrets=' is deprecated and will be removed in Rails 8.0.")
376
+ end
377
+
378
+ def encoding=(value)
379
+ @encoding = value
380
+ silence_warnings do
381
+ Encoding.default_external = value
382
+ Encoding.default_internal = value
383
+ end
384
+ end
385
+
386
+ def api_only=(value)
387
+ @api_only = value
388
+ generators.api_only = value
389
+
390
+ @debug_exception_response_format ||= :api
391
+ end
392
+
393
+ def log_level=(level)
394
+ @log_level = level
395
+ @broadcast_log_level = level
396
+ end
397
+
398
+ attr_reader :broadcast_log_level # :nodoc:
399
+
400
+ def debug_exception_response_format
401
+ @debug_exception_response_format || :default
402
+ end
403
+
404
+ attr_writer :debug_exception_response_format
405
+
406
+ def paths
407
+ @paths ||= begin
408
+ paths = super
409
+ paths.add "config/database", with: "config/database.yml"
410
+ paths.add "config/environment", with: "config/environment.rb"
411
+ paths.add "lib/templates"
412
+ paths.add "log", with: "log/#{Rails.env}.log"
413
+ paths.add "public"
414
+ paths.add "public/javascripts"
415
+ paths.add "public/stylesheets"
416
+ paths.add "tmp"
417
+ paths
418
+ end
419
+ end
420
+
421
+ # Load the <tt>config/database.yml</tt> to create the Rake tasks for
422
+ # multiple databases without loading the environment and filling in the
423
+ # environment specific configuration values.
424
+ #
425
+ # Do not use this method, use #database_configuration instead.
426
+ def load_database_yaml # :nodoc:
427
+ if path = paths["config/database"].existent.first
428
+ require "rails/application/dummy_config"
429
+ original_rails_config = Rails.application.config
430
+
431
+ begin
432
+ Rails.application.config = DummyConfig.new(original_rails_config)
433
+ ActiveSupport::ConfigurationFile.parse(Pathname.new(path))
434
+ ensure
435
+ Rails.application.config = original_rails_config
436
+ end
437
+ else
438
+ {}
439
+ end
440
+ end
441
+
442
+ # Loads and returns the entire raw configuration of database from
443
+ # values stored in <tt>config/database.yml</tt>.
444
+ def database_configuration
445
+ path = paths["config/database"].existent.first
446
+ yaml = Pathname.new(path) if path
447
+
448
+ config = if yaml&.exist?
449
+ loaded_yaml = ActiveSupport::ConfigurationFile.parse(yaml)
450
+ if (shared = loaded_yaml.delete("shared"))
451
+ loaded_yaml.each do |env, config|
452
+ if config.is_a?(Hash) && config.values.all?(Hash)
453
+ if shared.is_a?(Hash) && shared.values.all?(Hash)
454
+ config.map do |name, sub_config|
455
+ sub_config.reverse_merge!(shared[name])
456
+ end
457
+ else
458
+ config.map do |name, sub_config|
459
+ sub_config.reverse_merge!(shared)
460
+ end
461
+ end
462
+ else
463
+ config.reverse_merge!(shared)
464
+ end
465
+ end
466
+ end
467
+ Hash.new(shared).merge(loaded_yaml)
468
+ elsif ENV["DATABASE_URL"]
469
+ # Value from ENV['DATABASE_URL'] is set to default database connection
470
+ # by Active Record.
471
+ {}
472
+ else
473
+ raise "Could not load database configuration. No such file - #{paths["config/database"].instance_variable_get(:@paths)}"
474
+ end
475
+
476
+ config
477
+ rescue => e
478
+ raise e, "Cannot load database configuration:\n#{e.message}", e.backtrace
479
+ end
480
+
481
+ def autoload_lib(ignore:)
482
+ lib = root.join("lib")
483
+
484
+ # Set as a string to have the same type as default autoload paths, for
485
+ # consistency.
486
+ autoload_paths << lib.to_s
487
+ eager_load_paths << lib.to_s
488
+
489
+ ignored_abspaths = Array.wrap(ignore).map { lib.join(_1) }
490
+ Rails.autoloaders.main.ignore(ignored_abspaths)
491
+ end
492
+
493
+ def autoload_lib_once(ignore:)
494
+ lib = root.join("lib")
495
+
496
+ # Set as a string to have the same type as default autoload paths, for
497
+ # consistency.
498
+ autoload_once_paths << lib.to_s
499
+ eager_load_paths << lib.to_s
500
+
501
+ ignored_abspaths = Array.wrap(ignore).map { lib.join(_1) }
502
+ Rails.autoloaders.once.ignore(ignored_abspaths)
503
+ end
504
+
505
+ def colorize_logging
506
+ ActiveSupport::LogSubscriber.colorize_logging
507
+ end
508
+
509
+ def colorize_logging=(val)
510
+ ActiveSupport::LogSubscriber.colorize_logging = val
511
+ generators.colorize_logging = val
512
+ end
513
+
514
+ def secret_key_base
515
+ @secret_key_base || begin
516
+ self.secret_key_base = if generate_local_secret?
517
+ generate_local_secret
518
+ else
519
+ ENV["SECRET_KEY_BASE"] || Rails.application.credentials.secret_key_base
520
+ end
521
+ end
522
+ end
523
+
524
+ def secret_key_base=(new_secret_key_base)
525
+ if new_secret_key_base.nil? && generate_local_secret?
526
+ @secret_key_base = generate_local_secret
527
+ elsif new_secret_key_base.is_a?(String) && new_secret_key_base.present?
528
+ @secret_key_base = new_secret_key_base
529
+ elsif new_secret_key_base
530
+ raise ArgumentError, "`secret_key_base` for #{Rails.env} environment must be a type of String`"
531
+ else
532
+ raise ArgumentError, "Missing `secret_key_base` for '#{Rails.env}' environment, set this string with `bin/rails credentials:edit`"
533
+ end
534
+ end
535
+
536
+ # Specifies what class to use to store the session. Possible values
537
+ # are +:cache_store+, +:cookie_store+, +:mem_cache_store+, a custom
538
+ # store, or +:disabled+. +:disabled+ tells \Rails not to deal with
539
+ # sessions.
540
+ #
541
+ # Additional options will be set as +session_options+:
542
+ #
543
+ # config.session_store :cookie_store, key: "_your_app_session"
544
+ # config.session_options # => {key: "_your_app_session"}
545
+ #
546
+ # If a custom store is specified as a symbol, it will be resolved to
547
+ # the +ActionDispatch::Session+ namespace:
548
+ #
549
+ # # use ActionDispatch::Session::MyCustomStore as the session store
550
+ # config.session_store :my_custom_store
551
+ def session_store(new_session_store = nil, **options)
552
+ if new_session_store
553
+ @session_store = new_session_store
554
+ @session_options = options || {}
555
+ else
556
+ case @session_store
557
+ when :disabled
558
+ nil
559
+ when Symbol
560
+ ActionDispatch::Session.resolve_store(@session_store)
561
+ else
562
+ @session_store
563
+ end
564
+ end
565
+ end
566
+
567
+ def session_store? # :nodoc:
568
+ @session_store
569
+ end
570
+
571
+ def annotations
572
+ Rails::SourceAnnotationExtractor::Annotation
573
+ end
574
+
575
+ # Configures the ActionDispatch::ContentSecurityPolicy.
576
+ def content_security_policy(&block)
577
+ if block_given?
578
+ @content_security_policy = ActionDispatch::ContentSecurityPolicy.new(&block)
579
+ else
580
+ @content_security_policy
581
+ end
582
+ end
583
+
584
+ # Configures the ActionDispatch::PermissionsPolicy.
585
+ def permissions_policy(&block)
586
+ if block_given?
587
+ @permissions_policy = ActionDispatch::PermissionsPolicy.new(&block)
588
+ else
589
+ @permissions_policy
590
+ end
591
+ end
592
+
593
+ def default_log_file
594
+ path = paths["log"].first
595
+ unless File.exist? File.dirname path
596
+ FileUtils.mkdir_p File.dirname path
597
+ end
598
+
599
+ f = File.open path, "a"
600
+ f.binmode
601
+ f.sync = autoflush_log # if true make sure every write flushes
602
+ f
603
+ end
604
+
605
+ def inspect # :nodoc:
606
+ "#<#{self.class.name}:#{'%#016x' % (object_id << 1)}>"
607
+ end
608
+
609
+ class Custom # :nodoc:
610
+ def initialize
611
+ @configurations = Hash.new
612
+ end
613
+
614
+ def method_missing(method, *args)
615
+ if method.end_with?("=")
616
+ @configurations[:"#{method[0..-2]}"] = args.first
617
+ elsif args.empty?
618
+ @configurations.fetch(method) {
619
+ @configurations[method] = ActiveSupport::OrderedOptions.new
620
+ }
621
+ else
622
+ raise ArgumentError, "wrong number of arguments (given #{args.length}, expected 0) when reading configuration `#{method}`"
623
+ end
624
+ end
625
+
626
+ def respond_to_missing?(symbol, _)
627
+ true
628
+ end
629
+ end
630
+
631
+ private
632
+ def credentials_defaults
633
+ content_path = root.join("config/credentials/#{Rails.env}.yml.enc")
634
+ content_path = root.join("config/credentials.yml.enc") if !content_path.exist?
635
+
636
+ key_path = root.join("config/credentials/#{Rails.env}.key")
637
+ key_path = root.join("config/master.key") if !key_path.exist?
638
+
639
+ { content_path: content_path, key_path: key_path }
640
+ end
641
+
642
+ def generate_local_secret
643
+ key_file = root.join("tmp/local_secret.txt")
644
+
645
+ unless File.exist?(key_file)
646
+ random_key = SecureRandom.hex(64)
647
+ FileUtils.mkdir_p(key_file.dirname)
648
+ File.binwrite(key_file, random_key)
649
+ end
650
+
651
+ File.binread(key_file)
652
+ end
653
+
654
+ def generate_local_secret?
655
+ Rails.env.local? || ENV["SECRET_KEY_BASE_DUMMY"]
656
+ end
657
+ end
658
+ end
659
+ end