class Debride

Public Instance Methods

process_curly(path) click to toggle source

Process curly and parse the result. Returns the sexp of the parsed ruby.

# File lib/debride_curly.rb, line 10
def process_curly(path)
  text = File.read(path)

  # A dirty cheat that may break down. Converting the Curly structure
  # to the "vanilla" rails ERB template in which we aren't calling helper
  # methods but instead levaring a receiver.
  text.gsub!(/\{\{[\/\#\^\*\@]? */, '<% dummy.' )
  text.gsub!(/\}\}/, ' %>')

  as_ruby = Erubis.new(text).src

  begin
    RubyParser.for_current_ruby.process(as_ruby, path)
  rescue Racc::ParseError => e
    warn "Parse Error parsing #{path}. Skipping."
    warn "  #{e.message}"
  rescue Timeout::Error
    warn "TIMEOUT parsing #{path}. Skipping."
  end
end