Class: ProxyPacRb::ProxyPacLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/proxy_pac_rb/proxy_pac_loader.rb

Overview

Dump Proxy pac to file system

Instance Method Summary collapse

Constructor Details

#initializeProxyPacLoader


12
13
14
15
16
17
18
19
20
# File 'lib/proxy_pac_rb/proxy_pac_loader.rb', line 12

def initialize
  @loaders = []
  @loaders << ProxyPacStringLoader.new
  @loaders << ProxyPacUriLoader.new
  @loaders << ProxyPacFileLoader.new
  @loaders << ProxyPacNullLoader.new

  @default_loader = -> { ProxyPacNullLoader.new }
end

Instance Method Details

#load(proxy_pac) ⇒ Object

Load proxy pac


26
27
28
29
30
31
32
33
34
35
# File 'lib/proxy_pac_rb/proxy_pac_loader.rb', line 26

def load(proxy_pac)
  return if proxy_pac.content?

  loaders.find(default_loader) { |l| l.suitable_for? proxy_pac }.load(proxy_pac)

  proxy_pac.readable = true
rescue => err
  proxy_pac.message = err.message
  proxy_pac.readable = false
end