Class: SourceNotes::Extractor
- Inherits:
-
Object
- Object
- SourceNotes::Extractor
- Defined in:
- lib/source_notes.rb
Defined Under Namespace
Classes: Annotation
Instance Attribute Summary collapse
-
#tag ⇒ Object
readonly
Returns the value of attribute tag.
Class Method Summary collapse
-
.enumerate(tag, options = {}) ⇒ Object
Prints all annotations with tag
tag
under the current PWD Only filenames with extension.builder
,.rb
,.erb
,.haml
,.slim
,.css
,.scss
,.js
, and.coffee
are taken into account.
Instance Method Summary collapse
-
#display(options = {}) ⇒ Object
Prints the mapping from filenames to annotations in
results
ordered by filename. -
#initialize(tag, options = {}) ⇒ Extractor
constructor
A new instance of Extractor.
Constructor Details
#initialize(tag, options = {}) ⇒ Extractor
Returns a new instance of Extractor.
40 41 42 43 |
# File 'lib/source_notes.rb', line 40 def initialize(tag, = {}) @tag = tag @dirs = [:dirs] || [Dir::pwd] end |
Instance Attribute Details
#tag ⇒ Object (readonly)
Returns the value of attribute tag.
38 39 40 |
# File 'lib/source_notes.rb', line 38 def tag @tag end |
Class Method Details
.enumerate(tag, options = {}) ⇒ Object
Prints all annotations with tag tag
under the current PWD Only filenames with extension .builder
, .rb
, .erb
, .haml
, .slim
, .css
, .scss
, .js
, and .coffee
are taken into account. The options
hash is passed to each annotation’s to_s
.
This class method is the single entry point for the rake tasks.
33 34 35 36 |
# File 'lib/source_notes.rb', line 33 def self.enumerate(tag, ={}) extractor = new(tag) extractor.display() end |
Instance Method Details
#display(options = {}) ⇒ Object
Prints the mapping from filenames to annotations in results
ordered by filename. The options
hash is passed to each annotation’s to_s
.
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/source_notes.rb', line 47 def display(={}) [:indent] = find.map { |f, a| a.map(&:line) }.flatten.max.to_s.size find.keys.sort.each do |file| puts "#{file}:" find[file].each do |note| puts " * #{note.to_s()}" end puts end end |