Sha256: 9967ec2772dc037d0530e380dac186e534967c9d7f90da67267b150fae7a25b0

Contents?: true

Size: 1.27 KB

Versions: 20

Compression:

Stored size: 1.27 KB

Contents

module Watir
  module Generator
    class HTML::SpecExtractor < Base::SpecExtractor

      private

      def extract_interface_map
        # http://www.whatwg.org/specs/web-apps/current-work/#elements-1
        table = @doc.search("//h3[@id='index-elements']/following-sibling::table[1]").first
        table or raise "could not find index-elements table"

        @interface_map = {}

        parse_table(table).each do |row|
          row['Element'].split(", ").each { |tag| @interface_map[tag] = row['Interface'] }
        end
      end

      def build_result
        {}.tap do |result|
          @interface_map.each do |tag, interface|
            result[tag] = fetch_interface(interface)
          end

          # missing from the elements-1 table
          result['frameset'] = fetch_interface('HTMLFrameSetElement')
        end
      end

      def parse_table(table)
        headers = table.css("thead th").map { |e| e.inner_text.strip }

        table.css("tbody tr").map do |row|
          result = {}

          row.css("th, td").each_with_index do |node, idx|
            result[headers[idx]] = node.inner_text.strip
          end

          result
        end
      end

      def issued_interfaces
        []
      end

    end # HTML:;SpecExtractor
  end # Generator
end # Watir

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
watir-6.13.0 lib/watir/generator/html/spec_extractor.rb
watir-6.12.0 lib/watir/generator/html/spec_extractor.rb
watir-6.11.0 lib/watir/generator/html/spec_extractor.rb
watir-6.11.0.beta2 lib/watir/generator/html/spec_extractor.rb
watir-6.11.0.beta1 lib/watir/generator/html/spec_extractor.rb
watir-6.10.3 lib/watir/generator/html/spec_extractor.rb
watir-6.10.2 lib/watir/generator/html/spec_extractor.rb
watir-6.10.0 lib/watir/generator/html/spec_extractor.rb
watir-6.9.1 lib/watir/generator/html/spec_extractor.rb
watir-6.9.0 lib/watir/generator/html/spec_extractor.rb
watir-6.8.4 lib/watir/generator/html/spec_extractor.rb
watir-6.8.3 lib/watir/generator/html/spec_extractor.rb
watir-6.8.2 lib/watir/generator/html/spec_extractor.rb
watir-6.8.1 lib/watir/generator/html/spec_extractor.rb
watir-6.8.0 lib/watir/generator/html/spec_extractor.rb
watir-6.7.3 lib/watir/generator/html/spec_extractor.rb
watir-6.7.2 lib/watir/generator/html/spec_extractor.rb
watir-6.7.1 lib/watir/generator/html/spec_extractor.rb
watir-6.7.0 lib/watir/generator/html/spec_extractor.rb
watir-6.6.3 lib/watir/generator/html/spec_extractor.rb