Class: Guard::LiveReload
- Inherits:
-
Plugin
- Object
- Plugin
- Guard::LiveReload
- Defined in:
- lib/guard/livereload.rb,
lib/guard/livereload/reactor.rb,
lib/guard/livereload/snippet.rb,
lib/guard/livereload/websocket.rb
Defined Under Namespace
Classes: Reactor, Snippet, WebSocket
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
-
#reactor ⇒ Object
Returns the value of attribute reactor.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ LiveReload
constructor
A new instance of LiveReload.
- #run_on_modifications(paths) ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ LiveReload
Returns a new instance of LiveReload.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/guard/livereload.rb', line 11 def initialize( = {}) super js_path = File.('../../../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() 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 |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
9 10 11 |
# File 'lib/guard/livereload.rb', line 9 def @options end |
#reactor ⇒ Object
Returns the value of attribute reactor.
9 10 11 |
# File 'lib/guard/livereload.rb', line 9 def reactor @reactor end |
Instance Method Details
#run_on_modifications(paths) ⇒ Object
39 40 41 42 |
# File 'lib/guard/livereload.rb', line 39 def run_on_modifications(paths) sleep [:grace_period] reactor.reload_browser(paths) end |
#start ⇒ Object
31 32 33 |
# File 'lib/guard/livereload.rb', line 31 def start @reactor = Reactor.new() end |
#stop ⇒ Object
35 36 37 |
# File 'lib/guard/livereload.rb', line 35 def stop reactor.stop end |