Parse Ruby code into indexable expressions
Codeminer takes advantage of Ripper and produces a custom abstract syntax tree. Each syntax node has accurate source information and contains references to its immediate children.
A processor is a stateful object that hooks into the codeminer parser and subscribes to parse events.
class ClassNameProcessor def initialize @class_names =  end # Hook into the "class" parse event def process_class(exp) @class_names << exp.value end def result @class_names end end
The processor shown above can be invoked in the following way:
class_name_processor = ClassNameProcessor.new CodeMiner.process('class Bar; end; class Foo; end', [class_name_processor]) class_name_processor.result # => ['Bar', 'Foo']