Sha256: 28c0a036c2eb0502a261efcfb96c28c92d8a2ddc129024d04d2029e99fbe46da

Contents?: true

Size: 1.22 KB

Versions: 25

Compression:

Stored size: 1.22 KB

Contents

# encoding: utf-8
module ProxyPacRb
  # Proxy Pac parser
  #
  # @example Usage
  #
  # parser = Parser.new
  # parser.load('http://example.com/proxy.pac')
  # parser.read('file.pac')
  #
  # string = ''
  # parser.source(string)
  class Parser
    private

    attr_reader :parser, :loader, :linter

    public

    def initialize(*args)
      if args.first.is_a? Hash
        @parser = ProxyPacParser.new(**args.first)
      else
        $stderr.puts 'Deprecated: Use of positional parameters. Please use named parameters: environment: Environment.new.'
        @parser = ProxyPacParser.new(environment: args.first)
      end

      @loader = ProxyPacLoader.new
      @linter = ProxyPacLinter.new
    end

    def parse(source)
      pac_file = ProxyPacFile.new source: source

      loader.load(pac_file)
      linter.lint(pac_file)
      parser.parse(pac_file)

      pac_file
    end

    def load(*args)
      $stderr.puts 'Deprecated: #load. Please use #parse instead.'

      parse(*args)
    end

    def read(*args)
      $stderr.puts 'Deprecated: #read. Please use #parse instead.'

      parse(*args)
    end

    def source(*args)
      $stderr.puts 'Deprecated: #source. Please use #parse instead.'

      parse(*args)
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
proxy_pac_rb-0.9.1 lib/proxy_pac_rb/parser.rb
proxy_pac_rb-0.8.2 lib/proxy_pac_rb/parser.rb
proxy_pac_rb-0.8.1 lib/proxy_pac_rb/parser.rb
proxy_pac_rb-0.8.0 lib/proxy_pac_rb/parser.rb
proxy_pac_rb-0.7.0 lib/proxy_pac_rb/parser.rb
proxy_pac_rb-0.6.9 lib/proxy_pac_rb/parser.rb
proxy_pac_rb-0.6.8 lib/proxy_pac_rb/parser.rb
proxy_pac_rb-0.6.7 lib/proxy_pac_rb/parser.rb
proxy_pac_rb-0.6.5 lib/proxy_pac_rb/parser.rb
proxy_pac_rb-0.6.4 lib/proxy_pac_rb/parser.rb
proxy_pac_rb-0.6.3 lib/proxy_pac_rb/parser.rb
proxy_pac_rb-0.6.2 lib/proxy_pac_rb/parser.rb
proxy_pac_rb-0.6.1 lib/proxy_pac_rb/parser.rb
proxy_pac_rb-0.6.0 lib/proxy_pac_rb/parser.rb
proxy_pac_rb-0.5.10 lib/proxy_pac_rb/parser.rb
proxy_pac_rb-0.5.9 lib/proxy_pac_rb/parser.rb
proxy_pac_rb-0.5.8 lib/proxy_pac_rb/parser.rb
proxy_pac_rb-0.5.7 lib/proxy_pac_rb/parser.rb
proxy_pac_rb-0.5.6 lib/proxy_pac_rb/parser.rb
proxy_pac_rb-0.5.5 lib/proxy_pac_rb/parser.rb