Sha256: 9492232d6a048e15eceaca549edeb9e61f968a40f5b4ab959a48446da13f9118

Contents?: true

Size: 675 Bytes

Versions: 4

Compression:

Stored size: 675 Bytes

Contents

# encoding: utf-8
# frozen_string_literal: true
module ProxyPacRb
  # Parse Proxy pac to file system
  class ProxyPacParser
    private

    attr_reader :environment, :runtime, :compiler

    public

    def initialize(
      environment: Environment.new,
      compiler: JavascriptCompiler.new
    )
      @environment = environment
      @compiler    = compiler
    end

    def parse(proxy_pac)
      return unless proxy_pac.valid?

      proxy_pac.javascript = compiler.compile(content: proxy_pac.content, environment: environment)
      proxy_pac.parsable = true
    rescue => err
      proxy_pac.parsable = false
      proxy_pac.message = err.message
    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/proxy_pac_parser.rb
proxy_pac_rb-2.1.0 lib/proxy_pac_rb/proxy_pac_parser.rb
proxy_pac_rb-2.0.0 lib/proxy_pac_rb/proxy_pac_parser.rb
proxy_pac_rb-1.0.0 lib/proxy_pac_rb/proxy_pac_parser.rb