4

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?

Community
  • 1
  • 1
snowguy
  • 899
  • 2
  • 13
  • 23

3 Answers3

12

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

CubaLibre
  • 1,675
  • 13
  • 22
  • Ok. I'm close to figuring this out I think with this help. How do I get the output of that command to open up in nautilus? I tried: bundle show jquery-rails | gnome open. That doesn't work. Any ideas? – snowguy Jul 19 '12 at 06:18
  • @snowguy sorry i don't know anything about nautilus. I use a Mac and Rubymine for Ruby code, so i get 'jump to definition' for free. In your case, I would use emacs/vim and open individual files as i need them. You can explore generating a TAGS table with etags/ctags and using the http://www.emacswiki.org/emacs/JumpToDefinition operation in emacs as well! All the best. – CubaLibre Jul 22 '12 at 13:39
  • 1
    The piping of commands in Ubuntu works as expected. You just have to use it the right way. Like in your example it should be `bundle show jquery-rails | xargs gnome-open` – Ramandeep Singh Apr 17 '13 at 10:04
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.

Community
  • 1
  • 1
snowguy
  • 899
  • 2
  • 13
  • 23
0

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)
lacostenycoder
  • 10,623
  • 4
  • 31
  • 48