lib/sexp.rb in sexp_processor-4.1.3 vs lib/sexp.rb in sexp_processor-4.1.4
- old
+ new
@@ -1,6 +1,5 @@
-
$TESTING ||= false # unless defined $TESTING
##
# Sexps are the basic storage mechanism of SexpProcessor. Sexps have
# a +type+ (to be renamed +node_type+) which is the first element of
@@ -208,10 +207,15 @@
def method_missing meth, delete = false
find_node meth, delete
end
+ def respond_to? msg, private = false # :nodoc:
+ # why do I need this? Because ruby 2.0 is broken. That's why.
+ super
+ end
+
def pretty_print(q) # :nodoc:
nnd = ')'
nnd << ".line(#{line})" if line && ENV['VERBOSE']
q.group(1, 's(', nnd) do
@@ -245,21 +249,19 @@
##
# Returns the bare bones structure of the sexp.
# s(:a, :b, s(:c, :d), :e) => s(:a, s(:c))
def structure
- result = self.class.new
if Array === self.first then
- raise "When does this happen? #{self.inspect}" # TODO: remove >= 4.2.0
- result = self.first.structure
+ s(:bogus, *self).structure # TODO: remove >= 4.2.0
else
- result << self.first
- self.grep(Sexp).each do |subexp|
- result << subexp.structure
+ result = s(self.first)
+ self.each do |subexp|
+ result << subexp.structure if Sexp === subexp
end
+ result
end
- result
end
##
# Replaces the Sexp matching +pattern+ with +repl+.
@@ -325,6 +327,5 @@
# This is just a stupid shortcut to make indentation much cleaner.
def s(*args)
Sexp.new(*args)
end
-