Sha256: a77dbdc4e3252bc2d6e1290e52c3992022efec4b7fd98a18549f7a926508317a

Contents?: true

Size: 1.17 KB

Versions: 4

Compression:

Stored size: 1.17 KB

Contents

# encoding: utf-8
# frozen_string_literal: true
module ProxyPacRb
  module Cli
    # Compress proxy pac
    class CompressProxyPac < Thor::Group
      include Shared

      class_option :proxy_pac, type: :array, desc: 'Proxy.pac-file(s)', aliases: '-p', required: true

      def pre_init
        enable_debug_mode
      end

      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

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

      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

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
proxy_pac_rb-3.0.0 lib/proxy_pac_rb/cli/compress_proxy_pac.rb
proxy_pac_rb-2.1.0 lib/proxy_pac_rb/cli/compress_proxy_pac.rb
proxy_pac_rb-2.0.0 lib/proxy_pac_rb/cli/compress_proxy_pac.rb
proxy_pac_rb-1.0.0 lib/proxy_pac_rb/cli/compress_proxy_pac.rb