How do I browse the source code for a gem in Rails3 with RVM (linux & gedit)

懵懂的女人 提交于 2019-12-07 10:56:54

问题


I am running rails3 in Ubuntu and using gedit for coding. I am using RVM. To look at the gem source code I tried: bundle open jquery-rails

That doesn't work since I hadn't setup an editor. After setting gedit as the editor it still doesn't work because gedit can't be passed directories. I guess it only works with files. Too bad :(.

nathan.f77's answer to this question ( Lookup Gem or Plugin code packaged in a Rails3 application ) seems promising, but I wasn't able to follow his instructions. They lacked sufficient detail for me.

What is a very easy way to browse the source files for gems that I am using in my rails3 app?


回答1:


bundle show jquery-rails should tell you where the gem source lives on your filesystem. Then open the file that you want.




回答2:


CubaLibre's response got me half-way there. The other piece of the puzzle I was able to get from Ask Ubuntu.

Here are the steps to browse gem code in gedit using Ubuntu.

a. From the command line run:

gnome-open $(bundle show [gem-name])

b. This will open up the gem directory in nautilus. From there just double click on file you'd like to see and it will open up in gedit.




回答3:


Assuming you have a default editor set in your terminal, on MacOS you can do something like this example (atom is my editor, but should work with sublime or textmate, vim, etc.):

atom $(bundle show name_of_gem)


来源:https://stackoverflow.com/questions/11546475/how-do-i-browse-the-source-code-for-a-gem-in-rails3-with-rvm-linux-gedit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!