Can I add Ruby gem / module like a Java jar file?

I use eclispse Kepler and dltk plug-ins to make ruby I can't "request" the nokogiri module because eclipse can't find it I tried some gem install commands from some websites, but it didn't help Now, I don't want to use the command line until I master Ruby Programming for the first time

I learned that I can add Java jars to my project by creating a lib folder, copying jar files to that folder, and then adding them all to the build path Is it that simple?

Can I do the same thing for Ruby gems and modules? Ideally, I just want to use the IDE instead of the command line and complex installation script

Please help.

Solution

If this gem has all the dependencies installed, you can add it using a simple require command:

require "/path_to_gems/gem_name/lib/gem_name"

In my case, the command is:

require '/Users/yukke/.rvm/gems/ruby-2.1.1/gems/nokogiri-1.6.1/lib/nokogiri'

Otherwise, you can try to ask rubygems:

require "rubygems"
require "gem-name"
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>