Class: RSpectre::SourceMap
- Inherits:
-
Object
- Object
- RSpectre::SourceMap
- Defined in:
- lib/rspectre/source_map.rb,
lib/rspectre/source_map/parser.rb
Direct Known Subclasses
Defined Under Namespace
Class Method Summary collapse
Instance Method Summary collapse
- #add(node) ⇒ Object
- #find_method(target_selector, line) ⇒ Object
-
#initialize ⇒ SourceMap
constructor
A new instance of SourceMap.
Constructor Details
#initialize ⇒ SourceMap
Returns a new instance of SourceMap.
7 8 9 |
# File 'lib/rspectre/source_map.rb', line 7 def initialize super(Hash.new { [] }) end |
Class Method Details
.parse(file) ⇒ Object
12 13 14 |
# File 'lib/rspectre/source_map.rb', line 12 def self.parse(file) self::Parser.new(file).populate(new) end |
Instance Method Details
#add(node) ⇒ Object
16 17 18 19 20 |
# File 'lib/rspectre/source_map.rb', line 16 def add(node) return unless node.loc.expression map[node.loc.first_line] <<= node end |
#find_method(target_selector, line) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/rspectre/source_map.rb', line 22 def find_method(target_selector, line) candidates = find_methods(target_selector, line) if candidates.one? candidates.first else warn Color.yellow("Unable to resolve `#{target_selector}` on line #{line}.") end end |