diff --git a/lib/oga/xpath/compiler.rb b/lib/oga/xpath/compiler.rb index f30f181..1872b0e 100644 --- a/lib/oga/xpath/compiler.rb +++ b/lib/oga/xpath/compiler.rb @@ -30,11 +30,16 @@ module Oga end end - literal('lambda').add_block(document) do + proc_ast = literal('lambda').add_block(document) do matched.assign(literal(XML::NodeSet).new) .followed_by(ruby_ast) .followed_by(matched) end + + generator = Ruby::Generator.new + source = generator.process(proc_ast) + + eval(source) end ## diff --git a/spec/oga/xpath/compiler_spec.rb b/spec/oga/xpath/compiler_spec.rb index 18b8a22..3e4f372 100644 --- a/spec/oga/xpath/compiler_spec.rb +++ b/spec/oga/xpath/compiler_spec.rb @@ -31,7 +31,7 @@ describe Oga::XPath::Compiler do ast = parse_xpath('foo') 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