Sha256: 0f2776f11be8e52568ee58d46f079d9d90618382786bfbc2755f348974205134

Contents?: true

Size: 1003 Bytes

Versions: 2

Compression:

Stored size: 1003 Bytes

Contents

module Kango
  module Reloader
    module Chrome
      class ExtensionsReloader
        attr_accessor :watch_folder, :watcher, :on

        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

        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

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

        def reload_browser
          system(command)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
kango-0.1.0.0.9.2 lib/kango/reloader/chrome/extensions_reloader.rb
kango-0.0.3.0.9.2 lib/kango/reloader/chrome/extensions_reloader.rb