lib/spontaneous/plugins/application/state.rb in spontaneous-0.1.0.alpha1 vs lib/spontaneous/plugins/application/state.rb in spontaneous-0.2.0.alpha1
- old
+ new
@@ -1,24 +1,22 @@
# encoding: UTF-8
-
module Spontaneous::Plugins::Application
module State
+ extend ActiveSupport::Concern
- def self.configure(base)
- end
-
module ClassMethods
-
def init(options={})
# return false if loaded?
self.environment = (options.delete(:environment) || ENV["SPOT_ENV"] || :development)
self.mode = options.delete(:mode) || ENV["SPOT_MODE"] || :back
+ root = options.delete(:root) || ENV["SPOT_ROOT"] || Dir.pwd
+ site = Spontaneous::Site.instantiate(root, environment, mode)
Spontaneous::Logger.setup(:log_level => options[:log_level], :logfile => options[:logfile], :cli => options[:cli])
- Spontaneous.instance = Spontaneous::Site.instantiate(root, environment, mode)
- Spontaneous.instance.initialize!
- Spontaneous::Schema.validate! if self.mode == :console
+ site.initialize!
+ site.schema.validate! if self.mode == :console
+ logger.warn "Auto login is enabled and set to '#{site.config.auto_login}'. Please ensure this is disabled in production mode by removing the 'auto_login' setting from your environment file." if site.config.auto_login and mode == :back
Thread.current[:spontaneous_loaded] = true
end
def loaded?
Thread.current[:spontaneous_loaded]
@@ -81,6 +79,5 @@
environment == :test
end
end # ClassMethods
end # State
end
-