Parse Ruby code into indexable expressions
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
test
.gitignore
.ruby-gemset
.ruby-version
.travis.yml
Gemfile
Gemfile.lock
README.md
Rakefile
codeminer.gemspec

README.md

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