gem unpack [gem]
each of the gems I'm using in the vendor directory. This works out well, but I am stuck maintaining the require [path/to/gem]
statements that are necessary for loading the libraries.To resolve this maintenance pain I put the following code in environment.rb.
Dir[File.dirname(__FILE__) + "/../vendor/*"].each do |path|The above script relies on a few RubyGems conventions: 3 digit versioning and a file in lib that requires all relevant ruby files for the library. I'm comfortable with these assumptions; however, not all gems follow them. For example, postgres-pr uses a ruby file named postres.rb to load the library. For situations like these, I still need to do an explicit require.
gem_name = File.basename(path.gsub(/-\d+.\d+.\d+$/, ''))
gem_path = path + "/lib/" + gem_name + ".rb"
require gem_path if File.exists? gem_path
end
Check out Rick Olson's GEMs plugin which will be rolled into core after the 1.2 release: http://svn.techno-weenie.net/projects/plugins/gems/
ReplyDeleteThis plus the gems.rake task Rick made will really help this be more widely used. Thanks!
ReplyDeleteI've also started some ideas on freezing & linknig gems into rails apps - http://rubyforge.org/projects/gemsonrails/
ReplyDeleteNot officially released or advertised yet, but its very nice so far.