class Pacproxy::PacFile
Pacproxy::PacFile
represent proxy.pac file
Public Class Methods
new(file_location, update_interval = 1800)
click to toggle source
# File lib/pacproxy/pac_file.rb, line 10 def initialize(file_location, update_interval = 1800) begin require 'pac' rescue PAC::RuntimeUnavailable info('No javascript runtime found for pac') end @file_location = file_location @update_interval = update_interval @runtime = Runtime.new begin_update end
Public Instance Methods
find(uri)
click to toggle source
# File lib/pacproxy/pac_file.rb, line 27 def find(uri) return 'DIRECT' unless @runtime @runtime.find(uri) end
shutdown()
click to toggle source
# File lib/pacproxy/pac_file.rb, line 22 def shutdown @update_thread.kill if @update_thread @runtime.shutdown if @runtime end
Private Instance Methods
begin_update()
click to toggle source
# File lib/pacproxy/pac_file.rb, line 34 def begin_update is_updated = false @update_thread = Thread.new do loop do @runtime.update(@file_location) is_updated = true sleep(@update_interval) end end sleep 0.01 until is_updated end