Sha256: 92335e485d9823460bc2c8aea88002a311c79cf8a11df32d24167b4152a61361

Contents?: true

Size: 1.4 KB

Versions: 16

Compression:

Stored size: 1.4 KB

Contents

# encoding: utf-8
module LocalPac
  module ProxyPac
    class ResultParser
      class PacResultHtmlStylist
        attr_reader :class_proxy_port, :class_proxy, :class_proxy_port

        def initialize(options = {})
          @class_request_type = options.fetch(:class_request_type, 'lp_request_type')
          @class_proxy        = options.fetch(:class_proxy, 'lp_proxy')
          @class_proxy_port   = options.fetch(:class_proxy_port, 'lp_proxy_port')
        end

        def style_me(result)
          styled_result = []

          styled_result << span(result.request_type, class_request_type) if result.request_type
          styled_result << " "                                           if result.proxy || result.proxy_port
          styled_result << span(result.proxy, class_proxy)               if result.proxy

          if result.proxy_port
            styled_result << ':'
            styled_result << span(result.proxy_port, class_proxy_port)
          end

          result.styled_content = styled_content.join
        end

        private

        def span(content, css_class)
          "<span class=\"#{css_class}\">#{content}</span>"
        end

      end

      def parse(string)
        regex.match(string)
        result = PacResult.new(string)
      end

      private

      def regex
        %q{"(?<type>[A-Z]+)\s+(?:(?<host>[0-9]{1,3}(:?\.[0-9]{1,3}){3}):(?<port>[0-9]+))?;?"}
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
local_pac-0.10.2 lib/local_pac/proxy_pac/result_parser.rb
local_pac-0.10.1 lib/local_pac/proxy_pac/result_parser.rb
local_pac-0.10.0 lib/local_pac/proxy_pac/result_parser.rb
local_pac-0.9.0 lib/local_pac/proxy_pac/result_parser.rb
local_pac-0.7.0 lib/local_pac/proxy_pac/result_parser.rb
local_pac-0.6.3 lib/local_pac/proxy_pac/result_parser.rb
local_pac-0.6.2 lib/local_pac/proxy_pac/result_parser.rb
local_pac-0.6.1 lib/local_pac/proxy_pac/result_parser.rb
local_pac-0.5.0 lib/local_pac/proxy_pac/result_parser.rb
local_pac-0.4.0 lib/local_pac/proxy_pac/result_parser.rb
local_pac-0.3.0 lib/local_pac/proxy_pac/result_parser.rb
local_pac-0.2.3 lib/local_pac/proxy_pac/result_parser.rb
local_pac-0.2.2 lib/local_pac/proxy_pac/result_parser.rb
local_pac-0.2.1 lib/local_pac/proxy_pac/result_parser.rb
local_pac-0.2.0 lib/local_pac/proxy_pac/result_parser.rb
local_pac-0.1.13 lib/local_pac/proxy_pac/result_parser.rb