是否有类似于Nokogiri的语法来解析Ruby代码? [英] Is there something similar to Nokogiri for parsing Ruby code?

查看:91
本文介绍了是否有类似于Nokogiri的语法来解析Ruby代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Nokogiri很棒.我可以做类似#css('.bla')这样的操作,它将返回第一个匹配的元素.

Nokogiri is awesome. I can do things like #css('.bla') which will return the first matching element.

现在,我们需要对Ruby源代码进行一些解析-查找类中的所有方法,等等.我们正在使用

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代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆