Class: Kango::Reloader::Chrome::ExtensionsReloader

Inherits:
Object
  • Object
show all
Defined in:
lib/kango/reloader/chrome/extensions_reloader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeExtensionsReloader

Returns a new instance of ExtensionsReloader.



7
8
9
10
11
# File 'lib/kango/reloader/chrome/extensions_reloader.rb', line 7

def initialize
  self.watch_folder = File.join(Dir.pwd, 'output', 'chrome')
  STDOUT.puts "#{self.class} watching #{self.watch_folder}"
  STDOUT.puts "WARNING: This experimental feature requires the chrome extension called ExtensionsReloader and calls the following command: #{command}"
end

Instance Attribute Details

#onObject

Returns the value of attribute on.



5
6
7
# File 'lib/kango/reloader/chrome/extensions_reloader.rb', line 5

def on
  @on
end

#watch_folderObject

Returns the value of attribute watch_folder.



5
6
7
# File 'lib/kango/reloader/chrome/extensions_reloader.rb', line 5

def watch_folder
  @watch_folder
end

#watcherObject

Returns the value of attribute watcher.



5
6
7
# File 'lib/kango/reloader/chrome/extensions_reloader.rb', line 5

def watcher
  @watcher
end

Instance Method Details

#commandObject



24
25
26
# File 'lib/kango/reloader/chrome/extensions_reloader.rb', line 24

def command
  %{open -a '/Applications/Google\ Chrome\ Canary.app' 'http://reload.extensions'}
end

#reload_browserObject



28
29
30
# File 'lib/kango/reloader/chrome/extensions_reloader.rb', line 28

def reload_browser
  system(command)
end

#trigger(&block) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/kango/reloader/chrome/extensions_reloader.rb', line 13

def trigger &block
  return if @on
  self.watcher = DirectoryWatcher.new(self.watch_folder, :pre_load => true)
  self.watcher.interval = 1
  self.watcher.add_observer do |*args|
    block.call
  end
  self.watcher.start
  self.on = true
end