Class: Debride

Inherits:
Object
  • Object
show all
Defined in:
lib/debride_curly.rb

Defined Under Namespace

Modules: Curly

Instance Method Summary collapse

Instance Method Details

#process_curly(path) ⇒ Object

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



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# 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