开发者

Ruby gems in lib - spare tire principle

I'm working on a console ruby application (not rails!) I will be installing this application on several machines. I was wondering if there is a way i can build it so i dont have to install the gems i'm using for the app on each machine. I'd like to be able to just copy the directory to each machine and run it. Ide开发者_Python百科ally, i'd like to put the gems in the lib folder or something and reference them from there, so i don't have to even install them on my dev machine. Is there a way to do this?

In .net, we call this the "spare tire" principle.

thanks, Craig


How about using bundler?

Then you can include a Gemfile that specifies all the necssary gems and just run "bundle install" on each machine to pull them down.

If you really want to bundle them with the app run "bundle package" and the gems will be stored in vendor/cache.


You could take the same approach as rails allows and "vendor" your gems. This involves creating a new directory (rails uses vendor/gems) and unpack the gem into this directory, using gem unpack.

You then configure your load path to include all of the sub-folders below that.

Edit

You can configure your load path by doing something like this

Dir.glob(File.join("vendor", "gems", "*", "lib")).each do |lib|
  $LOAD_PATH.unshift(File.expand_path(lib))
end
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜