lib/sexp_path.rb in sexp_path-0.5.1 vs lib/sexp_path.rb in sexp_path-0.5.2

- old
+ new

@@ -50,11 +50,19 @@ include SexpPath::Traverse # Extends Sexp to allow any Sexp to be used as a SexpPath matcher def satisfy?(o, data={}) return false unless o.is_a? Sexp - return false unless (length == o.length || last.is_a?(SexpPath::Matcher::Remaining) ) - each_with_index{|c,i| return false unless c.is_a?(Sexp) ? c.satisfy?( o[i], data ) : c == o[i] } + return false unless length == o.length || (last.is_a?(Sexp) && last.greedy?) + + each_with_index do |child,i| + if child.is_a?(Sexp) + candidate = child.greedy? ? o[i..-1] : o[i] + return false unless child.satisfy?( candidate, data ) + else + return false unless child == o[i] + end + end capture_match(o, data) end end \ No newline at end of file