diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2019-04-15 17:46:07 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-15 17:46:07 -0400 |
commit | 81c8f18d849a1538c4b838187280a572a5ff15e8 (patch) | |
tree | b08b98c9fb8b28ea7286af087ea4e82643de49fb /railties/lib/rails | |
parent | c2fcc6ac18f102d7650a416ec87bd65db6078a9d (diff) | |
parent | 6463cc05730d25ef591fd361a67ac10a1884c3de (diff) | |
download | rails-81c8f18d849a1538c4b838187280a572a5ff15e8.tar.gz rails-81c8f18d849a1538c4b838187280a572a5ff15e8.tar.bz2 rails-81c8f18d849a1538c4b838187280a572a5ff15e8.zip |
Merge pull request #35906 from yoones/notes-tags-registration
Notes tags registration
Diffstat (limited to 'railties/lib/rails')
-rw-r--r-- | railties/lib/rails/commands/notes/notes_command.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/source_annotation_extractor.rb | 15 |
2 files changed, 15 insertions, 2 deletions
diff --git a/railties/lib/rails/commands/notes/notes_command.rb b/railties/lib/rails/commands/notes/notes_command.rb index 64b339b3cd..94cf183855 100644 --- a/railties/lib/rails/commands/notes/notes_command.rb +++ b/railties/lib/rails/commands/notes/notes_command.rb @@ -5,7 +5,7 @@ require "rails/source_annotation_extractor" module Rails module Command class NotesCommand < Base # :nodoc: - class_option :annotations, aliases: "-a", desc: "Filter by specific annotations, e.g. Foobar TODO", type: :array, default: %w(OPTIMIZE FIXME TODO) + class_option :annotations, aliases: "-a", desc: "Filter by specific annotations, e.g. Foobar TODO", type: :array, default: Rails::SourceAnnotationExtractor::Annotation.tags def perform(*) require_application_and_environment! diff --git a/railties/lib/rails/source_annotation_extractor.rb b/railties/lib/rails/source_annotation_extractor.rb index d7170e6282..9ce22b96a6 100644 --- a/railties/lib/rails/source_annotation_extractor.rb +++ b/railties/lib/rails/source_annotation_extractor.rb @@ -29,6 +29,16 @@ module Rails directories.push(*dirs) end + def self.tags + @@tags ||= %w(OPTIMIZE FIXME TODO) + end + + # Registers additional tags + # Rails::SourceAnnotationExtractor::Annotation.register_tags("TESTME", "DEPRECATEME") + def self.register_tags(*additional_tags) + tags.push(*additional_tags) + end + def self.extensions @@extensions ||= {} end @@ -66,6 +76,8 @@ module Rails # Prints all annotations with tag +tag+ under the root directories +app+, # +config+, +db+, +lib+, and +test+ (recursively). # + # If +tag+ is <tt>nil</tt>, annotations with either default or registered tags are printed. + # # Specific directories can be explicitly set using the <tt>:dirs</tt> key in +options+. # # Rails::SourceAnnotationExtractor.enumerate 'TODO|FIXME', dirs: %w(app lib), tag: true @@ -75,7 +87,8 @@ module Rails # See <tt>#find_in</tt> for a list of file extensions that will be taken into account. # # This class method is the single entry point for the `rails notes` command. - def self.enumerate(tag, options = {}) + def self.enumerate(tag = nil, options = {}) + tag ||= Annotation.tags.join("|") extractor = new(tag) dirs = options.delete(:dirs) || Annotation.directories extractor.display(extractor.find(dirs), options) |