Class: Rails::SourceAnnotationExtractor::Annotation
- Defined in:
- railties/lib/rails/source_annotation_extractor.rb
Instance Attribute Summary collapse
-
#line ⇒ Object
Returns the value of attribute line.
-
#tag ⇒ Object
Returns the value of attribute tag.
-
#text ⇒ Object
Returns the value of attribute text.
Class Method Summary collapse
- .directories ⇒ Object
- .extensions ⇒ Object
-
.notes_task_deprecation_warning ⇒ Object
Used in annotations.rake :nodoc:.
-
.register_directories(*dirs) ⇒ Object
Registers additional directories to be included Rails::SourceAnnotationExtractor::Annotation.register_directories(“spec”, “another”).
-
.register_extensions(*exts, &block) ⇒ Object
Registers new Annotations File Extensions Rails::SourceAnnotationExtractor::Annotation.register_extensions(“css”, “scss”, “sass”, “less”, “js”) { |tag| ///s*(##tag):?s*(.*)$/ }.
-
.register_tags(*additional_tags) ⇒ Object
Registers additional tags Rails::SourceAnnotationExtractor::Annotation.register_tags(“TESTME”, “DEPRECATEME”).
- .tags ⇒ Object
Instance Method Summary collapse
-
#to_s(options = {}) ⇒ Object
Returns a representation of the annotation that looks like this:.
Methods inherited from Struct
Instance Attribute Details
#line ⇒ Object
Returns the value of attribute line
16 17 18 |
# File 'railties/lib/rails/source_annotation_extractor.rb', line 16 def line @line end |
#tag ⇒ Object
Returns the value of attribute tag
16 17 18 |
# File 'railties/lib/rails/source_annotation_extractor.rb', line 16 def tag @tag end |
#text ⇒ Object
Returns the value of attribute text
16 17 18 |
# File 'railties/lib/rails/source_annotation_extractor.rb', line 16 def text @text end |
Class Method Details
.directories ⇒ Object
17 18 19 |
# File 'railties/lib/rails/source_annotation_extractor.rb', line 17 def self.directories @@directories ||= %w(app config db lib test) end |
.extensions ⇒ Object
37 38 39 |
# File 'railties/lib/rails/source_annotation_extractor.rb', line 37 def self.extensions @@extensions ||= {} end |
.notes_task_deprecation_warning ⇒ Object
Used in annotations.rake :nodoc:
65 66 67 68 |
# File 'railties/lib/rails/source_annotation_extractor.rb', line 65 def self.notes_task_deprecation_warning 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") puts "\n" end |
.register_directories(*dirs) ⇒ Object
Registers additional directories to be included
Rails::SourceAnnotationExtractor::Annotation.register_directories("spec", "another")
23 24 25 |
# File 'railties/lib/rails/source_annotation_extractor.rb', line 23 def self.register_directories(*dirs) directories.push(*dirs) end |
.register_extensions(*exts, &block) ⇒ Object
Registers new Annotations File Extensions
Rails::SourceAnnotationExtractor::Annotation.register_extensions("css", "scss", "sass", "less", "js") { |tag| /\/\/\s*(#{tag}):?\s*(.*)$/ }
43 44 45 |
# File 'railties/lib/rails/source_annotation_extractor.rb', line 43 def self.register_extensions(*exts, &block) extensions[/\.(#{exts.join("|")})$/] = block end |
.register_tags(*additional_tags) ⇒ Object
Registers additional tags
Rails::SourceAnnotationExtractor::Annotation.("TESTME", "DEPRECATEME")
33 34 35 |
# File 'railties/lib/rails/source_annotation_extractor.rb', line 33 def self.(*) .push(*) end |
.tags ⇒ Object
27 28 29 |
# File 'railties/lib/rails/source_annotation_extractor.rb', line 27 def self. @@tags ||= %w(OPTIMIZE FIXME TODO) end |
Instance Method Details
#to_s(options = {}) ⇒ Object
Returns a representation of the annotation that looks like this:
[126] [TODO] This algorithm is simple and clearly correct, make it faster.
If options
has a flag :tag
the tag is shown as in the example above. Otherwise the string contains just line and text.
57 58 59 60 61 |
# File 'railties/lib/rails/source_annotation_extractor.rb', line 57 def to_s( = {}) s = +"[#{line.to_s.rjust([:indent])}] " s << "[#{tag}] " if [:tag] s << text end |