Sha256: bbeafa1947b58af2a004378a5a8bfdc767c94ae4f518b156a2a1b9169f58209f
Contents?: true
Size: 610 Bytes
Versions: 47
Compression:
Stored size: 610 Bytes
Contents
# frozen_string_literal: true require 'ripper' module Haml class RubyExpression < Ripper class ParseError < StandardError; end def self.syntax_error?(code) self.new(code).parse false rescue ParseError true end def self.string_literal?(code) return false if syntax_error?(code) type, instructions = Ripper.sexp(code) return false if type != :program return false if instructions.size > 1 type, _ = instructions.first type == :string_literal end private def on_parse_error(*) raise ParseError end end end
Version data entries
47 entries across 47 versions & 1 rubygems