lib/sexp_path.rb in sexp_path-0.4.0 vs lib/sexp_path.rb in sexp_path-0.5.0
- old
+ new
@@ -12,25 +12,25 @@
sexp_path_root = File.dirname(__FILE__)+'/sexp_path/'
%w[
traverse
sexp_query_builder
+ ruby_query_builder
sexp_result
sexp_collection
-
- line_numbering_processor
-
+
matcher/base
matcher/any
matcher/all
matcher/not
matcher/child
matcher/block
matcher/atom
matcher/pattern
matcher/type
matcher/wild
+ matcher/remaining
matcher/include
matcher/sibling
].each do |path|
require sexp_path_root+path
@@ -39,18 +39,23 @@
# Pattern building helper, see SexpQueryBuilder
def Q?(&block)
SexpPath::SexpQueryBuilder.do(&block)
end
+# Ruby specific builder
+def R?(&block)
+ SexpPath::RubyQueryBuilder.do(&block)
+end
+
# SexpPath extends Sexp with Traverse.
# This adds support for searching S-Expressions
class Sexp
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
+ 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] }
capture_match(o, data)
end
end
\ No newline at end of file