Class: Pacproxy::PacFile

Inherits:
Object
  • Object
show all
Includes:
Loggable
Defined in:
lib/pacproxy/pac_file.rb

Overview

Pacproxy::PacFile represent proxy.pac file

Instance Method Summary collapse

Methods included from Loggable

#access_logger, #accesslog, #debug, #error, #fatal, #general_logger, #info, #lwarn

Constructor Details

#initialize(file_location, update_interval = 1800) ⇒ PacFile

Returns a new instance of PacFile.



10
11
12
13
14
15
16
17
18
19
20
# 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

Instance Method Details

#find(uri) ⇒ Object



27
28
29
30
# File 'lib/pacproxy/pac_file.rb', line 27

def find(uri)
  return 'DIRECT' unless @runtime
  @runtime.find(uri)
end

#shutdownObject



22
23
24
25
# File 'lib/pacproxy/pac_file.rb', line 22

def shutdown
  @update_thread.kill if @update_thread
  @runtime.shutdown   if @runtime
end