Class: NoteTracker::SourceAnnotationExtractor::Annotation
- Inherits:
-
Struct
- Object
- Struct
- NoteTracker::SourceAnnotationExtractor::Annotation
- Defined in:
- lib/note_tracker/source_annotation_extractor.rb
Instance Attribute Summary collapse
-
#line ⇒ Object
Returns the value of attribute line.
-
#story_id ⇒ Object
Returns the value of attribute story_id.
-
#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_extensions(*exts, &block) ⇒ Object
Registers new Annotations File Extensions SourceAnnotationExtractor::Annotation.register_extensions(“css”, “scss”, “sass”, “less”, “js”) { |tag| ///s*(##tag):?s*(.*)$/ }.
Instance Method Summary collapse
-
#to_s(options = {}) ⇒ Object
Returns a representation of the annotation that looks like this:.
- #trackered? ⇒ Boolean
Instance Attribute Details
#line ⇒ Object
Returns the value of attribute line
6 7 8 |
# File 'lib/note_tracker/source_annotation_extractor.rb', line 6 def line @line end |
#story_id ⇒ Object
Returns the value of attribute story_id
6 7 8 |
# File 'lib/note_tracker/source_annotation_extractor.rb', line 6 def story_id @story_id end |
#tag ⇒ Object
Returns the value of attribute tag
6 7 8 |
# File 'lib/note_tracker/source_annotation_extractor.rb', line 6 def tag @tag end |
#text ⇒ Object
Returns the value of attribute text
6 7 8 |
# File 'lib/note_tracker/source_annotation_extractor.rb', line 6 def text @text end |
Class Method Details
.directories ⇒ Object
7 8 9 |
# File 'lib/note_tracker/source_annotation_extractor.rb', line 7 def self.directories @@directories ||= %w(app config db lib test) + (ENV['SOURCE_ANNOTATION_DIRECTORIES'] || '').split(',') end |
.extensions ⇒ Object
11 12 13 |
# File 'lib/note_tracker/source_annotation_extractor.rb', line 11 def self.extensions @@extensions ||= {} end |
.register_extensions(*exts, &block) ⇒ Object
Registers new Annotations File Extensions
SourceAnnotationExtractor::Annotation.register_extensions("css", "scss", "sass", "less", "js") { |tag| /\/\/\s*(#{tag}):?\s*(.*)$/ }
17 18 19 |
# File 'lib/note_tracker/source_annotation_extractor.rb', line 17 def self.register_extensions(*exts, &block) extensions[/\.(#{exts.join("|")})$/] = block 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.
31 32 33 34 35 |
# File 'lib/note_tracker/source_annotation_extractor.rb', line 31 def to_s(={}) s = "[#{line.to_s.rjust([:indent])}] " s << "[#{tag}] " if [:tag] s << text end |
#trackered? ⇒ Boolean
37 38 39 |
# File 'lib/note_tracker/source_annotation_extractor.rb', line 37 def trackered? !!story_id end |