Class: ProxyPacRb::Cli::CompressProxyPac

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

Overview

Compress proxy pac

Instance Method Summary collapse

Methods included from Shared

#enable_debug_mode, #remove_proxy_environment_variables

Instance Method Details

#compress_proxy_pacObject



41
42
43
44
45
46
# File 'lib/proxy_pac_rb/cli/compress_proxy_pac.rb', line 41

def compress_proxy_pac
  @proxy_pacs.each do |p|
    @compressor.compress(p)
    @dumper.dump(p, type: :template)
  end
end

#load_filesObject



23
24
25
# File 'lib/proxy_pac_rb/cli/compress_proxy_pac.rb', line 23

def load_files
  @proxy_pacs.each { |p| @loader.load(p) }
end

#pre_initObject



11
12
13
# File 'lib/proxy_pac_rb/cli/compress_proxy_pac.rb', line 11

def pre_init
  enable_debug_mode
end

#set_variablesObject



15
16
17
18
19
20
21
# File 'lib/proxy_pac_rb/cli/compress_proxy_pac.rb', line 15

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

#test_proxy_pacObject



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/proxy_pac_rb/cli/compress_proxy_pac.rb', line 27

def test_proxy_pac
  @proxy_pacs.keep_if do |p|
    @linter.lint(p)

    if p.valid?
      true
    else
      $stderr.puts %(proxy.pac "#{p.source}" is of type #{p.type} and is invalid: #{p.message}. I'm going to ignore that file.)

      false
    end
  end
end