mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
Rename SyntaxChecker to RubyExpression
This commit is contained in:
parent
a2b69e3cbe
commit
957305538c
4 changed files with 9 additions and 9 deletions
|
@ -1,4 +1,4 @@
|
|||
require 'hamlit/syntax_checker'
|
||||
require 'hamlit/ruby_expression'
|
||||
|
||||
module Hamlit
|
||||
class HashParser
|
||||
|
@ -11,7 +11,7 @@ module Hamlit
|
|||
|
||||
def parse(text)
|
||||
exp = wrap_bracket(text)
|
||||
return if SyntaxChecker.syntax_error?(exp)
|
||||
return if RubyExpression.syntax_error?(exp)
|
||||
|
||||
hash = {}
|
||||
tokens = Ripper.lex(exp)[1..-2] || []
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
require 'ripper'
|
||||
|
||||
module Hamlit
|
||||
class SyntaxChecker < Ripper
|
||||
class RubyExpression < Ripper
|
||||
class ParseError < StandardError; end
|
||||
|
||||
def self.syntax_error?(code)
|
|
@ -1,4 +1,4 @@
|
|||
require 'hamlit/syntax_checker'
|
||||
require 'hamlit/ruby_expression'
|
||||
|
||||
module Hamlit
|
||||
class StaticAnalyzer
|
||||
|
@ -26,7 +26,7 @@ module Hamlit
|
|||
|
||||
def self.static?(exp)
|
||||
return false if exp.nil? || exp.strip.empty?
|
||||
return false if SyntaxChecker.syntax_error?(exp)
|
||||
return false if RubyExpression.syntax_error?(exp)
|
||||
|
||||
Ripper.lex(exp).each do |(_, col), token, str|
|
||||
case token
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
describe Hamlit::SyntaxChecker do
|
||||
describe Hamlit::RubyExpression do
|
||||
describe '.syntax_error?' do
|
||||
it { assert_equal(true, Hamlit::SyntaxChecker.syntax_error?('{ hash }')) }
|
||||
it { assert_equal(false, Hamlit::SyntaxChecker.syntax_error?('{ a: b }')) }
|
||||
it { assert_equal(true, Hamlit::RubyExpression.syntax_error?('{ hash }')) }
|
||||
it { assert_equal(false, Hamlit::RubyExpression.syntax_error?('{ a: b }')) }
|
||||
end
|
||||
|
||||
describe '.string_literal?' do
|
||||
def assert_literal(expected, code)
|
||||
actual = Hamlit::SyntaxChecker.string_literal?(code)
|
||||
actual = Hamlit::RubyExpression.string_literal?(code)
|
||||
assert_equal expected, actual
|
||||
end
|
||||
|
Loading…
Add table
Reference in a new issue