Skip to content

JacobNinja/codeminer

Repository files navigation

Codeminer

Parse Ruby code into indexable expressions

Parser

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.

Processor

A processor is a stateful object that hooks into the codeminer parser and subscribes to parse events.

Example:

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']

About

Parse Ruby code into indexable expressions

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages