There is a DSL ruby file which I need to parse. It looks like
# file B.rb
class B < A
hello "John"
end
hello "Mary"
It calls function hello() with a string parameter both inside and outside of the class B.
I try to require the file B.rb and resolve the missing methods:
# file A.rb
# define a class A for subclassing, before loading B.rb
class A
end
# Try to catch the missing methods
def method_missing(name, *args, &block)
puts "tried to handle unknown method %s" % name # name is a symbol
end
require("./B.rb")
After running this code, the method_missing causes infinite loop.
How to capture and resolve undefined method both inside and outside of the class B? I want to know what the methods and parameters are called in the DSL file.