BVB Source Codes

guard-livereload Show livereload.rb Source code

Return Download guard-livereload: download livereload.rb Source code - Download guard-livereload Source code - Type:.rb
  1. require 'guard/compat/plugin'
  2.  
  3. module Guard
  4.   class LiveReload < Plugin
  5.     require 'guard/livereload/websocket'
  6.     require 'guard/livereload/reactor'
  7.     require 'guard/livereload/snippet'
  8.     require 'guard/livereload/guaranteed_sleep'
  9.  
  10.     attr_accessor :reactor, :options
  11.  
  12.     def initialize(options = {})
  13.       super
  14.  
  15.       js_path = File.expand_path('../../../js/livereload.js.erb', __FILE__)
  16.       @options = {
  17.         host:           '0.0.0.0',
  18.         port:           '35729',
  19.         apply_css_live: true,
  20.         override_url:   false,
  21.         grace_period:   0,
  22.         js_template: js_path
  23.       }.merge(options)
  24.  
  25.       js_path = @options[:js_template]
  26.  
  27.       # NOTE: save snippet as instvar, so it's not GC'ed
  28.       @snippet = Snippet.new(js_path, @options)
  29.       @options[:livereload_js_path] = @snippet.path
  30.     end
  31.  
  32.     def start
  33.       @reactor = Reactor.new(options)
  34.     end
  35.  
  36.     def stop
  37.       reactor.stop
  38.     end
  39.  
  40.     def run_on_modifications(paths)
  41.       GuaranteedSleep.new.sleep(options[:grace_period])
  42.       reactor.reload_browser(paths)
  43.     end
  44.   end
  45. end
  46.  
downloadlivereload.rb Source code - Download guard-livereload Source code
Related Source Codes/Software:
Begin-Latex-in-minutes - Brief Intro to LaTeX for beginners that helps you ... 2017-04-22
wicked - Use wicked to turn your controller into a wizard ... 2017-04-22
flexboxfroggy - A game for learning CSS flexbox ... 2017-04-22
phpDocumentor2 - Documentation Generator for PHP ... 2017-04-22
cmus - Small, fast and powerful console music player for ... 2017-04-22
grit - **Grit is no longer maintained. Check out libgit2/... 2017-04-22
grr - GRR Rapid Response: remote live forensics for inci... 2017-04-22
libsvm - 2017-04-22
breakpoint - Really simple media queries in Sa 2017-04-23
CoffeeScriptRedux - 2017-04-23
PreloadJS - PreloadJS makes preloading assets & getting ag... 2017-04-29
gotraining - Go Training Class Material : ... 2017-04-29
eigen - The Art World in Your Pocket or Your Trendy Tech C... 2017-04-29
rack-cors - Rack Middleware for handling Cross-Origin Resource... 2017-04-29
react-redux-tutorial - react-redux-tutorial in Chinese, catalog &&... 2017-04-29
swifter - Tiny http server engine written in Swift programmi... 2017-04-29
Chartbuilder - A front-end charting application that facilitates ... 2017-04-29
offline-first - 2017-04-29
plotly.py - An interactive, browser-based graphing library for... 2017-04-29
statsmodels - Statsmodels: statistical modeling and econometrics... 2017-04-29

 Back to top