Class: ProxyPacRb::Cli::FindProxy
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- ProxyPacRb::Cli::FindProxy
- Includes:
- Shared
- Defined in:
- lib/proxy_pac_rb/cli/find_proxy.rb
Overview
Find proxy for url
Instance Method Summary collapse
Methods included from Shared
#enable_debug_mode, #remove_proxy_environment_variables
Instance Method Details
#find_proxy ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/proxy_pac_rb/cli/find_proxy.rb', line 19 def find_proxy CliValidator.new().validate environment = ProxyPacRb::Environment.new( client_ip: IPAddr.new([:client_ip]), time: Time.parse([:time]) ) remove_proxy_environment_variables unless [:use_proxy] file = ProxyPacRb::Parser.new(environment: environment).parse([:proxy_pac]) return if file.blank? $stderr.printf("%30s: %-s\n", 'url', 'result') [:urls].each do |u| begin $stderr.printf("%30s: %-s\n", u, file.find(u)) rescue UrlInvalidError $stderr.puts "You provide an invalid url \"#{u}\". Please use a correct one." rescue ProxyPacRb::ProxyPacInvalidError => err $stderr.puts err. end end end |
#pre_init ⇒ Object
15 16 17 |
# File 'lib/proxy_pac_rb/cli/find_proxy.rb', line 15 def pre_init enable_debug_mode end |