XPath compiler now actually returns a Proc

This commit is contained in:
Yorick Peterse 2015-07-07 10:26:22 +02:00
parent d11a754946
commit 6d01adafc7
2 changed files with 7 additions and 2 deletions

View File

@ -30,11 +30,16 @@ module Oga
end end
end end
literal('lambda').add_block(document) do proc_ast = literal('lambda').add_block(document) do
matched.assign(literal(XML::NodeSet).new) matched.assign(literal(XML::NodeSet).new)
.followed_by(ruby_ast) .followed_by(ruby_ast)
.followed_by(matched) .followed_by(matched)
end end
generator = Ruby::Generator.new
source = generator.process(proc_ast)
eval(source)
end end
## ##

View File

@ -31,7 +31,7 @@ describe Oga::XPath::Compiler do
ast = parse_xpath('foo') ast = parse_xpath('foo')
block = @compiler.compile(ast) block = @compiler.compile(ast)
block.call(doc).should be_an_instance_of(NodeSet) block.call(doc).should be_an_instance_of(Oga::XML::NodeSet)
end end
end end
end end