From cb0e3d926435a2c5d364bb56a63f32cec3c152f5 Mon Sep 17 00:00:00 2001 From: Marnen Laibow-Koser Date: Thu, 1 Sep 2011 14:57:30 -0400 Subject: [PATCH] Add Bundler stuff. [#53] --- config/boot.rb | 17 +++++++++++++++++ config/preinitializer.rb | 23 +++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 config/preinitializer.rb diff --git a/config/boot.rb b/config/boot.rb index 6686664c..dbeae81a 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -110,5 +110,22 @@ def read_environment_rb end end +# BEGIN Bundler code. +# TODO: remove when we upgrade to Rails 3. +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 +# END Bundler code. + # All that for this: Rails.boot! diff --git a/config/preinitializer.rb b/config/preinitializer.rb new file mode 100644 index 00000000..bced7d6d --- /dev/null +++ b/config/preinitializer.rb @@ -0,0 +1,23 @@ +# This is for Bundler. +# TODO: Remove when we upgrade to Rails 3! + +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 \ No newline at end of file