# 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
# File lib/guard/livereload.rb, line 39 def run_on_modifications(paths) sleep options[:grace_period] reactor.reload_browser(paths) end
# File lib/guard/livereload.rb, line 31 def start @reactor = Reactor.new(options) end
# File lib/guard/livereload.rb, line 35 def stop reactor.stop end