Override Rails' default gem handling and replace it with Bundler

Bundler does a better job of manage dependencies and is used by default
in Rails 3 so this will move Tracks a bit closer towards a Rails 3
conversion.
This commit is contained in:
Matt Rogers 2011-08-18 10:12:29 -05:00
parent e93a6970bd
commit 69cb08378d
2 changed files with 35 additions and 0 deletions

View file

@ -110,5 +110,19 @@ module Rails
end end
end end
class Rails::Boot
def run
load_initializer
Rails::Initializer.class_eval do
def load_gems
@bundler_loaded ||= Bundler.require :default, Rails.env
end
end
Rails::Initializer.run(:set_load_path)
end
end
# All that for this: # All that for this:
Rails.boot! Rails.boot!

21
config/preinitializer.rb Normal file
View file

@ -0,0 +1,21 @@
begin
require "rubygems"
require "bundler"
rescue LoadError
raise "Could not load the bundler gem. Install it with `gem install bundler`."
end
if Gem::Version.new(Bundler::VERSION) <= Gem::Version.new("0.9.24")
raise RuntimeError, "Your bundler version is too old for Rails 2.3." +
"Run `gem install bundler` to upgrade."
end
begin
# Set up load paths for all bundled gems
ENV["BUNDLE_GEMFILE"] = File.expand_path("../../Gemfile", __FILE__)
Bundler.setup
rescue Bundler::GemNotFound
raise RuntimeError, "Bundler couldn't find some gems." +
"Did you run `bundle install`?"
end