railties 7.0.8.7 → 7.1.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (163) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +570 -229
  3. data/MIT-LICENSE +1 -1
  4. data/RDOC_MAIN.md +99 -0
  5. data/README.rdoc +4 -4
  6. data/lib/minitest/rails_plugin.rb +63 -0
  7. data/lib/rails/api/task.rb +35 -4
  8. data/lib/rails/app_updater.rb +1 -1
  9. data/lib/rails/application/bootstrap.rb +12 -3
  10. data/lib/rails/application/configuration.rb +179 -67
  11. data/lib/rails/application/default_middleware_stack.rb +8 -2
  12. data/lib/rails/application/dummy_config.rb +19 -0
  13. data/lib/rails/application/finisher.rb +40 -33
  14. data/lib/rails/application.rb +112 -24
  15. data/lib/rails/backtrace_cleaner.rb +1 -1
  16. data/lib/rails/cli.rb +5 -2
  17. data/lib/rails/command/actions.rb +10 -12
  18. data/lib/rails/command/base.rb +55 -53
  19. data/lib/rails/command/environment_argument.rb +32 -16
  20. data/lib/rails/command/helpers/editor.rb +17 -12
  21. data/lib/rails/command.rb +84 -33
  22. data/lib/rails/commands/about/about_command.rb +14 -0
  23. data/lib/rails/commands/application/application_command.rb +2 -0
  24. data/lib/rails/commands/console/console_command.rb +14 -14
  25. data/lib/rails/commands/credentials/USAGE +53 -55
  26. data/lib/rails/commands/credentials/credentials_command/diffing.rb +5 -3
  27. data/lib/rails/commands/credentials/credentials_command.rb +64 -70
  28. data/lib/rails/commands/db/system/change/change_command.rb +2 -1
  29. data/lib/rails/commands/dbconsole/dbconsole_command.rb +25 -115
  30. data/lib/rails/commands/destroy/destroy_command.rb +3 -2
  31. data/lib/rails/commands/dev/dev_command.rb +1 -6
  32. data/lib/rails/commands/encrypted/USAGE +15 -20
  33. data/lib/rails/commands/encrypted/encrypted_command.rb +46 -35
  34. data/lib/rails/commands/gem_help/USAGE +16 -0
  35. data/lib/rails/commands/gem_help/gem_help_command.rb +13 -0
  36. data/lib/rails/commands/generate/generate_command.rb +2 -2
  37. data/lib/rails/commands/help/USAGE +13 -13
  38. data/lib/rails/commands/help/help_command.rb +21 -2
  39. data/lib/rails/commands/initializers/initializers_command.rb +1 -4
  40. data/lib/rails/commands/middleware/middleware_command.rb +17 -0
  41. data/lib/rails/commands/new/new_command.rb +2 -0
  42. data/lib/rails/commands/notes/notes_command.rb +2 -1
  43. data/lib/rails/commands/plugin/plugin_command.rb +2 -0
  44. data/lib/rails/commands/rake/rake_command.rb +25 -22
  45. data/lib/rails/commands/restart/restart_command.rb +14 -0
  46. data/lib/rails/commands/routes/routes_command.rb +13 -1
  47. data/lib/rails/commands/runner/USAGE +14 -12
  48. data/lib/rails/commands/runner/runner_command.rb +32 -20
  49. data/lib/rails/commands/secret/secret_command.rb +13 -0
  50. data/lib/rails/commands/secrets/USAGE +44 -49
  51. data/lib/rails/commands/secrets/secrets_command.rb +19 -38
  52. data/lib/rails/commands/server/server_command.rb +32 -31
  53. data/lib/rails/commands/test/USAGE +14 -0
  54. data/lib/rails/commands/test/test_command.rb +56 -14
  55. data/lib/rails/commands/unused_routes/unused_routes_command.rb +75 -0
  56. data/lib/rails/commands/version/version_command.rb +1 -0
  57. data/lib/rails/configuration.rb +5 -5
  58. data/lib/rails/console/app.rb +1 -4
  59. data/lib/rails/deprecator.rb +7 -0
  60. data/lib/rails/engine/configuration.rb +5 -0
  61. data/lib/rails/engine.rb +32 -11
  62. data/lib/rails/gem_version.rb +4 -4
  63. data/lib/rails/generators/actions.rb +6 -15
  64. data/lib/rails/generators/active_model.rb +2 -2
  65. data/lib/rails/generators/app_base.rb +354 -83
  66. data/lib/rails/generators/app_name.rb +3 -14
  67. data/lib/rails/generators/base.rb +12 -4
  68. data/lib/rails/generators/database.rb +19 -1
  69. data/lib/rails/generators/erb/mailer/templates/layout.html.erb.tt +1 -1
  70. data/lib/rails/generators/generated_attribute.rb +2 -0
  71. data/lib/rails/generators/migration.rb +1 -2
  72. data/lib/rails/generators/model_helpers.rb +2 -1
  73. data/lib/rails/generators/rails/app/USAGE +15 -6
  74. data/lib/rails/generators/rails/app/app_generator.rb +84 -60
  75. data/lib/rails/generators/rails/app/templates/Dockerfile.tt +107 -0
  76. data/lib/rails/generators/rails/app/templates/Gemfile.tt +8 -10
  77. data/lib/rails/generators/rails/app/templates/app/views/layouts/mailer.html.erb.tt +1 -1
  78. data/lib/rails/generators/rails/app/templates/bin/setup.tt +10 -1
  79. data/lib/rails/generators/rails/app/templates/config/application.rb.tt +4 -17
  80. data/lib/rails/generators/rails/app/templates/config/databases/jdbcsqlite3.yml.tt +3 -3
  81. data/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml.tt +0 -2
  82. data/lib/rails/generators/rails/app/templates/config/databases/sqlite3.yml.tt +3 -3
  83. data/lib/rails/generators/rails/app/templates/config/databases/trilogy.yml.tt +59 -0
  84. data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +10 -2
  85. data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +28 -24
  86. data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +11 -7
  87. data/lib/rails/generators/rails/app/templates/config/initializers/assets.rb.tt +2 -0
  88. data/lib/rails/generators/rails/app/templates/config/initializers/content_security_policy.rb.tt +2 -2
  89. data/lib/rails/generators/rails/app/templates/config/initializers/cors.rb.tt +1 -1
  90. data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_7_1.rb.tt +223 -0
  91. data/lib/rails/generators/rails/app/templates/config/initializers/permissions_policy.rb.tt +11 -9
  92. data/lib/rails/generators/rails/app/templates/config/locales/en.yml +11 -13
  93. data/lib/rails/generators/rails/app/templates/config/puma.rb.tt +10 -19
  94. data/lib/rails/generators/rails/app/templates/config/routes.rb.tt +4 -0
  95. data/lib/rails/generators/rails/app/templates/db/seeds.rb.tt +6 -4
  96. data/lib/rails/generators/rails/app/templates/docker-entrypoint.tt +10 -0
  97. data/lib/rails/generators/rails/app/templates/dockerignore.tt +43 -0
  98. data/lib/rails/generators/rails/app/templates/gitignore.tt +1 -9
  99. data/lib/rails/generators/rails/app/templates/node-version.tt +1 -0
  100. data/lib/rails/generators/rails/app/templates/test/channels/application_cable/connection_test.rb.tt +10 -8
  101. data/lib/rails/generators/rails/app/templates/test/test_helper.rb.tt +9 -7
  102. data/lib/rails/generators/rails/application_record/application_record_generator.rb +4 -0
  103. data/lib/rails/generators/rails/benchmark/benchmark_generator.rb +2 -1
  104. data/lib/rails/generators/rails/controller/USAGE +12 -4
  105. data/lib/rails/generators/rails/controller/controller_generator.rb +5 -0
  106. data/lib/rails/generators/rails/controller/templates/controller.rb.tt +1 -1
  107. data/lib/rails/generators/rails/credentials/credentials_generator.rb +29 -24
  108. data/lib/rails/generators/rails/credentials/templates/credentials.yml.tt +8 -0
  109. data/lib/rails/generators/rails/encryption_key_file/encryption_key_file_generator.rb +1 -2
  110. data/lib/rails/generators/rails/migration/USAGE +21 -11
  111. data/lib/rails/generators/rails/model/model_generator.rb +4 -0
  112. data/lib/rails/generators/rails/plugin/USAGE +17 -6
  113. data/lib/rails/generators/rails/plugin/plugin_generator.rb +5 -15
  114. data/lib/rails/generators/rails/plugin/templates/Gemfile.tt +2 -2
  115. data/lib/rails/generators/rails/plugin/templates/MIT-LICENSE.tt +1 -1
  116. data/lib/rails/generators/rails/plugin/templates/bin/rails.tt +1 -17
  117. data/lib/rails/generators/rails/plugin/templates/gitignore.tt +0 -2
  118. data/lib/rails/generators/rails/plugin/templates/test/test_helper.rb.tt +4 -4
  119. data/lib/rails/generators/rails/resource/resource_generator.rb +6 -0
  120. data/lib/rails/generators/rails/scaffold/scaffold_generator.rb +2 -1
  121. data/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb +1 -1
  122. data/lib/rails/generators/test_case.rb +2 -2
  123. data/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb +1 -1
  124. data/lib/rails/generators/testing/{behaviour.rb → behavior.rb} +4 -1
  125. data/lib/rails/generators.rb +5 -13
  126. data/lib/rails/health_controller.rb +55 -0
  127. data/lib/rails/info.rb +1 -1
  128. data/lib/rails/info_controller.rb +31 -11
  129. data/lib/rails/mailers_controller.rb +15 -5
  130. data/lib/rails/paths.rb +13 -10
  131. data/lib/rails/rack/logger.rb +15 -12
  132. data/lib/rails/rackup/server.rb +15 -0
  133. data/lib/rails/railtie/configuration.rb +14 -1
  134. data/lib/rails/railtie.rb +18 -18
  135. data/lib/rails/ruby_version_check.rb +2 -0
  136. data/lib/rails/source_annotation_extractor.rb +67 -18
  137. data/lib/rails/tasks/engine.rake +8 -8
  138. data/lib/rails/tasks/framework.rake +4 -10
  139. data/lib/rails/tasks/log.rake +1 -1
  140. data/lib/rails/tasks/misc.rake +3 -14
  141. data/lib/rails/tasks/statistics.rake +5 -4
  142. data/lib/rails/tasks/tmp.rake +5 -5
  143. data/lib/rails/tasks/zeitwerk.rake +1 -1
  144. data/lib/rails/tasks.rb +0 -2
  145. data/lib/rails/templates/rails/mailers/email.html.erb +25 -0
  146. data/lib/rails/templates/rails/mailers/index.html.erb +14 -7
  147. data/lib/rails/templates/rails/mailers/mailer.html.erb +11 -5
  148. data/lib/rails/templates/rails/welcome/index.html.erb +1 -0
  149. data/lib/rails/test_help.rb +7 -7
  150. data/lib/rails/test_unit/line_filtering.rb +1 -1
  151. data/lib/rails/test_unit/reporter.rb +6 -2
  152. data/lib/rails/test_unit/runner.rb +36 -18
  153. data/lib/rails/test_unit/test_parser.rb +88 -0
  154. data/lib/rails/test_unit/testing.rake +13 -33
  155. data/lib/rails/version.rb +1 -1
  156. data/lib/rails.rb +15 -15
  157. metadata +69 -34
  158. data/RDOC_MAIN.rdoc +0 -97
  159. data/lib/rails/application/dummy_erb_compiler.rb +0 -18
  160. data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_7_0.rb.tt +0 -143
  161. data/lib/rails/generators/rails/model/USAGE +0 -113
  162. data/lib/rails/tasks/middleware.rake +0 -9
  163. data/lib/rails/tasks/restart.rake +0 -9
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2004-2022 David Heinemeier Hansson
1
+ Copyright (c) David Heinemeier Hansson
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/RDOC_MAIN.md ADDED
@@ -0,0 +1,99 @@
1
+ # Welcome to \Rails
2
+
3
+ ## What's \Rails?
4
+
5
+ \Rails is a web-application framework that includes everything needed to
6
+ create database-backed web applications according to the
7
+ [Model-View-Controller (MVC)](https://en.wikipedia.org/wiki/Model-view-controller)
8
+ pattern.
9
+
10
+ Understanding the MVC pattern is key to understanding \Rails. MVC divides your
11
+ application into three layers: Model, View, and Controller, each with a specific responsibility.
12
+
13
+ ## Model layer
14
+
15
+ The _**Model layer**_ represents the domain model (such as Account, Product,
16
+ Person, Post, etc.) and encapsulates the business logic specific to
17
+ your application. In \Rails, database-backed model classes are derived from
18
+ `ActiveRecord::Base`. [Active Record](files/activerecord/README.rdoc) allows you to present the data from
19
+ database rows as objects and embellish these data objects with business logic
20
+ methods.
21
+ Although most \Rails models are backed by a database, models can also be ordinary
22
+ Ruby classes, or Ruby classes that implement a set of interfaces as provided by
23
+ the [Active Model](files/activemodel/README.rdoc) module.
24
+
25
+ ## View layer
26
+
27
+ The _**View layer**_ is composed of "templates" that are responsible for providing
28
+ appropriate representations of your application's resources. Templates can
29
+ come in a variety of formats, but most view templates are HTML with embedded
30
+ Ruby code (\ERB files). Views are typically rendered to generate a controller response
31
+ or to generate the body of an email. In \Rails, View generation is handled by [Action View](files/actionview/README.rdoc).
32
+
33
+ ## Controller layer
34
+
35
+ The _**Controller layer**_ is responsible for handling incoming HTTP requests and
36
+ providing a suitable response. Usually, this means returning HTML, but \Rails controllers
37
+ can also generate XML, JSON, PDFs, mobile-specific views, and more. Controllers load and
38
+ manipulate models, and render view templates in order to generate the appropriate HTTP response.
39
+ In \Rails, incoming requests are routed by Action Dispatch to an appropriate controller, and
40
+ controller classes are derived from `ActionController::Base`. Action Dispatch and Action Controller
41
+ are bundled together in [Action Pack](files/actionpack/README.rdoc).
42
+
43
+ ## Frameworks and libraries
44
+
45
+ [Active Record](files/activerecord/README.rdoc), [Active Model](files/activemodel/README.rdoc), [Action Pack](files/actionpack/README.rdoc), and [Action View](files/actionview/README.rdoc) can each be used independently outside \Rails.
46
+
47
+ In addition to that, \Rails also comes with:
48
+
49
+ - [Action Mailer](files/actionmailer/README.rdoc), a library to generate and send emails
50
+ - [Action Mailbox](files/actionmailbox/README.md), a library to receive emails within a \Rails application
51
+ - [Active Job](files/activejob/README.md), a framework for declaring jobs and making them run on a variety of queuing backends
52
+ - [Action Cable](files/actioncable/README.md), a framework to integrate WebSockets with a \Rails application
53
+ - [Active Storage](files/activestorage/README.md), a library to attach cloud and local files to \Rails applications
54
+ - [Action Text](files/actiontext/README.md), a library to handle rich text content
55
+ - [Active Support](files/activesupport/README.rdoc), a collection of utility classes and standard library extensions that are useful for \Rails, and may also be used independently outside \Rails
56
+
57
+ ## Getting Started
58
+
59
+ 1. Install \Rails at the command prompt if you haven't yet:
60
+
61
+ $ gem install rails
62
+
63
+ 2. At the command prompt, create a new \Rails application:
64
+
65
+ $ rails new myapp
66
+
67
+ where "myapp" is the application name.
68
+
69
+ 3. Change directory to `myapp` and start the web server:
70
+
71
+ $ cd myapp
72
+ $ bin/rails server
73
+
74
+ Run with `--help` or `-h` for options.
75
+
76
+ 4. Go to `http://localhost:3000` and you'll see the \Rails bootscreen with your
77
+ \Rails and Ruby versions.
78
+
79
+ 5. Follow the guidelines to start developing your application. You may find the
80
+ following resources handy:
81
+
82
+ * [Getting Started with Rails](https://guides.rubyonrails.org/getting_started.html)
83
+ * [Ruby on Rails Guides](https://guides.rubyonrails.org)
84
+ * [The API Documentation](https://api.rubyonrails.org)
85
+
86
+ ## Contributing
87
+
88
+ We encourage you to contribute to Ruby on \Rails! Please check out the
89
+ [Contributing to Ruby on Rails guide](https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html) for guidelines about how to proceed. [Join us!](https://contributors.rubyonrails.org)
90
+
91
+ Trying to report a possible security vulnerability in \Rails? Please
92
+ check out our [security policy](https://rubyonrails.org/security) for
93
+ guidelines about how to proceed.
94
+
95
+ Everyone interacting in \Rails and its sub-projects' codebases, issue trackers, chat rooms, and mailing lists is expected to follow the \Rails [code of conduct](https://rubyonrails.org/conduct).
96
+
97
+ ## License
98
+
99
+ Ruby on \Rails is released under the [MIT License](https://opensource.org/licenses/MIT).
data/README.rdoc CHANGED
@@ -1,12 +1,12 @@
1
- = Railties -- Gluing the Engine to the Rails
1
+ = Railties -- Gluing the Engine to the \Rails
2
2
 
3
3
  Railties is responsible for gluing all frameworks together. Overall, it:
4
4
 
5
- * handles the bootstrapping process for a Rails application;
5
+ * handles the bootstrapping process for a \Rails application;
6
6
 
7
7
  * manages the +rails+ command line interface;
8
8
 
9
- * and provides the Rails generators core.
9
+ * and provides the \Rails generators core.
10
10
 
11
11
  == Download
12
12
 
@@ -30,7 +30,7 @@ API documentation is at
30
30
 
31
31
  * https://api.rubyonrails.org
32
32
 
33
- Bug reports can be filed for the Ruby on Rails project here:
33
+ Bug reports can be filed for the Ruby on \Rails project here:
34
34
 
35
35
  * https://github.com/rails/rails/issues
36
36
 
@@ -25,6 +25,46 @@ module Minitest
25
25
  end
26
26
  end
27
27
 
28
+ class ProfileReporter < StatisticsReporter
29
+ def initialize(io = $stdout, options = {})
30
+ super
31
+ @results = []
32
+ @count = options[:profile]
33
+ end
34
+
35
+ def record(result)
36
+ @results << result
37
+ end
38
+
39
+ def report
40
+ total_time = @results.sum(&:time)
41
+
42
+ @results.sort! { |a, b| b.time <=> a.time }
43
+ slow_results = @results.take(@count)
44
+ slow_tests_total_time = slow_results.sum(&:time)
45
+
46
+ ratio = (total_time == 0) ? 0.0 : (slow_tests_total_time / total_time) * 100
47
+
48
+ io.puts("\nTop %d slowest tests (%.2f seconds, %.1f%% of total time):\n" % [slow_results.size, slow_tests_total_time, ratio])
49
+ slow_results.each do |result|
50
+ io.puts(" %s\n %.4f seconds %s\n" % [result.location, result.time, source_location(result)])
51
+ end
52
+ io.puts("\n")
53
+ end
54
+
55
+ private
56
+ def source_location(result)
57
+ filename, line = result.source_location
58
+ return "" unless filename
59
+
60
+ pwd = Dir.pwd
61
+ if filename.start_with?(pwd)
62
+ filename = Pathname.new(filename).relative_path_from(pwd)
63
+ end
64
+ "#{filename}:#{line}"
65
+ end
66
+ end
67
+
28
68
  def self.plugin_rails_options(opts, options)
29
69
  ::Rails::TestUnit::Runner.attach_before_load_options(opts)
30
70
 
@@ -44,6 +84,24 @@ module Minitest
44
84
  options[:color] = value
45
85
  end
46
86
 
87
+ opts.on("--profile [COUNT]", "Enable profiling of tests and list the slowest test cases (default: 10)") do |value|
88
+ default_count = 10
89
+
90
+ if value.nil?
91
+ count = default_count
92
+ else
93
+ count = Integer(value, exception: false)
94
+ if count.nil?
95
+ warn("Non integer specified as profile count, separate " \
96
+ "your path from options with -- e.g. " \
97
+ "`bin/test --profile -- #{value}`")
98
+ count = default_count
99
+ end
100
+ end
101
+
102
+ options[:profile] = count
103
+ end
104
+
47
105
  options[:color] = true
48
106
  options[:output_inline] = true
49
107
  end
@@ -67,6 +125,11 @@ module Minitest
67
125
  if reporter.reporters.reject! { |reporter| reporter.kind_of?(ProgressReporter) }
68
126
  reporter << ::Rails::TestUnitReporter.new(options[:io], options)
69
127
  end
128
+
129
+ # Add slowest tests reporter at the end.
130
+ if options[:profile]
131
+ reporter << ProfileReporter.new(options[:io], options)
132
+ end
70
133
  end
71
134
 
72
135
  # Backwards compatibility with Rails 5.0 generated plugin test scripts
@@ -10,6 +10,7 @@ module Rails
10
10
  "activesupport" => {
11
11
  include: %w(
12
12
  README.rdoc
13
+ lib/active_support.rb
13
14
  lib/active_support/**/*.rb
14
15
  )
15
16
  },
@@ -17,6 +18,7 @@ module Rails
17
18
  "activerecord" => {
18
19
  include: %w(
19
20
  README.rdoc
21
+ lib/active_record.rb
20
22
  lib/active_record/**/*.rb
21
23
  lib/arel.rb
22
24
  )
@@ -25,6 +27,7 @@ module Rails
25
27
  "activemodel" => {
26
28
  include: %w(
27
29
  README.rdoc
30
+ lib/active_model.rb
28
31
  lib/active_model/**/*.rb
29
32
  )
30
33
  },
@@ -33,7 +36,9 @@ module Rails
33
36
  include: %w(
34
37
  README.rdoc
35
38
  lib/abstract_controller/**/*.rb
39
+ lib/action_controller.rb
36
40
  lib/action_controller/**/*.rb
41
+ lib/action_dispatch.rb
37
42
  lib/action_dispatch/**/*.rb
38
43
  )
39
44
  },
@@ -41,6 +46,7 @@ module Rails
41
46
  "actionview" => {
42
47
  include: %w(
43
48
  README.rdoc
49
+ lib/action_view.rb
44
50
  lib/action_view/**/*.rb
45
51
  ),
46
52
  exclude: "lib/action_view/vendor/*"
@@ -49,6 +55,7 @@ module Rails
49
55
  "actionmailer" => {
50
56
  include: %w(
51
57
  README.rdoc
58
+ lib/action_mailer.rb
52
59
  lib/action_mailer/**/*.rb
53
60
  )
54
61
  },
@@ -56,6 +63,7 @@ module Rails
56
63
  "activejob" => {
57
64
  include: %w(
58
65
  README.md
66
+ lib/active_job.rb
59
67
  lib/active_job/**/*.rb
60
68
  )
61
69
  },
@@ -63,6 +71,7 @@ module Rails
63
71
  "actioncable" => {
64
72
  include: %w(
65
73
  README.md
74
+ lib/action_cable.rb
66
75
  lib/action_cable/**/*.rb
67
76
  )
68
77
  },
@@ -71,6 +80,7 @@ module Rails
71
80
  include: %w(
72
81
  README.md
73
82
  app/**/active_storage/**/*.rb
83
+ lib/active_storage.rb
74
84
  lib/active_storage/**/*.rb
75
85
  )
76
86
  },
@@ -79,6 +89,7 @@ module Rails
79
89
  include: %w(
80
90
  README.md
81
91
  app/**/action_mailbox/**/*.rb
92
+ lib/action_mailbox.rb
82
93
  lib/action_mailbox/**/*.rb
83
94
  )
84
95
  },
@@ -87,6 +98,7 @@ module Rails
87
98
  include: %w(
88
99
  README.md
89
100
  app/**/action_text/**/*.rb
101
+ lib/action_text.rb
90
102
  lib/action_text/**/*.rb
91
103
  )
92
104
  },
@@ -150,8 +162,8 @@ module Rails
150
162
 
151
163
  # Only generate documentation for files that have been
152
164
  # changed since the API was generated.
153
- if Dir.exist?("doc/rdoc") && !ENV["ALL"]
154
- last_generation = DateTime.rfc2822(File.open("doc/rdoc/created.rid", &:readline))
165
+ if Dir.exist?(api_dir) && !ENV["ALL"]
166
+ last_generation = DateTime.rfc2822(File.open("#{api_dir}/created.rid", &:readline))
155
167
 
156
168
  rdoc_files.keep_if do |file|
157
169
  File.mtime(file).to_datetime > last_generation
@@ -162,13 +174,16 @@ module Rails
162
174
  end
163
175
  end
164
176
 
165
- def setup_horo_variables
177
+ # These variables are used by the sdoc template
178
+ def setup_horo_variables # :nodoc:
166
179
  ENV["HORO_PROJECT_NAME"] = "Ruby on Rails"
167
180
  ENV["HORO_PROJECT_VERSION"] = rails_version
181
+ ENV["HORO_BADGE_VERSION"] = badge_version
182
+ ENV["HORO_CANONICAL_URL"] = canonical_url
168
183
  end
169
184
 
170
185
  def api_main
171
- component_root_dir("railties") + "/RDOC_MAIN.rdoc"
186
+ component_root_dir("railties") + "/RDOC_MAIN.md"
172
187
  end
173
188
  end
174
189
 
@@ -191,12 +206,28 @@ module Rails
191
206
  def rails_version
192
207
  "main@#{`git rev-parse HEAD`[0, 7]}"
193
208
  end
209
+
210
+ def badge_version
211
+ "edge"
212
+ end
213
+
214
+ def canonical_url
215
+ "https://edgeapi.rubyonrails.org"
216
+ end
194
217
  end
195
218
 
196
219
  class StableTask < RepoTask
197
220
  def rails_version
198
221
  File.read("RAILS_VERSION").strip
199
222
  end
223
+
224
+ def badge_version
225
+ "v#{rails_version}"
226
+ end
227
+
228
+ def canonical_url
229
+ "https://api.rubyonrails.org/#{badge_version}"
230
+ end
200
231
  end
201
232
  end
202
233
  end
@@ -21,6 +21,7 @@ module Rails
21
21
  private
22
22
  def generator_options
23
23
  options = { api: !!Rails.application.config.api_only, update: true }
24
+ options[:name] = Rails.application.class.name.chomp("::Application").underscore
24
25
  options[:skip_active_job] = !defined?(ActiveJob::Railtie)
25
26
  options[:skip_active_record] = !defined?(ActiveRecord::Railtie)
26
27
  options[:skip_active_storage] = !defined?(ActiveStorage::Engine)
@@ -32,7 +33,6 @@ module Rails
32
33
  options[:skip_system_test] = Rails.application.config.generators.system_tests.nil?
33
34
  options[:skip_asset_pipeline] = !defined?(Sprockets::Railtie) && !defined?(Propshaft::Railtie)
34
35
  options[:skip_bootsnap] = !defined?(Bootsnap)
35
- options[:updating] = true
36
36
  options
37
37
  end
38
38
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "fileutils"
4
+ require "set"
4
5
  require "active_support/notifications"
5
6
  require "active_support/dependencies"
6
7
  require "active_support/descendants_tracker"
@@ -14,7 +15,6 @@ module Rails
14
15
  initializer :load_environment_hook, group: :all do end
15
16
 
16
17
  initializer :load_active_support, group: :all do
17
- ENV["RAILS_DISABLE_DEPRECATED_TO_S_CONVERSION"] = "true" if config.active_support.disable_to_s_conversion
18
18
  require "active_support/all" unless config.active_support.bare
19
19
  end
20
20
 
@@ -28,14 +28,18 @@ module Rails
28
28
  * production - set it to true
29
29
 
30
30
  INFO
31
- config.eager_load = config.cache_classes
31
+ config.eager_load = !config.reloading_enabled?
32
32
  end
33
33
  end
34
34
 
35
35
  # Initialize the logger early in the stack in case we need to log some deprecation.
36
36
  initializer :initialize_logger, group: :all do
37
37
  Rails.logger ||= config.logger || begin
38
- logger = ActiveSupport::Logger.new(config.default_log_file)
38
+ logger = if config.log_file_size
39
+ ActiveSupport::Logger.new(config.default_log_file, 1, config.log_file_size)
40
+ else
41
+ ActiveSupport::Logger.new(config.default_log_file)
42
+ end
39
43
  logger.formatter = config.log_formatter
40
44
  logger = ActiveSupport::TaggedLogging.new(logger)
41
45
  logger
@@ -76,10 +80,15 @@ module Rails
76
80
  initializer :setup_once_autoloader, after: :set_eager_load_paths, before: :bootstrap_hook do
77
81
  autoloader = Rails.autoloaders.once
78
82
 
83
+ # Normally empty, but if the user already defined some, we won't
84
+ # override them. Important if there are custom namespaces associated.
85
+ already_configured_dirs = Set.new(autoloader.dirs)
86
+
79
87
  ActiveSupport::Dependencies.autoload_once_paths.freeze
80
88
  ActiveSupport::Dependencies.autoload_once_paths.uniq.each do |path|
81
89
  # Zeitwerk only accepts existing directories in `push_dir`.
82
90
  next unless File.directory?(path)
91
+ next if already_configured_dirs.member?(path.to_s)
83
92
 
84
93
  autoloader.push_dir(path)
85
94
  autoloader.do_not_eager_load(path) unless ActiveSupport::Dependencies.eager_load?(path)