Sha256: d787687b616ed3bb2cd03637a58f0fcb362984b007cab556c2cf3d3c0a852149

Contents?: true

Size: 961 Bytes

Versions: 106

Compression:

Stored size: 961 Bytes

Contents

# frozen_string_literal: true

require 'nokogiri'
require 'aranha/parsers/base'
require 'aranha/parsers/html/node/default'

module Aranha
  module Parsers
    module Html
      class Base < ::Aranha::Parsers::Base
        class << self
          def fields
            @fields ||= []
            @fields.dup
          end

          def field(name, type, xpath)
            @fields ||= []
            @fields << Field.new(name, type, xpath)
          end

          Field = Struct.new(:name, :type, :xpath)
        end

        def nokogiri
          @nokogiri ||= Nokogiri::HTML(content, &:noblanks)
        end

        protected

        def node_parser_class
          ::Aranha::Parsers::Html::Node::Default
        end

        private

        def node_parser
          @node_parser ||= node_parser_class.new(fields)
        end

        def fields
          self.class.fields.map { |f| [f.name, f.type, f.xpath] }
        end
      end
    end
  end
end

Version data entries

106 entries across 106 versions & 4 rubygems

Version Path
eac_tools-0.65.0 sub/aranha-parsers/lib/aranha/parsers/html/base.rb
eac_tools-0.64.0 sub/aranha-parsers/lib/aranha/parsers/html/base.rb
eac_tools-0.63.0 sub/aranha-parsers/lib/aranha/parsers/html/base.rb
eac_tools-0.62.1 sub/aranha-parsers/lib/aranha/parsers/html/base.rb
eac_tools-0.62.0 sub/aranha-parsers/lib/aranha/parsers/html/base.rb
eac_tools-0.61.1 sub/aranha-parsers/lib/aranha/parsers/html/base.rb
eac_tools-0.61.0 sub/aranha-parsers/lib/aranha/parsers/html/base.rb
eac_tools-0.60.3 sub/aranha-parsers/lib/aranha/parsers/html/base.rb
eac_tools-0.60.2 sub/aranha-parsers/lib/aranha/parsers/html/base.rb
eac_tools-0.60.1 sub/aranha-parsers/lib/aranha/parsers/html/base.rb
aranha-parsers-0.17.1 lib/aranha/parsers/html/base.rb
eac_tools-0.60.0 sub/aranha-parsers/lib/aranha/parsers/html/base.rb
eac_tools-0.59.0 sub/aranha-parsers/lib/aranha/parsers/html/base.rb
eac_tools-0.58.0 sub/aranha-parsers/lib/aranha/parsers/html/base.rb
eac_tools-0.57.0 sub/aranha-parsers/lib/aranha/parsers/html/base.rb
eac_tools-0.56.1 sub/aranha-parsers/lib/aranha/parsers/html/base.rb
eac_tools-0.56.0 sub/aranha-parsers/lib/aranha/parsers/html/base.rb
eac_tools-0.55.7 sub/aranha-parsers/lib/aranha/parsers/html/base.rb
eac_tools-0.55.6 sub/aranha-parsers/lib/aranha/parsers/html/base.rb
eac_tools-0.55.5 sub/aranha-parsers/lib/aranha/parsers/html/base.rb