railties 6.0.0 → 7.1.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (286) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +699 -245
  3. data/MIT-LICENSE +1 -1
  4. data/RDOC_MAIN.md +99 -0
  5. data/README.rdoc +7 -8
  6. data/lib/minitest/rails_plugin.rb +80 -2
  7. data/lib/rails/all.rb +0 -1
  8. data/lib/rails/api/task.rb +37 -5
  9. data/lib/rails/app_updater.rb +9 -6
  10. data/lib/rails/application/bootstrap.rb +52 -14
  11. data/lib/rails/application/configuration.rb +327 -86
  12. data/lib/rails/application/default_middleware_stack.rb +33 -7
  13. data/lib/rails/application/dummy_config.rb +19 -0
  14. data/lib/rails/application/finisher.rb +94 -113
  15. data/lib/rails/application/routes_reloader.rb +17 -3
  16. data/lib/rails/application.rb +258 -201
  17. data/lib/rails/application_controller.rb +3 -4
  18. data/lib/rails/autoloaders/inflector.rb +21 -0
  19. data/lib/rails/autoloaders.rb +42 -42
  20. data/lib/rails/backtrace_cleaner.rb +13 -8
  21. data/lib/rails/cli.rb +5 -2
  22. data/lib/rails/code_statistics.rb +6 -4
  23. data/lib/rails/code_statistics_calculator.rb +16 -7
  24. data/lib/rails/command/actions.rb +10 -12
  25. data/lib/rails/command/base.rb +66 -46
  26. data/lib/rails/command/behavior.rb +3 -3
  27. data/lib/rails/command/environment_argument.rb +33 -17
  28. data/lib/rails/command/helpers/editor.rb +17 -12
  29. data/lib/rails/command.rb +90 -32
  30. data/lib/rails/commands/about/about_command.rb +14 -0
  31. data/lib/rails/commands/application/application_command.rb +2 -0
  32. data/lib/rails/commands/console/console_command.rb +17 -13
  33. data/lib/rails/commands/credentials/USAGE +54 -39
  34. data/lib/rails/commands/credentials/credentials_command/diffing.rb +53 -0
  35. data/lib/rails/commands/credentials/credentials_command.rb +83 -60
  36. data/lib/rails/commands/db/system/change/change_command.rb +8 -2
  37. data/lib/rails/commands/dbconsole/dbconsole_command.rb +39 -124
  38. data/lib/rails/commands/destroy/destroy_command.rb +3 -2
  39. data/lib/rails/commands/dev/dev_command.rb +1 -6
  40. data/lib/rails/commands/encrypted/USAGE +15 -20
  41. data/lib/rails/commands/encrypted/encrypted_command.rb +46 -35
  42. data/lib/rails/commands/gem_help/USAGE +16 -0
  43. data/lib/rails/commands/gem_help/gem_help_command.rb +13 -0
  44. data/lib/rails/commands/generate/generate_command.rb +3 -3
  45. data/lib/rails/commands/help/USAGE +15 -14
  46. data/lib/rails/commands/help/help_command.rb +21 -2
  47. data/lib/rails/commands/initializers/initializers_command.rb +1 -4
  48. data/lib/rails/commands/middleware/middleware_command.rb +17 -0
  49. data/lib/rails/commands/new/new_command.rb +2 -0
  50. data/lib/rails/commands/notes/notes_command.rb +5 -14
  51. data/lib/rails/commands/plugin/plugin_command.rb +2 -0
  52. data/lib/rails/commands/rake/rake_command.rb +27 -23
  53. data/lib/rails/commands/restart/restart_command.rb +14 -0
  54. data/lib/rails/commands/routes/routes_command.rb +13 -1
  55. data/lib/rails/commands/runner/USAGE +14 -12
  56. data/lib/rails/commands/runner/runner_command.rb +34 -21
  57. data/lib/rails/commands/secret/secret_command.rb +13 -0
  58. data/lib/rails/commands/secrets/USAGE +44 -43
  59. data/lib/rails/commands/secrets/secrets_command.rb +20 -38
  60. data/lib/rails/commands/server/server_command.rb +40 -64
  61. data/lib/rails/commands/test/USAGE +14 -0
  62. data/lib/rails/commands/test/test_command.rb +58 -16
  63. data/lib/rails/commands/unused_routes/unused_routes_command.rb +75 -0
  64. data/lib/rails/commands/version/version_command.rb +1 -0
  65. data/lib/rails/configuration.rb +53 -23
  66. data/lib/rails/console/app.rb +1 -4
  67. data/lib/rails/console/helpers.rb +2 -2
  68. data/lib/rails/deprecator.rb +7 -0
  69. data/lib/rails/engine/configuration.rb +54 -9
  70. data/lib/rails/engine/updater.rb +1 -1
  71. data/lib/rails/engine.rb +105 -81
  72. data/lib/rails/gem_version.rb +5 -5
  73. data/lib/rails/generators/actions/create_migration.rb +9 -5
  74. data/lib/rails/generators/actions.rb +275 -97
  75. data/lib/rails/generators/active_model.rb +28 -14
  76. data/lib/rails/generators/app_base.rb +487 -165
  77. data/lib/rails/generators/app_name.rb +3 -14
  78. data/lib/rails/generators/base.rb +42 -31
  79. data/lib/rails/generators/database.rb +41 -4
  80. data/lib/rails/generators/erb/mailer/mailer_generator.rb +0 -1
  81. data/lib/rails/generators/erb/mailer/templates/layout.html.erb.tt +1 -1
  82. data/lib/rails/generators/erb/scaffold/scaffold_generator.rb +2 -1
  83. data/lib/rails/generators/erb/scaffold/templates/_form.html.erb.tt +11 -11
  84. data/lib/rails/generators/erb/scaffold/templates/edit.html.erb.tt +8 -4
  85. data/lib/rails/generators/erb/scaffold/templates/index.html.erb.tt +11 -28
  86. data/lib/rails/generators/erb/scaffold/templates/new.html.erb.tt +7 -3
  87. data/lib/rails/generators/erb/scaffold/templates/partial.html.erb.tt +17 -0
  88. data/lib/rails/generators/erb/scaffold/templates/show.html.erb.tt +8 -17
  89. data/lib/rails/generators/erb.rb +1 -2
  90. data/lib/rails/generators/generated_attribute.rb +60 -19
  91. data/lib/rails/generators/migration.rb +4 -8
  92. data/lib/rails/generators/model_helpers.rb +29 -4
  93. data/lib/rails/generators/named_base.rb +15 -15
  94. data/lib/rails/generators/rails/app/USAGE +23 -6
  95. data/lib/rails/generators/rails/app/app_generator.rb +151 -80
  96. data/lib/rails/generators/rails/app/templates/Dockerfile.tt +103 -0
  97. data/lib/rails/generators/rails/app/templates/Gemfile.tt +44 -54
  98. data/lib/rails/generators/rails/app/templates/Rakefile.tt +1 -1
  99. data/lib/rails/generators/rails/app/templates/app/assets/stylesheets/application.css.tt +2 -2
  100. data/lib/rails/generators/rails/app/templates/app/mailers/application_mailer.rb.tt +2 -2
  101. data/lib/rails/generators/rails/app/templates/app/models/application_record.rb.tt +1 -1
  102. data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +4 -9
  103. data/lib/rails/generators/rails/app/templates/app/views/layouts/mailer.html.erb.tt +1 -1
  104. data/lib/rails/generators/rails/app/templates/bin/rails.tt +3 -3
  105. data/lib/rails/generators/rails/app/templates/bin/rake.tt +2 -2
  106. data/lib/rails/generators/rails/app/templates/bin/setup.tt +19 -15
  107. data/lib/rails/generators/rails/app/templates/config/application.rb.tt +18 -23
  108. data/lib/rails/generators/rails/app/templates/config/boot.rb.tt +3 -3
  109. data/lib/rails/generators/rails/app/templates/config/databases/jdbc.yml.tt +5 -6
  110. data/lib/rails/generators/rails/app/templates/config/databases/jdbcmysql.yml.tt +12 -11
  111. data/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml.tt +17 -16
  112. data/lib/rails/generators/rails/app/templates/config/databases/jdbcsqlite3.yml.tt +5 -5
  113. data/lib/rails/generators/rails/app/templates/config/databases/mysql.yml.tt +12 -11
  114. data/lib/rails/generators/rails/app/templates/config/databases/oracle.yml.tt +12 -11
  115. data/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml.tt +17 -18
  116. data/lib/rails/generators/rails/app/templates/config/databases/sqlite3.yml.tt +4 -4
  117. data/lib/rails/generators/rails/app/templates/config/databases/sqlserver.yml.tt +14 -13
  118. data/lib/rails/generators/rails/app/templates/config/databases/trilogy.yml.tt +59 -0
  119. data/lib/rails/generators/rails/app/templates/config/environment.rb.tt +1 -1
  120. data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +32 -14
  121. data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +42 -55
  122. data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +27 -15
  123. data/lib/rails/generators/rails/app/templates/config/initializers/assets.rb.tt +3 -5
  124. data/lib/rails/generators/rails/app/templates/config/initializers/content_security_policy.rb.tt +21 -28
  125. data/lib/rails/generators/rails/app/templates/config/initializers/cors.rb.tt +3 -3
  126. data/lib/rails/generators/rails/app/templates/config/initializers/filter_parameter_logging.rb.tt +6 -2
  127. data/lib/rails/generators/rails/app/templates/config/initializers/inflections.rb.tt +4 -4
  128. data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_7_1.rb.tt +284 -0
  129. data/lib/rails/generators/rails/app/templates/config/initializers/permissions_policy.rb.tt +13 -0
  130. data/lib/rails/generators/rails/app/templates/config/locales/en.yml +13 -15
  131. data/lib/rails/generators/rails/app/templates/config/puma.rb.tt +17 -20
  132. data/lib/rails/generators/rails/app/templates/config/routes.rb.tt +8 -1
  133. data/lib/rails/generators/rails/app/templates/config/storage.yml.tt +5 -5
  134. data/lib/rails/generators/rails/app/templates/config.ru.tt +2 -1
  135. data/lib/rails/generators/rails/app/templates/db/seeds.rb.tt +7 -5
  136. data/lib/rails/generators/rails/app/templates/docker-entrypoint.tt +10 -0
  137. data/lib/rails/generators/rails/app/templates/dockerignore.tt +43 -0
  138. data/lib/rails/generators/rails/app/templates/gitattributes.tt +9 -0
  139. data/lib/rails/generators/rails/app/templates/gitignore.tt +12 -9
  140. data/lib/rails/generators/rails/app/templates/node-version.tt +1 -0
  141. data/lib/rails/generators/rails/app/templates/test/channels/application_cable/connection_test.rb.tt +10 -8
  142. data/lib/rails/generators/rails/app/templates/test/test_helper.rb.tt +13 -11
  143. data/lib/rails/generators/rails/application_record/application_record_generator.rb +4 -0
  144. data/lib/rails/generators/rails/benchmark/USAGE +19 -0
  145. data/lib/rails/generators/rails/benchmark/benchmark_generator.rb +30 -0
  146. data/lib/rails/generators/rails/benchmark/templates/benchmark.rb.tt +15 -0
  147. data/lib/rails/generators/rails/controller/USAGE +13 -5
  148. data/lib/rails/generators/rails/controller/controller_generator.rb +7 -42
  149. data/lib/rails/generators/rails/controller/templates/controller.rb.tt +1 -5
  150. data/lib/rails/generators/rails/credentials/credentials_generator.rb +30 -25
  151. data/lib/rails/generators/rails/credentials/templates/credentials.yml.tt +8 -0
  152. data/lib/rails/generators/rails/db/system/change/change_generator.rb +31 -1
  153. data/lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb +6 -2
  154. data/lib/rails/generators/rails/encryption_key_file/encryption_key_file_generator.rb +1 -2
  155. data/lib/rails/generators/rails/generator/USAGE +2 -2
  156. data/lib/rails/generators/rails/generator/generator_generator.rb +0 -1
  157. data/lib/rails/generators/rails/generator/templates/%file_name%_generator.rb.tt +1 -1
  158. data/lib/rails/generators/rails/generator/templates/USAGE.tt +1 -1
  159. data/lib/rails/generators/rails/helper/USAGE +2 -3
  160. data/lib/rails/generators/rails/integration_test/USAGE +2 -2
  161. data/lib/rails/generators/rails/migration/USAGE +22 -12
  162. data/lib/rails/generators/rails/model/model_generator.rb +4 -0
  163. data/lib/rails/generators/rails/plugin/USAGE +17 -6
  164. data/lib/rails/generators/rails/plugin/plugin_generator.rb +86 -46
  165. data/lib/rails/generators/rails/plugin/templates/%name%.gemspec.tt +15 -20
  166. data/lib/rails/generators/rails/plugin/templates/Gemfile.tt +10 -39
  167. data/lib/rails/generators/rails/plugin/templates/MIT-LICENSE.tt +1 -1
  168. data/lib/rails/generators/rails/plugin/templates/README.md.tt +1 -1
  169. data/lib/rails/generators/rails/plugin/templates/Rakefile.tt +4 -18
  170. data/lib/rails/generators/rails/plugin/templates/app/controllers/%namespaced_name%/application_controller.rb.tt +0 -1
  171. data/lib/rails/generators/rails/plugin/templates/app/mailers/%namespaced_name%/application_mailer.rb.tt +2 -2
  172. data/lib/rails/generators/rails/plugin/templates/app/views/layouts/%namespaced_name%/application.html.erb.tt +0 -3
  173. data/lib/rails/generators/rails/plugin/templates/bin/rails.tt +7 -22
  174. data/lib/rails/generators/rails/plugin/templates/gitignore.tt +10 -14
  175. data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/engine.rb.tt +2 -2
  176. data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/version.rb.tt +1 -1
  177. data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%.rb.tt +1 -0
  178. data/lib/rails/generators/rails/plugin/templates/rails/boot.rb.tt +3 -3
  179. data/lib/rails/generators/rails/plugin/templates/test/%namespaced_name%_test.rb.tt +4 -4
  180. data/lib/rails/generators/rails/plugin/templates/test/integration/navigation_test.rb.tt +1 -1
  181. data/lib/rails/generators/rails/plugin/templates/test/test_helper.rb.tt +6 -14
  182. data/lib/rails/generators/rails/resource/USAGE +4 -4
  183. data/lib/rails/generators/rails/resource/resource_generator.rb +6 -0
  184. data/lib/rails/generators/rails/resource_route/resource_route_generator.rb +2 -27
  185. data/lib/rails/generators/rails/scaffold/USAGE +5 -5
  186. data/lib/rails/generators/rails/scaffold/scaffold_generator.rb +2 -20
  187. data/lib/rails/generators/rails/scaffold_controller/USAGE +2 -2
  188. data/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb +7 -2
  189. data/lib/rails/generators/rails/scaffold_controller/templates/api_controller.rb.tt +2 -6
  190. data/lib/rails/generators/rails/scaffold_controller/templates/controller.rb.tt +7 -11
  191. data/lib/rails/generators/rails/system_test/USAGE +2 -2
  192. data/lib/rails/generators/rails/task/USAGE +3 -3
  193. data/lib/rails/generators/resource_helpers.rb +2 -2
  194. data/lib/rails/generators/test_case.rb +3 -3
  195. data/lib/rails/generators/test_unit/controller/controller_generator.rb +2 -0
  196. data/lib/rails/generators/test_unit/controller/templates/functional_test.rb.tt +3 -3
  197. data/lib/rails/generators/test_unit/generator/generator_generator.rb +0 -1
  198. data/lib/rails/generators/test_unit/generator/templates/generator_test.rb.tt +3 -3
  199. data/lib/rails/generators/test_unit/integration/integration_generator.rb +0 -1
  200. data/lib/rails/generators/test_unit/integration/templates/integration_test.rb.tt +1 -1
  201. data/lib/rails/generators/test_unit/job/templates/unit_test.rb.tt +1 -1
  202. data/lib/rails/generators/test_unit/mailer/templates/functional_test.rb.tt +1 -1
  203. data/lib/rails/generators/test_unit/model/templates/fixtures.yml.tt +3 -3
  204. data/lib/rails/generators/test_unit/model/templates/unit_test.rb.tt +1 -1
  205. data/lib/rails/generators/test_unit/plugin/templates/%file_name%_test.rb.tt +1 -1
  206. data/lib/rails/generators/test_unit/plugin/templates/test_helper.rb +2 -2
  207. data/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb +4 -5
  208. data/lib/rails/generators/test_unit/scaffold/templates/api_functional_test.rb.tt +6 -6
  209. data/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb.tt +8 -8
  210. data/lib/rails/generators/test_unit/scaffold/templates/system_test.rb.tt +9 -11
  211. data/lib/rails/generators/testing/assertions.rb +2 -2
  212. data/lib/rails/generators/testing/{behaviour.rb → behavior.rb} +8 -7
  213. data/lib/rails/generators.rb +43 -45
  214. data/lib/rails/health_controller.rb +55 -0
  215. data/lib/rails/info.rb +4 -4
  216. data/lib/rails/info_controller.rb +30 -13
  217. data/lib/rails/initializable.rb +1 -1
  218. data/lib/rails/mailers_controller.rb +18 -9
  219. data/lib/rails/paths.rb +28 -19
  220. data/lib/rails/rack/logger.rb +17 -17
  221. data/lib/rails/rackup/server.rb +15 -0
  222. data/lib/rails/railtie/configurable.rb +0 -1
  223. data/lib/rails/railtie/configuration.rb +15 -3
  224. data/lib/rails/railtie.rb +80 -37
  225. data/lib/rails/ruby_version_check.rb +5 -3
  226. data/lib/rails/secrets.rb +14 -9
  227. data/lib/rails/source_annotation_extractor.rb +69 -34
  228. data/lib/rails/tasks/engine.rake +8 -11
  229. data/lib/rails/tasks/framework.rake +4 -6
  230. data/lib/rails/tasks/log.rake +1 -1
  231. data/lib/rails/tasks/misc.rake +4 -15
  232. data/lib/rails/tasks/statistics.rake +9 -6
  233. data/lib/rails/tasks/tmp.rake +13 -6
  234. data/lib/rails/tasks/yarn.rake +17 -6
  235. data/lib/rails/tasks/zeitwerk.rake +16 -41
  236. data/lib/rails/tasks.rb +0 -6
  237. data/lib/rails/templates/layouts/application.html.erb +15 -0
  238. data/lib/rails/templates/rails/mailers/email.html.erb +46 -11
  239. data/lib/rails/templates/rails/mailers/index.html.erb +14 -7
  240. data/lib/rails/templates/rails/mailers/mailer.html.erb +11 -5
  241. data/lib/rails/templates/rails/welcome/index.html.erb +65 -48
  242. data/lib/rails/test_help.rb +13 -14
  243. data/lib/rails/test_unit/line_filtering.rb +1 -1
  244. data/lib/rails/test_unit/railtie.rb +0 -4
  245. data/lib/rails/test_unit/reporter.rb +8 -3
  246. data/lib/rails/test_unit/runner.rb +61 -19
  247. data/lib/rails/test_unit/test_parser.rb +88 -0
  248. data/lib/rails/test_unit/testing.rake +17 -36
  249. data/lib/rails/testing/maintain_test_schema.rb +16 -0
  250. data/lib/rails/version.rb +1 -1
  251. data/lib/rails/welcome_controller.rb +1 -0
  252. data/lib/rails/zeitwerk_checker.rb +15 -0
  253. data/lib/rails.rb +31 -23
  254. metadata +89 -58
  255. data/RDOC_MAIN.rdoc +0 -98
  256. data/lib/rails/application/dummy_erb_compiler.rb +0 -18
  257. data/lib/rails/command/spellchecker.rb +0 -58
  258. data/lib/rails/generators/css/assets/assets_generator.rb +0 -15
  259. data/lib/rails/generators/css/assets/templates/stylesheet.css +0 -4
  260. data/lib/rails/generators/css/scaffold/scaffold_generator.rb +0 -18
  261. data/lib/rails/generators/rails/app/templates/app/javascript/channels/consumer.js +0 -6
  262. data/lib/rails/generators/rails/app/templates/app/javascript/channels/index.js +0 -5
  263. data/lib/rails/generators/rails/app/templates/app/javascript/packs/application.js.tt +0 -23
  264. data/lib/rails/generators/rails/app/templates/bin/yarn.tt +0 -10
  265. data/lib/rails/generators/rails/app/templates/config/databases/frontbase.yml.tt +0 -50
  266. data/lib/rails/generators/rails/app/templates/config/databases/ibm_db.yml.tt +0 -86
  267. data/lib/rails/generators/rails/app/templates/config/initializers/application_controller_renderer.rb.tt +0 -8
  268. data/lib/rails/generators/rails/app/templates/config/initializers/backtrace_silencers.rb.tt +0 -7
  269. data/lib/rails/generators/rails/app/templates/config/initializers/cookies_serializer.rb.tt +0 -5
  270. data/lib/rails/generators/rails/app/templates/config/initializers/mime_types.rb.tt +0 -4
  271. data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_6_0.rb.tt +0 -45
  272. data/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt +0 -16
  273. data/lib/rails/generators/rails/app/templates/config/spring.rb.tt +0 -6
  274. data/lib/rails/generators/rails/app/templates/package.json.tt +0 -11
  275. data/lib/rails/generators/rails/assets/USAGE +0 -17
  276. data/lib/rails/generators/rails/assets/assets_generator.rb +0 -26
  277. data/lib/rails/generators/rails/assets/templates/stylesheet.css +0 -4
  278. data/lib/rails/generators/rails/model/USAGE +0 -114
  279. data/lib/rails/generators/rails/plugin/templates/rails/application.rb.tt +0 -23
  280. data/lib/rails/generators/rails/scaffold/templates/scaffold.css +0 -80
  281. data/lib/rails/tasks/annotations.rake +0 -22
  282. data/lib/rails/tasks/dev.rake +0 -11
  283. data/lib/rails/tasks/initializers.rake +0 -9
  284. data/lib/rails/tasks/middleware.rake +0 -9
  285. data/lib/rails/tasks/restart.rake +0 -9
  286. data/lib/rails/tasks/routes.rake +0 -9
@@ -10,7 +10,7 @@ module Rails
10
10
  end
11
11
 
12
12
  # Expose the eager_load_namespaces at "module" level for convenience.
13
- def self.eager_load_namespaces #:nodoc:
13
+ def self.eager_load_namespaces # :nodoc:
14
14
  @@eager_load_namespaces ||= []
15
15
  end
16
16
 
@@ -71,6 +71,11 @@ module Rails
71
71
  ActiveSupport.on_load(:after_initialize, yield: true, &block)
72
72
  end
73
73
 
74
+ # Called after application routes have been loaded.
75
+ def after_routes_loaded(&block)
76
+ ActiveSupport.on_load(:after_routes_loaded, yield: true, &block)
77
+ end
78
+
74
79
  # Array of callbacks defined by #to_prepare.
75
80
  def to_prepare_blocks
76
81
  @@to_prepare_blocks ||= []
@@ -87,10 +92,17 @@ module Rails
87
92
  end
88
93
 
89
94
  private
95
+ def actual_method?(key)
96
+ !@@options.key?(key) && respond_to?(key)
97
+ end
90
98
 
91
99
  def method_missing(name, *args, &blk)
92
- if name.to_s =~ /=$/
93
- @@options[$`.to_sym] = args.first
100
+ if name.end_with?("=")
101
+ key = name[0..-2].to_sym
102
+ if actual_method?(key)
103
+ raise NoMethodError.new("Cannot assign to `#{key}`, it is a configuration method")
104
+ end
105
+ @@options[key] = args.first
94
106
  elsif @@options.key?(name)
95
107
  @@options[name]
96
108
  else
data/lib/rails/railtie.rb CHANGED
@@ -1,39 +1,40 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "rails/initializable"
4
+ require "active_support/descendants_tracker"
4
5
  require "active_support/inflector"
5
6
  require "active_support/core_ext/module/introspection"
6
7
  require "active_support/core_ext/module/delegation"
7
8
 
8
9
  module Rails
9
- # <tt>Rails::Railtie</tt> is the core of the Rails framework and provides
10
- # several hooks to extend Rails and/or modify the initialization process.
10
+ # +Rails::Railtie+ is the core of the \Rails framework and provides
11
+ # several hooks to extend \Rails and/or modify the initialization process.
11
12
  #
12
- # Every major component of Rails (Action Mailer, Action Controller, Active
13
+ # Every major component of \Rails (Action Mailer, Action Controller, Active
13
14
  # Record, etc.) implements a railtie. Each of them is responsible for their
14
- # own initialization. This makes Rails itself absent of any component hooks,
15
- # allowing other components to be used in place of any of the Rails defaults.
15
+ # own initialization. This makes \Rails itself absent of any component hooks,
16
+ # allowing other components to be used in place of any of the \Rails defaults.
16
17
  #
17
- # Developing a Rails extension does _not_ require implementing a railtie, but
18
- # if you need to interact with the Rails framework during or after boot, then
18
+ # Developing a \Rails extension does _not_ require implementing a railtie, but
19
+ # if you need to interact with the \Rails framework during or after boot, then
19
20
  # a railtie is needed.
20
21
  #
21
22
  # For example, an extension doing any of the following would need a railtie:
22
23
  #
23
24
  # * creating initializers
24
- # * configuring a Rails framework for the application, like setting a generator
25
+ # * configuring a \Rails framework for the application, like setting a generator
25
26
  # * adding <tt>config.*</tt> keys to the environment
26
- # * setting up a subscriber with <tt>ActiveSupport::Notifications</tt>
27
+ # * setting up a subscriber with ActiveSupport::Notifications
27
28
  # * adding Rake tasks
28
29
  #
29
30
  # == Creating a Railtie
30
31
  #
31
- # To extend Rails using a railtie, create a subclass of <tt>Rails::Railtie</tt>.
32
- # This class must be loaded during the Rails boot process, and is conventionally
33
- # called <tt>MyNamespace::Railtie</tt>.
32
+ # To extend \Rails using a railtie, create a subclass of +Rails::Railtie+.
33
+ # This class must be loaded during the \Rails boot process, and is conventionally
34
+ # called +MyNamespace::Railtie+.
34
35
  #
35
36
  # The following example demonstrates an extension which can be used with or
36
- # without Rails.
37
+ # without \Rails.
37
38
  #
38
39
  # # lib/my_gem/railtie.rb
39
40
  # module MyGem
@@ -42,11 +43,11 @@ module Rails
42
43
  # end
43
44
  #
44
45
  # # lib/my_gem.rb
45
- # require 'my_gem/railtie' if defined?(Rails)
46
+ # require "my_gem/railtie" if defined?(Rails::Railtie)
46
47
  #
47
48
  # == Initializers
48
49
  #
49
- # To add an initialization step to the Rails boot process from your railtie, just
50
+ # To add an initialization step to the \Rails boot process from your railtie, just
50
51
  # define the initialization code with the +initializer+ macro:
51
52
  #
52
53
  # class MyRailtie < Rails::Railtie
@@ -86,38 +87,56 @@ module Rails
86
87
  #
87
88
  # == Loading Rake Tasks and Generators
88
89
  #
89
- # If your railtie has Rake tasks, you can tell Rails to load them through the method
90
+ # If your railtie has Rake tasks, you can tell \Rails to load them through the method
90
91
  # +rake_tasks+:
91
92
  #
92
93
  # class MyRailtie < Rails::Railtie
93
94
  # rake_tasks do
94
- # load 'path/to/my_railtie.tasks'
95
+ # load "path/to/my_railtie.tasks"
95
96
  # end
96
97
  # end
97
98
  #
98
- # By default, Rails loads generators from your load path. However, if you want to place
99
+ # By default, \Rails loads generators from your load path. However, if you want to place
99
100
  # your generators at a different location, you can specify in your railtie a block which
100
101
  # will load them during normal generators lookup:
101
102
  #
102
103
  # class MyRailtie < Rails::Railtie
103
104
  # generators do
104
- # require 'path/to/my_railtie_generator'
105
+ # require "path/to/my_railtie_generator"
105
106
  # end
106
107
  # end
107
108
  #
108
109
  # Since filenames on the load path are shared across gems, be sure that files you load
109
110
  # through a railtie have unique names.
110
111
  #
112
+ # == Run another program when the \Rails server starts
113
+ #
114
+ # In development, it's very usual to have to run another process next to the \Rails Server. In example
115
+ # you might want to start the Webpack or React server. Or maybe you need to run your job scheduler process
116
+ # like Sidekiq. This is usually done by opening a new shell and running the program from here.
117
+ #
118
+ # \Rails allow you to specify a +server+ block which will get called when a \Rails server starts.
119
+ # This way, your users don't need to remember to have to open a new shell and run another program, making
120
+ # this less confusing for everyone.
121
+ # It can be used like this:
122
+ #
123
+ # class MyRailtie < Rails::Railtie
124
+ # server do
125
+ # WebpackServer.start
126
+ # end
127
+ # end
128
+ #
111
129
  # == Application and Engine
112
130
  #
113
131
  # An engine is nothing more than a railtie with some initializers already set. And since
114
- # <tt>Rails::Application</tt> is an engine, the same configuration described here can be
132
+ # Rails::Application is an engine, the same configuration described here can be
115
133
  # used in both.
116
134
  #
117
135
  # Be sure to look at the documentation of those specific classes for more information.
118
136
  class Railtie
119
137
  autoload :Configuration, "rails/railtie/configuration"
120
138
 
139
+ extend ActiveSupport::DescendantsTracker
121
140
  include Initializable
122
141
 
123
142
  ABSTRACT_RAILTIES = %w(Rails::Railtie Rails::Engine Rails::Application)
@@ -127,13 +146,7 @@ module Rails
127
146
  delegate :config, to: :instance
128
147
 
129
148
  def subclasses
130
- @subclasses ||= []
131
- end
132
-
133
- def inherited(base)
134
- unless base.abstract_railtie?
135
- subclasses << base
136
- end
149
+ super.reject(&:abstract_railtie?).sort
137
150
  end
138
151
 
139
152
  def rake_tasks(&blk)
@@ -152,6 +165,10 @@ module Rails
152
165
  register_block_for(:generators, &blk)
153
166
  end
154
167
 
168
+ def server(&blk)
169
+ register_block_for(:server, &blk)
170
+ end
171
+
155
172
  def abstract_railtie?
156
173
  ABSTRACT_RAILTIES.include?(name)
157
174
  end
@@ -174,24 +191,44 @@ module Rails
174
191
  instance.configure(&block)
175
192
  end
176
193
 
194
+ def <=>(other) # :nodoc:
195
+ load_index <=> other.load_index
196
+ end
197
+
198
+ def inherited(subclass)
199
+ subclass.increment_load_index
200
+ super
201
+ end
202
+
203
+ protected
204
+ attr_reader :load_index
205
+
206
+ def increment_load_index
207
+ @@load_counter ||= 0
208
+ @load_index = (@@load_counter += 1)
209
+ end
210
+
177
211
  private
178
212
  def generate_railtie_name(string)
179
213
  ActiveSupport::Inflector.underscore(string).tr("/", "_")
180
214
  end
181
215
 
182
216
  def respond_to_missing?(name, _)
217
+ return super if abstract_railtie?
218
+
183
219
  instance.respond_to?(name) || super
184
220
  end
185
221
 
186
222
  # If the class method does not have a method, then send the method call
187
223
  # to the Railtie instance.
188
224
  def method_missing(name, *args, &block)
189
- if instance.respond_to?(name)
225
+ if !abstract_railtie? && instance.respond_to?(name)
190
226
  instance.public_send(name, *args, &block)
191
227
  else
192
228
  super
193
229
  end
194
230
  end
231
+ ruby2_keywords(:method_missing)
195
232
 
196
233
  # receives an instance variable identifier, set the variable value if is
197
234
  # blank and append given block to value, which will be used later in
@@ -206,13 +243,17 @@ module Rails
206
243
 
207
244
  delegate :railtie_name, to: :class
208
245
 
209
- def initialize #:nodoc:
246
+ def initialize # :nodoc:
210
247
  if self.class.abstract_railtie?
211
248
  raise "#{self.class.name} is abstract, you cannot instantiate it directly."
212
249
  end
213
250
  end
214
251
 
215
- def configure(&block) #:nodoc:
252
+ def inspect # :nodoc:
253
+ "#<#{self.class.name}>"
254
+ end
255
+
256
+ def configure(&block) # :nodoc:
216
257
  instance_eval(&block)
217
258
  end
218
259
 
@@ -223,31 +264,33 @@ module Rails
223
264
  @config ||= Railtie::Configuration.new
224
265
  end
225
266
 
226
- def railtie_namespace #:nodoc:
267
+ def railtie_namespace # :nodoc:
227
268
  @railtie_namespace ||= self.class.module_parents.detect { |n| n.respond_to?(:railtie_namespace) }
228
269
  end
229
270
 
230
271
  protected
231
-
232
- def run_console_blocks(app) #:nodoc:
272
+ def run_console_blocks(app) # :nodoc:
233
273
  each_registered_block(:console) { |block| block.call(app) }
234
274
  end
235
275
 
236
- def run_generators_blocks(app) #:nodoc:
276
+ def run_generators_blocks(app) # :nodoc:
237
277
  each_registered_block(:generators) { |block| block.call(app) }
238
278
  end
239
279
 
240
- def run_runner_blocks(app) #:nodoc:
280
+ def run_runner_blocks(app) # :nodoc:
241
281
  each_registered_block(:runner) { |block| block.call(app) }
242
282
  end
243
283
 
244
- def run_tasks_blocks(app) #:nodoc:
284
+ def run_tasks_blocks(app) # :nodoc:
245
285
  extend Rake::DSL
246
286
  each_registered_block(:rake_tasks) { |block| instance_exec(app, &block) }
247
287
  end
248
288
 
249
- private
289
+ def run_server_blocks(app) # :nodoc:
290
+ each_registered_block(:server) { |block| block.call(app) }
291
+ end
250
292
 
293
+ private
251
294
  # run `&block` in every registered block in `#register_block_for`
252
295
  def each_registered_block(type, &block)
253
296
  klass = self.class
@@ -1,15 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.5.0") && RUBY_ENGINE == "ruby"
3
+ # :stopdoc:
4
+
5
+ if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.7.0") && RUBY_ENGINE == "ruby"
4
6
  desc = defined?(RUBY_DESCRIPTION) ? RUBY_DESCRIPTION : "ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE})"
5
7
  abort <<-end_message
6
8
 
7
- Rails 6 requires Ruby 2.5.0 or newer.
9
+ Rails 7 requires Ruby 2.7.0 or newer.
8
10
 
9
11
  You're running
10
12
  #{desc}
11
13
 
12
- Please upgrade to Ruby 2.5.0 or newer to continue.
14
+ Please upgrade to Ruby 2.7.0 or newer to continue.
13
15
 
14
16
  end_message
15
17
  end
data/lib/rails/secrets.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "yaml"
4
+ require "tempfile"
4
5
  require "active_support/message_encryptor"
5
6
 
6
7
  module Rails
@@ -25,7 +26,10 @@ module Rails
25
26
  paths.each_with_object(Hash.new) do |path, all_secrets|
26
27
  require "erb"
27
28
 
28
- secrets = YAML.load(ERB.new(preprocess(path)).result) || {}
29
+ source = ERB.new(preprocess(path)).result
30
+ secrets = YAML.respond_to?(:unsafe_load) ? YAML.unsafe_load(source) : YAML.load(source)
31
+ secrets ||= {}
32
+
29
33
  all_secrets.merge!(secrets["shared"].deep_symbolize_keys) if secrets["shared"]
30
34
  all_secrets.merge!(secrets[env].deep_symbolize_keys) if secrets[env]
31
35
  end
@@ -84,17 +88,18 @@ module Rails
84
88
  end
85
89
 
86
90
  def writing(contents)
87
- tmp_file = "#{File.basename(path)}.#{Process.pid}"
88
- tmp_path = File.join(Dir.tmpdir, tmp_file)
89
- IO.binwrite(tmp_path, contents)
91
+ file_name = "#{File.basename(path)}.#{Process.pid}"
92
+
93
+ Tempfile.create(["", "-" + file_name]) do |tmp_file|
94
+ tmp_path = Pathname.new(tmp_file)
95
+ tmp_path.binwrite contents
90
96
 
91
- yield tmp_path
97
+ yield tmp_path
92
98
 
93
- updated_contents = IO.binread(tmp_path)
99
+ updated_contents = tmp_path.binread
94
100
 
95
- write(updated_contents) if updated_contents != contents
96
- ensure
97
- FileUtils.rm(tmp_path) if File.exist?(tmp_path)
101
+ write(updated_contents) if updated_contents != contents
102
+ end
98
103
  end
99
104
 
100
105
  def encryptor
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "active_support/deprecation"
3
+ require "ripper"
4
4
 
5
5
  module Rails
6
- # Implements the logic behind <tt>Rails::Command::NotesCommand</tt>. See <tt>rails notes --help</tt> for usage information.
6
+ # Implements the logic behind +Rails::Command::NotesCommand+. See <tt>rails notes --help</tt> for usage information.
7
7
  #
8
8
  # Annotation objects are triplets <tt>:line</tt>, <tt>:tag</tt>, <tt>:text</tt> that
9
9
  # represent the line where the annotation lives, its tag, and its text. Note
@@ -13,6 +13,44 @@ module Rails
13
13
  # start with the tag optionally followed by a colon. Everything up to the end
14
14
  # of the line (or closing ERB comment tag) is considered to be their text.
15
15
  class SourceAnnotationExtractor
16
+ # Wraps a regular expression that will be tested against each of the source
17
+ # file's comments.
18
+ class ParserExtractor < Struct.new(:pattern)
19
+ class Parser < Ripper
20
+ attr_reader :comments, :pattern
21
+
22
+ def initialize(source, pattern:)
23
+ super(source)
24
+ @pattern = pattern
25
+ @comments = []
26
+ end
27
+
28
+ def on_comment(value)
29
+ @comments << Annotation.new(lineno, $1, $2) if value =~ pattern
30
+ end
31
+ end
32
+
33
+ def annotations(file)
34
+ contents = File.read(file, encoding: Encoding::BINARY)
35
+ parser = Parser.new(contents, pattern: pattern).tap(&:parse)
36
+ parser.error? ? [] : parser.comments
37
+ end
38
+ end
39
+
40
+ # Wraps a regular expression that will iterate through a file's lines and
41
+ # test each one for the given pattern.
42
+ class PatternExtractor < Struct.new(:pattern)
43
+ def annotations(file)
44
+ lineno = 0
45
+
46
+ File.readlines(file, encoding: Encoding::BINARY).inject([]) do |list, line|
47
+ lineno += 1
48
+ next list unless line =~ pattern
49
+ list << Annotation.new(lineno, $1, $2)
50
+ end
51
+ end
52
+ end
53
+
16
54
  class Annotation < Struct.new(:line, :tag, :text)
17
55
  def self.directories
18
56
  @@directories ||= %w(app config db lib test)
@@ -44,9 +82,21 @@ module Rails
44
82
  extensions[/\.(#{exts.join("|")})$/] = block
45
83
  end
46
84
 
47
- register_extensions("builder", "rb", "rake", "yml", "yaml", "ruby") { |tag| /#\s*(#{tag}):?\s*(.*)$/ }
48
- register_extensions("css", "js") { |tag| /\/\/\s*(#{tag}):?\s*(.*)$/ }
49
- register_extensions("erb") { |tag| /<%\s*#\s*(#{tag}):?\s*(.*?)\s*%>/ }
85
+ register_extensions("builder", "rb", "rake", "ruby") do |tag|
86
+ ParserExtractor.new(/#\s*(#{tag}):?\s*(.*)$/)
87
+ end
88
+
89
+ register_extensions("yml", "yaml") do |tag|
90
+ PatternExtractor.new(/#\s*(#{tag}):?\s*(.*)$/)
91
+ end
92
+
93
+ register_extensions("css", "js") do |tag|
94
+ PatternExtractor.new(/\/\/\s*(#{tag}):?\s*(.*)$/)
95
+ end
96
+
97
+ register_extensions("erb") do |tag|
98
+ PatternExtractor.new(/<%\s*#\s*(#{tag}):?\s*(.*?)\s*%>/)
99
+ end
50
100
 
51
101
  # Returns a representation of the annotation that looks like this:
52
102
  #
@@ -59,13 +109,6 @@ module Rails
59
109
  s << "[#{tag}] " if options[:tag]
60
110
  s << text
61
111
  end
62
-
63
- # Used in annotations.rake
64
- #:nodoc:
65
- def self.notes_task_deprecation_warning
66
- ActiveSupport::Deprecation.warn("This rake task is deprecated and will be removed in Rails 6.1. \nRefer to `rails notes --help` for more information.\n")
67
- puts "\n"
68
- end
69
112
  end
70
113
 
71
114
  # Prints all annotations with tag +tag+ under the root directories +app+,
@@ -79,9 +122,9 @@ module Rails
79
122
  #
80
123
  # If +options+ has a <tt>:tag</tt> flag, it will be passed to each annotation's +to_s+.
81
124
  #
82
- # See <tt>#find_in</tt> for a list of file extensions that will be taken into account.
125
+ # See SourceAnnotationExtractor#find_in for a list of file extensions that will be taken into account.
83
126
  #
84
- # This class method is the single entry point for the `rails notes` command.
127
+ # This class method is the single entry point for the <tt>rails notes</tt> command.
85
128
  def self.enumerate(tag = nil, options = {})
86
129
  tag ||= Annotation.tags.join("|")
87
130
  extractor = new(tag)
@@ -109,7 +152,7 @@ module Rails
109
152
  results = {}
110
153
 
111
154
  Dir.glob("#{dir}/*") do |item|
112
- next if File.basename(item)[0] == ?.
155
+ next if File.basename(item).start_with?(".")
113
156
 
114
157
  if File.directory?(item)
115
158
  results.update(find_in(item))
@@ -120,7 +163,17 @@ module Rails
120
163
 
121
164
  if extension
122
165
  pattern = extension.last.call(tag)
123
- results.update(extract_annotations_from(item, pattern)) if pattern
166
+
167
+ # In case a user-defined pattern returns nothing for the given set
168
+ # of tags, we exit early.
169
+ next unless pattern
170
+
171
+ # If a user-defined pattern returns a regular expression, we will
172
+ # wrap it in a PatternExtractor to keep the same API.
173
+ pattern = PatternExtractor.new(pattern) if pattern.is_a?(Regexp)
174
+
175
+ annotations = pattern.annotations(item)
176
+ results.update(item => annotations) if annotations.any?
124
177
  end
125
178
  end
126
179
  end
@@ -128,19 +181,6 @@ module Rails
128
181
  results
129
182
  end
130
183
 
131
- # If +file+ is the filename of a file that contains annotations this method returns
132
- # a hash with a single entry that maps +file+ to an array of its annotations.
133
- # Otherwise it returns an empty hash.
134
- def extract_annotations_from(file, pattern)
135
- lineno = 0
136
- result = File.readlines(file, encoding: Encoding::BINARY).inject([]) do |list, line|
137
- lineno += 1
138
- next list unless line =~ pattern
139
- list << Annotation.new(lineno, $1, $2)
140
- end
141
- result.empty? ? {} : { file => result }
142
- end
143
-
144
184
  # Prints the mapping from filenames to annotations in +results+ ordered by filename.
145
185
  # The +options+ hash is passed to each annotation's +to_s+.
146
186
  def display(results, options = {})
@@ -155,8 +195,3 @@ module Rails
155
195
  end
156
196
  end
157
197
  end
158
-
159
- # Remove this deprecated class in the next minor version
160
- #:nodoc:
161
- SourceAnnotationExtractor = ActiveSupport::Deprecation::DeprecatedConstantProxy.
162
- new("SourceAnnotationExtractor", "Rails::SourceAnnotationExtractor")
@@ -18,7 +18,7 @@ task "load_app" do
18
18
  task environment: "app:environment"
19
19
 
20
20
  if !defined?(ENGINE_ROOT) || !ENGINE_ROOT
21
- ENGINE_ROOT = find_engine_path(APP_RAKEFILE)
21
+ ENGINE_ROOT = find_engine_path(Pathname.new(APP_RAKEFILE))
22
22
  end
23
23
  end
24
24
 
@@ -43,17 +43,17 @@ namespace :db do
43
43
  app_task "create"
44
44
  app_task "create:all"
45
45
 
46
- desc "Drops the database for the current Rails.env (use db:drop:all to drop all databases)"
46
+ desc "Drop the database for the current Rails.env (use db:drop:all to drop all databases)"
47
47
  app_task "drop"
48
48
  app_task "drop:all"
49
49
 
50
50
  desc "Load fixtures into the current environment's database."
51
51
  app_task "fixtures:load"
52
52
 
53
- desc "Rolls the schema back to the previous version (specify steps w/ STEP=n)."
53
+ desc "Roll the schema back to the previous version (specify steps w/ STEP=n)."
54
54
  app_task "rollback"
55
55
 
56
- desc "Create a db/schema.rb file that can be portably used against any database supported by Active Record"
56
+ desc "Create a database schema file (either db/schema.rb or db/structure.sql, depending on `config.active_record.schema_format`)"
57
57
  app_task "schema:dump"
58
58
 
59
59
  desc "Load a schema.rb file into the database"
@@ -65,10 +65,7 @@ namespace :db do
65
65
  desc "Create the database, load the schema, and initialize with the seed data (use db:reset to also drop the database first)"
66
66
  app_task "setup"
67
67
 
68
- desc "Dump the database structure to an SQL file"
69
- app_task "structure:dump"
70
-
71
- desc "Retrieves the current schema version number"
68
+ desc "Retrieve the current schema version number"
72
69
  app_task "version"
73
70
 
74
71
  # desc 'Load the test schema'
@@ -76,12 +73,12 @@ namespace :db do
76
73
  end
77
74
 
78
75
  def find_engine_path(path)
79
- return File.expand_path(Dir.pwd) if path == "/"
76
+ return File.expand_path(Dir.pwd) if path.root?
80
77
 
81
78
  if Rails::Engine.find(path)
82
- path
79
+ path.to_s
83
80
  else
84
- find_engine_path(File.expand_path("..", path))
81
+ find_engine_path(path.join(".."))
85
82
  end
86
83
  end
87
84
 
@@ -4,15 +4,13 @@ namespace :app do
4
4
  desc "Update configs and some other initially generated files (or use just update:configs or update:bin)"
5
5
  task update: [ "update:configs", "update:bin", "update:active_storage", "update:upgrade_guide_info" ]
6
6
 
7
- desc "Applies the template supplied by LOCATION=(/path/to/template) or URL"
7
+ desc "Apply the template supplied by LOCATION=(/path/to/template) or URL"
8
8
  task template: :environment do
9
9
  template = ENV["LOCATION"]
10
10
  raise "No LOCATION value given. Please set LOCATION either as path to a file or a URL" if template.blank?
11
- template = File.expand_path(template) if template !~ %r{\A[A-Za-z][A-Za-z0-9+\-\.]*://}
12
11
  require "rails/generators"
13
12
  require "rails/generators/rails/app/app_generator"
14
- generator = Rails::Generators::AppGenerator.new [Rails.root], {}, { destination_root: Rails.root }
15
- generator.apply template, verbose: false
13
+ Rails::Generators::AppGenerator.apply_rails_template(template, Rails.root)
16
14
  end
17
15
 
18
16
  namespace :templates do
@@ -22,7 +20,7 @@ namespace :app do
22
20
  project_templates = "#{Rails.root}/lib/templates"
23
21
 
24
22
  default_templates = { "erb" => %w{controller mailer scaffold},
25
- "rails" => %w{controller helper scaffold_controller assets} }
23
+ "rails" => %w{controller helper scaffold_controller} }
26
24
 
27
25
  default_templates.each do |type, names|
28
26
  local_template_type_dir = File.join(project_templates, type)
@@ -46,7 +44,7 @@ namespace :app do
46
44
  Rails::AppUpdater.invoke_from_app_generator :update_config_files
47
45
  end
48
46
 
49
- # desc "Adds new executables to the application bin/ directory"
47
+ # desc "Add new executables to the application bin/ directory"
50
48
  task :bin do
51
49
  Rails::AppUpdater.invoke_from_app_generator :update_bin_files
52
50
  end
@@ -7,7 +7,7 @@ namespace :log do
7
7
  # - defaults to all environments log files i.e. 'development,test,production'
8
8
  # - ENV['LOGS']=all truncates all files i.e. log/*.log
9
9
  # - ENV['LOGS']='test,development' truncates only specified files
10
- desc "Truncates all/specified *.log files in log/ to zero bytes (specify which logs with LOGS=test,development)"
10
+ desc "Truncate all/specified *.log files in log/ to zero bytes (specify which logs with LOGS=test,development)"
11
11
  task :clear do
12
12
  log_files.each do |file|
13
13
  clear_log_file(file)
@@ -1,18 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- desc "Generate a cryptographically secure secret key (this is typically used to generate a secret for cookie sessions)."
4
- task :secret do
5
- require "securerandom"
6
- puts SecureRandom.hex(64)
7
- end
8
-
9
- desc "List versions of all Rails frameworks and the environment"
10
- task about: :environment do
11
- puts Rails::Info
12
- end
13
-
14
3
  namespace :time do
15
- desc "List all time zones, list by two-letter country code (`rails time:zones[US]`), or list by UTC offset (`rails time:zones[-8]`)"
4
+ desc "List all time zones, list by two-letter country code (`bin/rails time:zones[US]`), or list by UTC offset (`bin/rails time:zones[-8]`)"
16
5
  task :zones, :country_or_offset do |t, args|
17
6
  zones, offset = ActiveSupport::TimeZone.all, nil
18
7
 
@@ -28,17 +17,17 @@ namespace :time do
28
17
  end
29
18
 
30
19
  namespace :zones do
31
- # desc 'Displays all time zones, also available: time:zones:us, time:zones:local -- filter with OFFSET parameter, e.g., OFFSET=-6'
20
+ # desc 'Display all time zones, also available: time:zones:us, time:zones:local -- filter with OFFSET parameter, e.g., OFFSET=-6'
32
21
  task :all do
33
22
  build_time_zone_list ActiveSupport::TimeZone.all
34
23
  end
35
24
 
36
- # desc 'Displays names of US time zones recognized by the Rails TimeZone class, grouped by offset. Results can be filtered with optional OFFSET parameter, e.g., OFFSET=-6'
25
+ # desc 'Display names of US time zones recognized by the Rails TimeZone class, grouped by offset. Results can be filtered with optional OFFSET parameter, e.g., OFFSET=-6'
37
26
  task :us do
38
27
  build_time_zone_list ActiveSupport::TimeZone.us_zones
39
28
  end
40
29
 
41
- # desc 'Displays names of time zones recognized by the Rails TimeZone class with the same offset as the system local time'
30
+ # desc 'Display names of time zones recognized by the Rails TimeZone class with the same offset as the system local time'
42
31
  task :local do
43
32
  require "active_support"
44
33
  require "active_support/time"