views:

52

answers:

3

Hello,

I am playing around with ruby and making my first desktop app. I have used 2 gems for my app and to make my "application" portable, I need to freeze those 2 gems and make my project refer to those gems from its project folder.

I know many ways to do it on Rails, but how to do it manually in Ruby?

Note: I am using jeweler using advice of my previous question. Thanks

A: 

What about using Bundler? You could simply lock your application gems with it.

tbuehlmann
yea, Bundler is an option, but this wont make a desktop app truely portable. In rails we have an option for rake freezen:gems. Can we replicate a similar functionality? How?
zengr
A: 

My first suggestion would also be, to use Bundler and lock your bundle. You can even put the bundle inside your app directory if you want to distribute the gems with it (though this might lead to problems if a gem contains an extension with native code and you're distributing it to a different platform).

Btw, Rails 3 uses Bundler for gem management exclusively. There will be no rake rails:freeze:gems in Rails 3 anymore.

As another option (if you don't want to use Bundler for some reason), you could manually put the lib dir of a gem to some subdirectory of the lib dir in your app, add it to your load path and require it manually. If a gem contains pure Ruby code without any extension, this might do well (but would be hard to maintain since you'd need to do updates manually).

Andreas
+1  A: 

You could use them independently of the rubygems infrastructure by first unpacking each gem into vendor/gems (or whatever path within your project):

cd yourapp
mkdir -p vendor/gems
cd vendor/gems
gem unpack gem1
gem unpack gem2
[etc.]

... and then adding all the frozen gems' lib directories into your load path:

$:.unshift(*Dir[File.dirname(__FILE__) + "/vendor/gems/**/lib"])
Daniel Vandersluis