Nokogiri很棒.我可以做类似#css('.bla')这样的操作,它将返回第一个匹配的元素.
Nokogiri is awesome. I can do things like #css('.bla') which will return the first matching element.
现在,我们需要对Ruby源代码进行一些解析-查找类中的所有方法,等等.我们正在使用 ruby_parser gem,但是它所做的只是梳理您的源代码并吐出S表达式.对于这些S表达式,是否有类似Nokogiri的功能,它们可以完成为找到的名为'foo'的第一个方法返回S表达式"之类的事情?
Right now we need to do some parsing of Ruby source code - finding all methods within a class etc. We're using the ruby_parser gem, but all it does is comb your source code and spit out S-expressions. Is there anything like Nokogiri for these S-expressions which can do things like "return S-expression for first method found named 'foo'"?
推荐答案我唯一能想到的是亚当·桑德森(Adam Sanderson)的SExpPath库.
The only thing I can think of, is Adam Sanderson's SExpPath library.
更多推荐
是否有类似于Nokogiri的语法来解析Ruby代码?
发布评论