Class: Hyla::Commands::Reload
- Inherits:
-
Hyla::Command
- Object
- Hyla::Command
- Hyla::Commands::Reload
- Defined in:
- lib/hyla/commands/reload.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{ host: '0.0.0.0', port: '35729', apply_css_live: true, override_url: false, grace_period: 0 }
- @@web_sockets =
[]
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#thread ⇒ Object
readonly
Returns the value of attribute thread.
-
#web_sockets ⇒ Object
readonly
Returns the value of attribute web_sockets.
Instance Method Summary collapse
-
#initialize ⇒ Reload
constructor
A new instance of Reload.
- #process(options) ⇒ Object
- #reload_browser(paths = []) ⇒ Object
- #reload_browser2(paths = []) ⇒ Object
Methods inherited from Hyla::Command
Constructor Details
#initialize ⇒ Reload
Returns a new instance of Reload.
17 18 |
# File 'lib/hyla/commands/reload.rb', line 17 def initialize() end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/hyla/commands/reload.rb', line 5 def @options end |
#thread ⇒ Object (readonly)
Returns the value of attribute thread.
5 6 7 |
# File 'lib/hyla/commands/reload.rb', line 5 def thread @thread end |
#web_sockets ⇒ Object (readonly)
Returns the value of attribute web_sockets.
5 6 7 |
# File 'lib/hyla/commands/reload.rb', line 5 def web_sockets @web_sockets end |
Instance Method Details
#process(options) ⇒ Object
20 21 22 23 24 |
# File 'lib/hyla/commands/reload.rb', line 20 def process() @options = DEFAULT_OPTIONS.clone.merge() @Websocket ||= Hyla::WebSocket _start end |
#reload_browser(paths = []) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/hyla/commands/reload.rb', line 26 def reload_browser(paths = []) Hyla.logger.info "Reloading browser: #{paths.join(' ')}" paths.each do |path| Hyla.logger.info(path) data = _data(path) Hyla.logger.info(">> Data received : #{data}") @@web_sockets.each { |ws| ws.send(MultiJson.encode(data)) } end end |
#reload_browser2(paths = []) ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/hyla/commands/reload.rb', line 36 def reload_browser2(paths = []) Hyla.logger.info "Reloading browser: #{paths.join(' ')}" paths.each do |path| Hyla.logger.info(path) data = 'hyla/development/' Hyla.logger.info(">> Data received : #{data}") @@web_sockets.each { |ws| ws.send(MultiJson.encode(data)) } end end |