Sha256: fbcd7d2389c655bba217c06d25cd008b6fef821b190f545802dbcfe40d16ad57

Contents?: true

Size: 778 Bytes

Versions: 1

Compression:

Stored size: 778 Bytes

Contents

#!/usr/bin/ruby

class Debride
  module Curly
  end

  ##
  # Process curly and parse the result. Returns the sexp of the parsed
  # ruby.
  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
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
debride-curly-0.1.0 lib/debride_curly.rb