From eb2f282b46476706521d2ec5e705714d1d4f4691 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Thu, 16 Jun 2011 10:27:16 -0400 Subject: [PATCH] if rails is loaded, but not well enough, load what we need for Jammit --- lib/guard/jammit.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/guard/jammit.rb b/lib/guard/jammit.rb index c8026a6..0627d04 100644 --- a/lib/guard/jammit.rb +++ b/lib/guard/jammit.rb @@ -1,6 +1,7 @@ require 'guard' require 'guard/guard' require 'jammit' + module Guard class Jammit < Guard @@ -46,6 +47,7 @@ module Guard end def jammit + ensure_rails_env! ::Jammit.load_configuration ::Jammit::DEFAULT_CONFIG_PATH puts "Jamming" ::Jammit.packager.force = true @@ -53,5 +55,11 @@ module Guard true end + private + def ensure_rails_env! + if !defined?(::Rails) || !::Rails.respond_to?(:env) + require 'rails' + end + end end -end \ No newline at end of file +end