Class: Rails::SourceAnnotationExtractor::Annotation
- Inherits:
-
Struct
- Object
- Struct
- Rails::SourceAnnotationExtractor::Annotation
- Defined in:
- 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
-
.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:.
Instance Attribute Details
#line ⇒ Object
Returns the value of attribute line
14 15 16 |
# File 'lib/rails/source_annotation_extractor.rb', line 14 def line @line end |
#tag ⇒ Object
Returns the value of attribute tag
14 15 16 |
# File 'lib/rails/source_annotation_extractor.rb', line 14 def tag @tag end |
#text ⇒ Object
Returns the value of attribute text
14 15 16 |
# File 'lib/rails/source_annotation_extractor.rb', line 14 def text @text end |
Class Method Details
.directories ⇒ Object
15 16 17 |
# File 'lib/rails/source_annotation_extractor.rb', line 15 def self.directories @@directories ||= %w(app config db lib test) end |
.extensions ⇒ Object
35 36 37 |
# File 'lib/rails/source_annotation_extractor.rb', line 35 def self.extensions @@extensions ||= {} end |
.register_directories(*dirs) ⇒ Object
Registers additional directories to be included
Rails::SourceAnnotationExtractor::Annotation.register_directories("spec", "another")
21 22 23 |
# File 'lib/rails/source_annotation_extractor.rb', line 21 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*(.*)$/ }
41 42 43 |
# File 'lib/rails/source_annotation_extractor.rb', line 41 def self.register_extensions(*exts, &block) extensions[/\.(#{exts.join("|")})$/] = block end |
.register_tags(*additional_tags) ⇒ Object
Registers additional tags
Rails::SourceAnnotationExtractor::Annotation.("TESTME", "DEPRECATEME")
31 32 33 |
# File 'lib/rails/source_annotation_extractor.rb', line 31 def self.(*) .push(*) end |
.tags ⇒ Object
25 26 27 |
# File 'lib/rails/source_annotation_extractor.rb', line 25 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.
55 56 57 58 59 |
# File 'lib/rails/source_annotation_extractor.rb', line 55 def to_s( = {}) s = +"[#{line.to_s.rjust([:indent])}] " s << "[#{tag}] " if [:tag] s << text end |