def test01dfldsfl
assert(“djdjdj”)
puts “logiicl”
end
def test02sldkfjdsjl
assert(kdjslafdljs)
end
def test03
mymethod
#this is just an example
end
def setup
super()
end
end
and i want to get the code inside the test methods as an array like this
first position:
assert(“djdjdj”)
puts “logiicl”
second position:
assert(kdjslafdljs)
third position:
mymethod
#this is just an example
what kind of regular expression i can use. I was trying some like this:
/(^\sdef test[^def]+^\send\s*)/m
but ^def will treat it as single characters not as a word…
code=<<EEND
def aa(a)
a*2
end
def bb(a,b)
while a>b
a
end
end
EEND
def find_defn(sexp,l)
node,*tail=sexp
case node
when :block
tail.each { |a| find_defn(a,l) }
when :defn
l << {name: tail.first, code: Ruby2Ruby.new.process(tail.last)}
end
l
end