railties 5.2.2.1 → 6.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +338 -119
- data/MIT-LICENSE +1 -1
- data/RDOC_MAIN.rdoc +38 -32
- data/README.rdoc +2 -2
- data/lib/minitest/rails_plugin.rb +7 -11
- data/lib/rails.rb +5 -0
- data/lib/rails/all.rb +4 -0
- data/lib/rails/api/generator.rb +2 -1
- data/lib/rails/api/task.rb +17 -0
- data/lib/rails/app_loader.rb +2 -2
- data/lib/rails/app_updater.rb +3 -1
- data/lib/rails/application.rb +73 -30
- data/lib/rails/application/bootstrap.rb +2 -10
- data/lib/rails/application/configuration.rb +114 -13
- data/lib/rails/application/default_middleware_stack.rb +3 -0
- data/lib/rails/application/dummy_erb_compiler.rb +18 -0
- data/lib/rails/application/finisher.rb +54 -0
- data/lib/rails/autoloaders.rb +48 -0
- data/lib/rails/backtrace_cleaner.rb +5 -17
- data/lib/rails/code_statistics.rb +3 -3
- data/lib/rails/command.rb +11 -10
- data/lib/rails/command/actions.rb +10 -0
- data/lib/rails/command/base.rb +16 -4
- data/lib/rails/command/behavior.rb +7 -48
- data/lib/rails/command/environment_argument.rb +8 -15
- data/lib/rails/command/spellchecker.rb +58 -0
- data/lib/rails/commands/console/console_command.rb +6 -0
- data/lib/rails/commands/credentials/USAGE +19 -1
- data/lib/rails/commands/credentials/credentials_command.rb +54 -21
- data/lib/rails/commands/db/system/change/change_command.rb +20 -0
- data/lib/rails/commands/dbconsole/dbconsole_command.rb +20 -8
- data/lib/rails/commands/dev/dev_command.rb +19 -0
- data/lib/rails/commands/encrypted/USAGE +28 -0
- data/lib/rails/commands/encrypted/encrypted_command.rb +3 -2
- data/lib/rails/commands/help/help_command.rb +1 -1
- data/lib/rails/commands/initializers/initializers_command.rb +23 -0
- data/lib/rails/commands/new/new_command.rb +2 -2
- data/lib/rails/commands/notes/notes_command.rb +39 -0
- data/lib/rails/commands/plugin/plugin_command.rb +1 -1
- data/lib/rails/commands/routes/routes_command.rb +37 -0
- data/lib/rails/commands/runner/runner_command.rb +13 -9
- data/lib/rails/commands/secrets/USAGE +3 -3
- data/lib/rails/commands/secrets/secrets_command.rb +3 -3
- data/lib/rails/commands/server/server_command.rb +113 -50
- data/lib/rails/configuration.rb +1 -7
- data/lib/rails/engine.rb +44 -18
- data/lib/rails/engine/configuration.rb +5 -2
- data/lib/rails/gem_version.rb +3 -3
- data/lib/rails/generators.rb +11 -10
- data/lib/rails/generators/actions.rb +52 -39
- data/lib/rails/generators/app_base.rb +60 -98
- data/lib/rails/generators/app_name.rb +50 -0
- data/lib/rails/generators/base.rb +4 -0
- data/lib/rails/generators/database.rb +58 -0
- data/lib/rails/generators/erb/mailer/mailer_generator.rb +1 -1
- data/lib/rails/generators/erb/scaffold/templates/_form.html.erb.tt +6 -3
- data/lib/rails/generators/erb/scaffold/templates/index.html.erb.tt +1 -1
- data/lib/rails/generators/erb/scaffold/templates/show.html.erb.tt +9 -1
- data/lib/rails/generators/generated_attribute.rb +53 -27
- data/lib/rails/generators/migration.rb +1 -2
- data/lib/rails/generators/model_helpers.rb +8 -1
- data/lib/rails/generators/named_base.rb +2 -6
- data/lib/rails/generators/rails/app/app_generator.rb +38 -71
- data/lib/rails/generators/rails/app/templates/Gemfile.tt +8 -11
- data/lib/rails/generators/rails/app/templates/app/assets/config/manifest.js.tt +0 -3
- data/lib/rails/generators/rails/app/templates/app/{assets/javascripts/cable.js.tt → javascript/channels/consumer.js} +2 -9
- data/lib/rails/generators/rails/app/templates/app/javascript/channels/index.js +5 -0
- data/lib/rails/generators/rails/app/templates/app/javascript/packs/application.js.tt +23 -0
- data/lib/rails/generators/rails/app/templates/app/jobs/application_job.rb.tt +5 -0
- data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +4 -4
- data/lib/rails/generators/rails/app/templates/bin/setup.tt +7 -7
- data/lib/rails/generators/rails/app/templates/config/application.rb.tt +2 -0
- data/lib/rails/generators/rails/app/templates/config/cable.yml.tt +1 -1
- data/lib/rails/generators/rails/app/templates/config/databases/frontbase.yml.tt +2 -2
- data/lib/rails/generators/rails/app/templates/config/databases/ibm_db.yml.tt +2 -2
- data/lib/rails/generators/rails/app/templates/config/databases/jdbc.yml.tt +2 -2
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcmysql.yml.tt +3 -3
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml.tt +3 -3
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcsqlite3.yml.tt +1 -1
- data/lib/rails/generators/rails/app/templates/config/databases/mysql.yml.tt +4 -4
- data/lib/rails/generators/rails/app/templates/config/databases/oracle.yml.tt +2 -2
- data/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml.tt +6 -6
- data/lib/rails/generators/rails/app/templates/config/databases/sqlite3.yml.tt +1 -1
- data/lib/rails/generators/rails/app/templates/config/databases/sqlserver.yml.tt +2 -2
- data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +5 -2
- data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +28 -12
- data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +13 -6
- data/lib/rails/generators/rails/app/templates/config/initializers/assets.rb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/config/initializers/content_security_policy.rb.tt +7 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_6_0.rb.tt +45 -0
- data/lib/rails/generators/rails/app/templates/config/locales/en.yml +1 -1
- data/lib/rails/generators/rails/app/templates/config/puma.rb.tt +7 -3
- data/lib/rails/generators/rails/app/templates/config/routes.rb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/config/spring.rb.tt +6 -6
- data/lib/rails/generators/rails/app/templates/gitignore.tt +3 -7
- data/lib/rails/generators/rails/app/templates/package.json.tt +7 -1
- data/lib/rails/generators/rails/app/templates/public/robots.txt +1 -1
- data/lib/rails/generators/rails/app/templates/ruby-version.tt +1 -1
- data/lib/rails/generators/rails/app/templates/test/channels/application_cable/connection_test.rb.tt +11 -0
- data/lib/rails/generators/rails/app/templates/test/test_helper.rb.tt +7 -0
- data/lib/rails/generators/rails/assets/USAGE +1 -4
- data/lib/rails/generators/rails/assets/assets_generator.rb +0 -1
- data/lib/rails/generators/rails/controller/controller_generator.rb +11 -1
- data/lib/rails/generators/rails/credentials/credentials_generator.rb +7 -8
- data/lib/rails/generators/rails/db/system/change/change_generator.rb +65 -0
- data/lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb +4 -5
- data/lib/rails/generators/rails/helper/helper_generator.rb +5 -0
- data/lib/rails/generators/rails/plugin/plugin_generator.rb +9 -33
- data/lib/rails/generators/rails/plugin/templates/app/controllers/%namespaced_name%/application_controller.rb.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/app/helpers/%namespaced_name%/application_helper.rb.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/app/jobs/%namespaced_name%/application_job.rb.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/app/mailers/%namespaced_name%/application_mailer.rb.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/app/models/%namespaced_name%/application_record.rb.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/gitignore.tt +2 -1
- data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/engine.rb.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/railtie.rb.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/test/test_helper.rb.tt +1 -2
- data/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb +14 -0
- data/lib/rails/generators/rails/scaffold_controller/templates/api_controller.rb.tt +1 -1
- data/lib/rails/generators/rails/scaffold_controller/templates/controller.rb.tt +1 -1
- data/lib/rails/generators/resource_helpers.rb +1 -6
- data/lib/rails/generators/test_unit/integration/integration_generator.rb +6 -0
- data/lib/rails/generators/test_unit/job/job_generator.rb +5 -0
- data/lib/rails/generators/test_unit/mailer/mailer_generator.rb +1 -1
- data/lib/rails/generators/test_unit/model/templates/fixtures.yml.tt +2 -2
- data/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb +12 -2
- data/lib/rails/generators/test_unit/scaffold/templates/system_test.rb.tt +8 -0
- data/lib/rails/generators/test_unit/system/system_generator.rb +5 -0
- data/lib/rails/generators/testing/behaviour.rb +3 -0
- data/lib/rails/info.rb +3 -3
- data/lib/rails/info_controller.rb +1 -1
- data/lib/rails/mailers_controller.rb +7 -4
- data/lib/rails/paths.rb +19 -9
- data/lib/rails/railtie.rb +1 -1
- data/lib/rails/ruby_version_check.rb +3 -3
- data/lib/rails/secrets.rb +0 -1
- data/lib/rails/source_annotation_extractor.rb +138 -117
- data/lib/rails/tasks.rb +1 -0
- data/lib/rails/tasks/annotations.rake +9 -9
- data/lib/rails/tasks/dev.rake +5 -4
- data/lib/rails/tasks/framework.rake +5 -1
- data/lib/rails/tasks/initializers.rake +5 -4
- data/lib/rails/tasks/log.rake +0 -1
- data/lib/rails/tasks/routes.rake +4 -26
- data/lib/rails/tasks/statistics.rake +4 -0
- data/lib/rails/tasks/yarn.rake +2 -3
- data/lib/rails/tasks/zeitwerk.rake +66 -0
- data/lib/rails/templates/rails/welcome/index.html.erb +2 -2
- data/lib/rails/test_help.rb +11 -9
- data/lib/rails/test_unit/reporter.rb +1 -1
- data/lib/rails/test_unit/runner.rb +5 -5
- data/lib/rails/test_unit/testing.rake +1 -1
- metadata +36 -23
- data/lib/rails/generators/js/assets/assets_generator.rb +0 -15
- data/lib/rails/generators/js/assets/templates/javascript.js +0 -2
- data/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt +0 -22
- data/lib/rails/generators/rails/app/templates/bin/bundle.tt +0 -2
- data/lib/rails/generators/rails/app/templates/bin/update.tt +0 -34
- data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_5_2.rb.tt +0 -38
- data/lib/rails/generators/rails/assets/templates/javascript.js +0 -2
data/lib/rails/railtie.rb
CHANGED
@@ -224,7 +224,7 @@ module Rails
|
|
224
224
|
end
|
225
225
|
|
226
226
|
def railtie_namespace #:nodoc:
|
227
|
-
@railtie_namespace ||= self.class.
|
227
|
+
@railtie_namespace ||= self.class.module_parents.detect { |n| n.respond_to?(:railtie_namespace) }
|
228
228
|
end
|
229
229
|
|
230
230
|
protected
|
@@ -1,15 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.
|
3
|
+
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.5.0") && RUBY_ENGINE == "ruby"
|
4
4
|
desc = defined?(RUBY_DESCRIPTION) ? RUBY_DESCRIPTION : "ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE})"
|
5
5
|
abort <<-end_message
|
6
6
|
|
7
|
-
Rails
|
7
|
+
Rails 6 requires Ruby 2.5.0 or newer.
|
8
8
|
|
9
9
|
You're running
|
10
10
|
#{desc}
|
11
11
|
|
12
|
-
Please upgrade to Ruby 2.
|
12
|
+
Please upgrade to Ruby 2.5.0 or newer to continue.
|
13
13
|
|
14
14
|
end_message
|
15
15
|
end
|
data/lib/rails/secrets.rb
CHANGED
@@ -1,141 +1,162 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
#
|
5
|
-
# rails notes
|
6
|
-
# rails notes:optimize
|
7
|
-
#
|
8
|
-
# and friends. See <tt>rails -T notes</tt> and <tt>railties/lib/rails/tasks/annotations.rake</tt>.
|
9
|
-
#
|
10
|
-
# Annotation objects are triplets <tt>:line</tt>, <tt>:tag</tt>, <tt>:text</tt> that
|
11
|
-
# represent the line where the annotation lives, its tag, and its text. Note
|
12
|
-
# the filename is not stored.
|
13
|
-
#
|
14
|
-
# Annotations are looked for in comments and modulus whitespace they have to
|
15
|
-
# start with the tag optionally followed by a colon. Everything up to the end
|
16
|
-
# of the line (or closing ERB comment tag) is considered to be their text.
|
17
|
-
class SourceAnnotationExtractor
|
18
|
-
Annotation = Struct.new(:line, :tag, :text) do
|
19
|
-
def self.directories
|
20
|
-
@@directories ||= %w(app config db lib test) + (ENV["SOURCE_ANNOTATION_DIRECTORIES"] || "").split(",")
|
21
|
-
end
|
3
|
+
require "active_support/deprecation"
|
22
4
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
5
|
+
module Rails
|
6
|
+
# Implements the logic behind <tt>Rails::Command::NotesCommand</tt>. See <tt>rails notes --help</tt> for usage information.
|
7
|
+
#
|
8
|
+
# Annotation objects are triplets <tt>:line</tt>, <tt>:tag</tt>, <tt>:text</tt> that
|
9
|
+
# represent the line where the annotation lives, its tag, and its text. Note
|
10
|
+
# the filename is not stored.
|
11
|
+
#
|
12
|
+
# Annotations are looked for in comments and modulus whitespace they have to
|
13
|
+
# start with the tag optionally followed by a colon. Everything up to the end
|
14
|
+
# of the line (or closing ERB comment tag) is considered to be their text.
|
15
|
+
class SourceAnnotationExtractor
|
16
|
+
class Annotation < Struct.new(:line, :tag, :text)
|
17
|
+
def self.directories
|
18
|
+
@@directories ||= %w(app config db lib test)
|
19
|
+
end
|
28
20
|
|
29
|
-
|
30
|
-
|
31
|
-
|
21
|
+
# Registers additional directories to be included
|
22
|
+
# Rails::SourceAnnotationExtractor::Annotation.register_directories("spec", "another")
|
23
|
+
def self.register_directories(*dirs)
|
24
|
+
directories.push(*dirs)
|
25
|
+
end
|
32
26
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
extensions[/\.(#{exts.join("|")})$/] = block
|
37
|
-
end
|
27
|
+
def self.tags
|
28
|
+
@@tags ||= %w(OPTIMIZE FIXME TODO)
|
29
|
+
end
|
38
30
|
|
39
|
-
|
40
|
-
|
41
|
-
|
31
|
+
# Registers additional tags
|
32
|
+
# Rails::SourceAnnotationExtractor::Annotation.register_tags("TESTME", "DEPRECATEME")
|
33
|
+
def self.register_tags(*additional_tags)
|
34
|
+
tags.push(*additional_tags)
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.extensions
|
38
|
+
@@extensions ||= {}
|
39
|
+
end
|
42
40
|
|
43
|
-
|
41
|
+
# Registers new Annotations File Extensions
|
42
|
+
# Rails::SourceAnnotationExtractor::Annotation.register_extensions("css", "scss", "sass", "less", "js") { |tag| /\/\/\s*(#{tag}):?\s*(.*)$/ }
|
43
|
+
def self.register_extensions(*exts, &block)
|
44
|
+
extensions[/\.(#{exts.join("|")})$/] = block
|
45
|
+
end
|
46
|
+
|
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*%>/ }
|
50
|
+
|
51
|
+
# Returns a representation of the annotation that looks like this:
|
52
|
+
#
|
53
|
+
# [126] [TODO] This algorithm is simple and clearly correct, make it faster.
|
54
|
+
#
|
55
|
+
# If +options+ has a flag <tt>:tag</tt> the tag is shown as in the example above.
|
56
|
+
# Otherwise the string contains just line and text.
|
57
|
+
def to_s(options = {})
|
58
|
+
s = +"[#{line.to_s.rjust(options[:indent])}] "
|
59
|
+
s << "[#{tag}] " if options[:tag]
|
60
|
+
s << text
|
61
|
+
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
|
+
end
|
70
|
+
|
71
|
+
# Prints all annotations with tag +tag+ under the root directories +app+,
|
72
|
+
# +config+, +db+, +lib+, and +test+ (recursively).
|
73
|
+
#
|
74
|
+
# If +tag+ is <tt>nil</tt>, annotations with either default or registered tags are printed.
|
75
|
+
#
|
76
|
+
# Specific directories can be explicitly set using the <tt>:dirs</tt> key in +options+.
|
77
|
+
#
|
78
|
+
# Rails::SourceAnnotationExtractor.enumerate 'TODO|FIXME', dirs: %w(app lib), tag: true
|
79
|
+
#
|
80
|
+
# If +options+ has a <tt>:tag</tt> flag, it will be passed to each annotation's +to_s+.
|
44
81
|
#
|
45
|
-
#
|
82
|
+
# See <tt>#find_in</tt> for a list of file extensions that will be taken into account.
|
46
83
|
#
|
47
|
-
#
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
84
|
+
# This class method is the single entry point for the `rails notes` command.
|
85
|
+
def self.enumerate(tag = nil, options = {})
|
86
|
+
tag ||= Annotation.tags.join("|")
|
87
|
+
extractor = new(tag)
|
88
|
+
dirs = options.delete(:dirs) || Annotation.directories
|
89
|
+
extractor.display(extractor.find(dirs), options)
|
53
90
|
end
|
54
|
-
end
|
55
91
|
|
56
|
-
|
57
|
-
# +config+, +db+, +lib+, and +test+ (recursively).
|
58
|
-
#
|
59
|
-
# Additional directories may be added using a comma-delimited list set using
|
60
|
-
# <tt>ENV['SOURCE_ANNOTATION_DIRECTORIES']</tt>.
|
61
|
-
#
|
62
|
-
# Directories may also be explicitly set using the <tt>:dirs</tt> key in +options+.
|
63
|
-
#
|
64
|
-
# SourceAnnotationExtractor.enumerate 'TODO|FIXME', dirs: %w(app lib), tag: true
|
65
|
-
#
|
66
|
-
# If +options+ has a <tt>:tag</tt> flag, it will be passed to each annotation's +to_s+.
|
67
|
-
#
|
68
|
-
# See <tt>#find_in</tt> for a list of file extensions that will be taken into account.
|
69
|
-
#
|
70
|
-
# This class method is the single entry point for the rake tasks.
|
71
|
-
def self.enumerate(tag, options = {})
|
72
|
-
extractor = new(tag)
|
73
|
-
dirs = options.delete(:dirs) || Annotation.directories
|
74
|
-
extractor.display(extractor.find(dirs), options)
|
75
|
-
end
|
76
|
-
|
77
|
-
attr_reader :tag
|
78
|
-
|
79
|
-
def initialize(tag)
|
80
|
-
@tag = tag
|
81
|
-
end
|
92
|
+
attr_reader :tag
|
82
93
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
dirs.inject({}) { |h, dir| h.update(find_in(dir)) }
|
87
|
-
end
|
94
|
+
def initialize(tag)
|
95
|
+
@tag = tag
|
96
|
+
end
|
88
97
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
results = {}
|
95
|
-
|
96
|
-
Dir.glob("#{dir}/*") do |item|
|
97
|
-
next if File.basename(item)[0] == ?.
|
98
|
-
|
99
|
-
if File.directory?(item)
|
100
|
-
results.update(find_in(item))
|
101
|
-
else
|
102
|
-
extension = Annotation.extensions.detect do |regexp, _block|
|
103
|
-
regexp.match(item)
|
104
|
-
end
|
98
|
+
# Returns a hash that maps filenames under +dirs+ (recursively) to arrays
|
99
|
+
# with their annotations.
|
100
|
+
def find(dirs)
|
101
|
+
dirs.inject({}) { |h, dir| h.update(find_in(dir)) }
|
102
|
+
end
|
105
103
|
|
106
|
-
|
107
|
-
|
108
|
-
|
104
|
+
# Returns a hash that maps filenames under +dir+ (recursively) to arrays
|
105
|
+
# with their annotations. Files with extensions registered in
|
106
|
+
# <tt>Rails::SourceAnnotationExtractor::Annotation.extensions</tt> are
|
107
|
+
# taken into account. Only files with annotations are included.
|
108
|
+
def find_in(dir)
|
109
|
+
results = {}
|
110
|
+
|
111
|
+
Dir.glob("#{dir}/*") do |item|
|
112
|
+
next if File.basename(item)[0] == ?.
|
113
|
+
|
114
|
+
if File.directory?(item)
|
115
|
+
results.update(find_in(item))
|
116
|
+
else
|
117
|
+
extension = Annotation.extensions.detect do |regexp, _block|
|
118
|
+
regexp.match(item)
|
119
|
+
end
|
120
|
+
|
121
|
+
if extension
|
122
|
+
pattern = extension.last.call(tag)
|
123
|
+
results.update(extract_annotations_from(item, pattern)) if pattern
|
124
|
+
end
|
109
125
|
end
|
110
126
|
end
|
111
|
-
end
|
112
127
|
|
113
|
-
|
114
|
-
|
128
|
+
results
|
129
|
+
end
|
115
130
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
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 }
|
125
142
|
end
|
126
|
-
result.empty? ? {} : { file => result }
|
127
|
-
end
|
128
143
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
144
|
+
# Prints the mapping from filenames to annotations in +results+ ordered by filename.
|
145
|
+
# The +options+ hash is passed to each annotation's +to_s+.
|
146
|
+
def display(results, options = {})
|
147
|
+
options[:indent] = results.flat_map { |f, a| a.map(&:line) }.max.to_s.size
|
148
|
+
results.keys.sort.each do |file|
|
149
|
+
puts "#{file}:"
|
150
|
+
results[file].each do |note|
|
151
|
+
puts " * #{note.to_s(options)}"
|
152
|
+
end
|
153
|
+
puts
|
137
154
|
end
|
138
|
-
puts
|
139
155
|
end
|
140
156
|
end
|
141
157
|
end
|
158
|
+
|
159
|
+
# Remove this deprecated class in the next minor version
|
160
|
+
#:nodoc:
|
161
|
+
SourceAnnotationExtractor = ActiveSupport::Deprecation::DeprecatedConstantProxy.
|
162
|
+
new("SourceAnnotationExtractor", "Rails::SourceAnnotationExtractor")
|
data/lib/rails/tasks.rb
CHANGED
@@ -2,21 +2,21 @@
|
|
2
2
|
|
3
3
|
require "rails/source_annotation_extractor"
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
task notes: :environment do
|
6
|
+
Rails::SourceAnnotationExtractor::Annotation.notes_task_deprecation_warning
|
7
|
+
Rails::Command.invoke :notes
|
8
8
|
end
|
9
9
|
|
10
10
|
namespace :notes do
|
11
11
|
["OPTIMIZE", "FIXME", "TODO"].each do |annotation|
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
task annotation.downcase.intern => :environment do
|
13
|
+
Rails::SourceAnnotationExtractor::Annotation.notes_task_deprecation_warning
|
14
|
+
Rails::Command.invoke :notes, ["--annotations", annotation]
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
task custom: :environment do
|
19
|
+
Rails::SourceAnnotationExtractor::Annotation.notes_task_deprecation_warning
|
20
|
+
Rails::Command.invoke :notes, ["--annotations", ENV["ANNOTATION"]]
|
21
21
|
end
|
22
22
|
end
|
data/lib/rails/tasks/dev.rake
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "rails/
|
3
|
+
require "rails/command"
|
4
|
+
require "active_support/deprecation"
|
4
5
|
|
5
6
|
namespace :dev do
|
6
|
-
|
7
|
-
|
8
|
-
Rails::
|
7
|
+
task cache: :environment do
|
8
|
+
ActiveSupport::Deprecation.warn("Using `bin/rake dev:cache` is deprecated and will be removed in Rails 6.1. Use `bin/rails dev:cache` instead.\n")
|
9
|
+
Rails::Command.invoke "dev:cache"
|
9
10
|
end
|
10
11
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
namespace :app do
|
4
4
|
desc "Update configs and some other initially generated files (or use just update:configs or update:bin)"
|
5
|
-
task update: [ "update:configs", "update:bin", "update:upgrade_guide_info" ]
|
5
|
+
task update: [ "update:configs", "update:bin", "update:active_storage", "update:upgrade_guide_info" ]
|
6
6
|
|
7
7
|
desc "Applies the template supplied by LOCATION=(/path/to/template) or URL"
|
8
8
|
task template: :environment do
|
@@ -51,6 +51,10 @@ namespace :app do
|
|
51
51
|
Rails::AppUpdater.invoke_from_app_generator :update_bin_files
|
52
52
|
end
|
53
53
|
|
54
|
+
task :active_storage do
|
55
|
+
Rails::AppUpdater.invoke_from_app_generator :update_active_storage
|
56
|
+
end
|
57
|
+
|
54
58
|
task :upgrade_guide_info do
|
55
59
|
Rails::AppUpdater.invoke_from_app_generator :display_upgrade_guide_info
|
56
60
|
end
|
@@ -1,8 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require "rails/command"
|
4
|
+
require "active_support/deprecation"
|
5
|
+
|
4
6
|
task initializers: :environment do
|
5
|
-
Rails.
|
6
|
-
|
7
|
-
end
|
7
|
+
ActiveSupport::Deprecation.warn("Using `bin/rake initializers` is deprecated and will be removed in Rails 6.1. Use `bin/rails initializers` instead.\n")
|
8
|
+
Rails::Command.invoke "initializers"
|
8
9
|
end
|
data/lib/rails/tasks/log.rake
CHANGED
data/lib/rails/tasks/routes.rake
CHANGED
@@ -1,31 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "
|
3
|
+
require "rails/command"
|
4
|
+
require "active_support/deprecation"
|
4
5
|
|
5
|
-
desc "Print out all defined routes in match order, with names. Target specific controller with -c option, or grep routes using -g option"
|
6
6
|
task routes: :environment do
|
7
|
-
|
8
|
-
|
9
|
-
inspector = ActionDispatch::Routing::RoutesInspector.new(all_routes)
|
10
|
-
|
11
|
-
routes_filter = nil
|
12
|
-
|
13
|
-
OptionParser.new do |opts|
|
14
|
-
opts.banner = "Usage: rails routes [options]"
|
15
|
-
|
16
|
-
Rake.application.standard_rake_options.each { |args| opts.on(*args) }
|
17
|
-
|
18
|
-
opts.on("-c CONTROLLER") do |controller|
|
19
|
-
routes_filter = { controller: controller }
|
20
|
-
end
|
21
|
-
|
22
|
-
opts.on("-g PATTERN") do |pattern|
|
23
|
-
routes_filter = pattern
|
24
|
-
end
|
25
|
-
|
26
|
-
end.parse!(ARGV.reject { |x| x == "routes" })
|
27
|
-
|
28
|
-
puts inspector.format(ActionDispatch::Routing::ConsoleFormatter.new, routes_filter)
|
29
|
-
|
30
|
-
exit 0 # ensure extra arguments aren't interpreted as Rake tasks
|
7
|
+
ActiveSupport::Deprecation.warn("Using `bin/rake routes` is deprecated and will be removed in Rails 6.1. Use `bin/rails routes` instead.\n")
|
8
|
+
Rails::Command.invoke "routes"
|
31
9
|
end
|