if rails is loaded, but not well enough, load what we need for Jammit

This commit is contained in:
John Bintz 2011-06-16 10:27:16 -04:00
parent 3a11aea76f
commit eb2f282b46

View File

@ -1,6 +1,7 @@
require 'guard' require 'guard'
require 'guard/guard' require 'guard/guard'
require 'jammit' require 'jammit'
module Guard module Guard
class Jammit < Guard class Jammit < Guard
@ -46,6 +47,7 @@ module Guard
end end
def jammit def jammit
ensure_rails_env!
::Jammit.load_configuration ::Jammit::DEFAULT_CONFIG_PATH ::Jammit.load_configuration ::Jammit::DEFAULT_CONFIG_PATH
puts "Jamming" puts "Jamming"
::Jammit.packager.force = true ::Jammit.packager.force = true
@ -53,5 +55,11 @@ module Guard
true true
end end
private
def ensure_rails_env!
if !defined?(::Rails) || !::Rails.respond_to?(:env)
require 'rails'
end
end
end end
end end