Class: Parser
- Inherits:
-
Object
- Object
- Parser
- Defined in:
- lib/active_record_scanner/parser.rb
Instance Method Summary collapse
-
#initialize(raw) ⇒ Parser
constructor
A new instance of Parser.
- #parse ⇒ Object
Constructor Details
#initialize(raw) ⇒ Parser
Returns a new instance of Parser.
5 6 7 8 |
# File 'lib/active_record_scanner/parser.rb', line 5 def initialize(raw) @raw = raw @compactor = Compactor.new end |
Instance Method Details
#parse ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/active_record_scanner/parser.rb', line 10 def parse raw_tree = Ripper.sexp(@raw) return [] unless raw_tree # if the file isn't valid ruby, ignore it filtered_tree = filter(raw_tree) compact_tree = @compactor.deep_compact(filtered_tree) return [] unless compact_tree # if the file has no queries or loops, ignore it normalise!(compact_tree) end |