Class: Lookbook::Engine
- Inherits:
-
Rails::Engine
- Object
- Rails::Engine
- Lookbook::Engine
- Defined in:
- lib/lookbook/engine.rb
Class Method Summary collapse
- .app_name ⇒ Object
- .hooks ⇒ Object
- .inputs ⇒ Object
- .mount_path ⇒ Object
- .mounted? ⇒ Boolean
- .panels ⇒ Object
- .preview_controller ⇒ Object
- .tags ⇒ Object
- .websocket ⇒ Object
Instance Method Summary collapse
- #file_watcher ⇒ Object
- #listen? ⇒ Boolean
- #opts ⇒ Object
- #parser ⇒ Object
- #process ⇒ Object
- #run_hooks(event_name, *args) ⇒ Object
Class Method Details
.app_name ⇒ Object
114 115 116 117 118 119 120 121 |
# File 'lib/lookbook/engine.rb', line 114 def self.app_name name = if Rails.application.class.respond_to?(:module_parent_name) Rails.application.class.module_parent_name else Rails.application.class.parent_name end name.underscore end |
.hooks ⇒ Object
144 145 146 |
# File 'lib/lookbook/engine.rb', line 144 def self.hooks @hooks ||= HookStore.init_from_config end |
.inputs ⇒ Object
136 137 138 |
# File 'lib/lookbook/engine.rb', line 136 def self.inputs @inputs ||= InputStore.init_from_config end |
.mount_path ⇒ Object
106 107 108 |
# File 'lib/lookbook/engine.rb', line 106 def self.mount_path routes.find_script_name({}) end |
.mounted? ⇒ Boolean
110 111 112 |
# File 'lib/lookbook/engine.rb', line 110 def self.mounted? mount_path.present? end |
.panels ⇒ Object
132 133 134 |
# File 'lib/lookbook/engine.rb', line 132 def self.panels @panels ||= PanelStore.init_from_config end |
.preview_controller ⇒ Object
148 149 150 |
# File 'lib/lookbook/engine.rb', line 148 def self.preview_controller @preview_controller end |
.tags ⇒ Object
140 141 142 |
# File 'lib/lookbook/engine.rb', line 140 def self. @tags ||= TagStore.init_from_config end |
.websocket ⇒ Object
123 124 125 126 127 128 129 130 |
# File 'lib/lookbook/engine.rb', line 123 def self.websocket if mounted? use_websocket = opts.auto_refresh && opts.listen && process.supports_listening? @websocket ||= use_websocket ? Websocket.new(mount_path, logger: Lookbook.logger) : Websocket.noop else Websocket.noop end end |
Instance Method Details
#file_watcher ⇒ Object
94 95 96 |
# File 'lib/lookbook/engine.rb', line 94 def file_watcher @file_watcher ||= FileWatcher.new(force_polling: opts.listen_use_polling) end |
#listen? ⇒ Boolean
102 103 104 |
# File 'lib/lookbook/engine.rb', line 102 def listen? opts.listen && process.supports_listening? end |
#parser ⇒ Object
90 91 92 |
# File 'lib/lookbook/engine.rb', line 90 def parser @parser ||= PreviewParser.new(opts.preview_paths, Engine.) end |
#process ⇒ Object
98 99 100 |
# File 'lib/lookbook/engine.rb', line 98 def process @process ||= Process.new(env: Rails.env) end |
#run_hooks(event_name, *args) ⇒ Object
84 85 86 87 88 |
# File 'lib/lookbook/engine.rb', line 84 def run_hooks(event_name, *args) self.class.hooks.for_event(event_name).each do |hook| hook.call(Lookbook, *args) end end |