Module: React::Rails::HotLoader

Defined in:
lib/hot_loader.rb,
lib/hot_loader/server.rb,
lib/hot_loader/railtie.rb,
lib/hot_loader/version.rb,
lib/hot_loader/asset_path.rb,
lib/hot_loader/asset_change_set.rb

Defined Under Namespace

Classes: AssetChangeSet, AssetPath, Railtie, Server

Constant Summary collapse

VERSION =
'0.2.0'

Class Method Summary collapse

Class Method Details

.error(err) ⇒ Object



26
27
28
29
# File 'lib/hot_loader.rb', line 26

def self.error(err)
  msg = "#{err.class.name}: #{err}\n #{err.backtrace.join("\n")}"
  log(msg)
end

.log(message) ⇒ Object



20
21
22
23
24
# File 'lib/hot_loader.rb', line 20

def self.log(message)
  msg = "[HotLoader] #{message}"
  ::Rails.logger.info(msg)
  ::Rails.logger.flush
end

.restartObject

Restart the server with the same options



14
15
16
17
18
# File 'lib/hot_loader.rb', line 14

def self.restart
  server.restart
rescue StandardError => err
  React::Rails::HotLoader.error(err)
end

.start(options = {}) ⇒ Object

Create a new server with ‘options` & start it



7
8
9
10
11
# File 'lib/hot_loader.rb', line 7

def self.start(options={})
  server_class = options.delete(:server_class) || Server
  self.server = server_class.new(options)
  restart
end