class Guard::LiveReload

Attributes

options[RW]
reactor[RW]

Public Class Methods

new(options = {}) click to toggle source
Calls superclass method
# File lib/guard/livereload.rb, line 11
def initialize(options = {})
  super

  js_path = File.expand_path('../../../js/livereload.js.erb', __FILE__)
  @options = {
    host:           '0.0.0.0',
    port:           '35729',
    apply_css_live: true,
    override_url:   false,
    grace_period:   0,
    js_template: js_path
  }.merge(options)

  js_path = @options[:js_template]

  # NOTE: save snippet as instvar, so it's not GC'ed
  @snippet = Snippet.new(js_path, @options)
  @options[:livereload_js_path] = @snippet.path
end

Public Instance Methods

run_on_modifications(paths) click to toggle source
# File lib/guard/livereload.rb, line 39
def run_on_modifications(paths)
  sleep options[:grace_period]
  reactor.reload_browser(paths)
end
start() click to toggle source
# File lib/guard/livereload.rb, line 31
def start
  @reactor = Reactor.new(options)
end
stop() click to toggle source
# File lib/guard/livereload.rb, line 35
def stop
  reactor.stop
end