lib/lookbook/engine.rb in lookbook-3.0.0.alpha.0 vs lib/lookbook/engine.rb in lookbook-3.0.0.alpha.1

- old
+ new

@@ -10,39 +10,45 @@ config.before_initialize do |app| YARD::Parser::Ruby::RipperParser.prepend YardParserPatch end - config.after_initialize do + config.to_prepare do ViewComponentConfigSync.call if Gem.loaded_specs.has_key?("view_component") preview_controller = Lookbook.config.preview_controller.constantize unless preview_controller.include?(Lookbook::PreviewControllerActions) preview_controller.include(Lookbook::PreviewControllerActions) end + end - boot! + config.after_initialize do + if Engine.enabled? + start + else + info("Lookbook is loaded but not enabled in this environment (#{Rails.env}).") + end end class << self - def boot! - raise "Lookbook is already booted!" if @booted + def start + raise "Lookbook is already started!" if @started - info("Initializing Lookbook in #{Lookbook.env} mode...") + info("Starting Lookbook in #{Lookbook.env} mode...") if watch_files? Reloaders.register(Previews.reloader) Reloaders.register(Pages.reloader) Reloaders.execute else Previews.load Pages.load end - @booted = true + @started = true - info("Lookbook initialized#{" - watching filesystem for changes" if watch_files?}") + info("Lookbook started#{" - watching filesystem for changes" if watch_files?}") end def mount_path config.lookbook.mount_path || Lookbook::Config.defaults.mount_path end @@ -82,9 +88,13 @@ @updated_at = DateTime.now end def updated_at @updated_at ||= DateTime.now + end + + def enabled? + config.lookbook.enabled end end end end