Method: Lemon::SourceParser#parse

Defined in:
lib/lemon/coverage/source_parser.rb

#parse(text) ⇒ Object

Converts Ruby code into a data structure. Note that at the instance level scopes accumulate, which makes it easy to parse multiple files in a single project but harder to parse files that have no connection.

text - A String of Ruby code.

Examples

@parser = SourceParser.new
files.each do |file|
  @parser.parse(File.read(file))
end
pp @parser.scopes

Returns a Hash with each key a namespace and each value another Hash or Scope.



68
69
70
71
# File 'lib/lemon/coverage/source_parser.rb', line 68

def parse(text)
  process(tokenize(sexp(text)))
  @scopes
end