Class: MoCo::Browser

Inherits:
Object
  • Object
show all
Defined in:
lib/moco/browser.rb

Class Method Summary collapse

Instance Method Summary collapse

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

.browsersObject



9
10
11
# File 'lib/moco/browser.rb', line 9

def self.browsers
  %w[Canary Chrome Firefox Opera Safari WebKit]
end

.extensionsObject



5
6
7
# File 'lib/moco/browser.rb', line 5

def self.extensions
  %w[css html js]
end

.localhostObject



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

#reloadObject



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

Returns:

  • (Boolean)


33
34
35
# File 'lib/moco/browser.rb', line 33

def should_reload?(file)
  @extensions.include?(FileUtil.normalized_extension(file))
end