Class: MoCo::Browser
- Inherits:
-
Object
- Object
- MoCo::Browser
- Defined in:
- lib/moco/browser.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(extensions, browsers, urls) ⇒ Browser
constructor
A new instance of Browser.
- #reload ⇒ Object
- #should_reload?(file) ⇒ Boolean
Constructor Details
#initialize(extensions, browsers, urls) ⇒ Browser
Returns a new instance of Browser.
26 27 28 29 30 31 |
# File 'lib/moco/browser.rb', line 26 def initialize(extensions, browsers, urls) @extensions = extensions @args = browsers + urls(urls) @reload = false at_exit { do_reload } end |
Class Method Details
.browsers ⇒ Object
9 10 11 |
# File 'lib/moco/browser.rb', line 9 def self.browsers %w[Canary Chrome Firefox Opera Safari WebKit] end |
.extensions ⇒ Object
5 6 7 |
# File 'lib/moco/browser.rb', line 5 def self.extensions %w[css html js] end |
.localhost ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/moco/browser.rb', line 13 def self.localhost %w[ file:/// file://localhost/ http://localhost/ http://localhost: http://127.0.0.1/ http://127.0.0.1: http://0.0.0.0/ http://0.0.0.0: ] end |
Instance Method Details
#reload ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/moco/browser.rb', line 37 def reload return if @reload @reload = true Thread.new do sleep 0.2 do_reload end end |
#should_reload?(file) ⇒ Boolean
33 34 35 |
# File 'lib/moco/browser.rb', line 33 def should_reload?(file) @extensions.include?(FileUtil.normalized_extension(file)) end |