Class: ProxyPacRb::Cli::LintProxyPac

Inherits:
Thor::Group
  • Object
show all
Includes:
Shared
Defined in:
lib/proxy_pac_rb/cli/lint_proxy_pac.rb

Overview

Find proxy for url

Instance Method Summary collapse

Methods included from Shared

#enable_debug_mode, #remove_proxy_environment_variables

Instance Method Details

#pre_initObject



10
11
12
# File 'lib/proxy_pac_rb/cli/lint_proxy_pac.rb', line 10

def pre_init
  enable_debug_mode
end

#set_variablesObject



14
15
16
17
18
# File 'lib/proxy_pac_rb/cli/lint_proxy_pac.rb', line 14

def set_variables
  @proxy_pacs = options[:proxy_pac].map { |p| ProxyPacFile.new source: p }
  @loader     = ProxyPacLoader.new
  @linter     = ProxyPacLinter.new
end

#test_proxy_pacObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/proxy_pac_rb/cli/lint_proxy_pac.rb', line 20

def test_proxy_pac
  @proxy_pacs.each do |p|
    @loader.load(p)
    @linter.lint(p)

    if p.valid?
      $stderr.puts %(proxy.pac "#{p.source}" is of type #{p.type} and is valid.)
      true
    else
      $stderr.puts %(proxy.pac "#{p.source}" is of type #{p.type} and is invalid.)

      false
    end
  end
end