Class: Hyla::Commands::Reload

Inherits:
Hyla::Command show all
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

Instance Method Summary collapse

Methods inherited from Hyla::Command

check_mandatory_option?

Constructor Details

#initializeReload

Returns a new instance of Reload.



17
18
# File 'lib/hyla/commands/reload.rb', line 17

def initialize()
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/hyla/commands/reload.rb', line 5

def options
  @options
end

#threadObject (readonly)

Returns the value of attribute thread.



5
6
7
# File 'lib/hyla/commands/reload.rb', line 5

def thread
  @thread
end

#web_socketsObject (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)
  @options = DEFAULT_OPTIONS.clone.merge(options)
  @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