Sha256: 0777d896af380f3e8eaeec11694cf7b2ec6b29bd1816c17b2db30782097e8d77

Contents?: true

Size: 1.26 KB

Versions: 29

Compression:

Stored size: 1.26 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='elements-3']/following-sibling::table[1]").first
        table or raise "could not find elements-3 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

29 entries across 29 versions & 2 rubygems

Version Path
watir-6.6.2 lib/watir/generator/html/spec_extractor.rb
watir-6.6.1 lib/watir/generator/html/spec_extractor.rb
watir-6.6.0 lib/watir/generator/html/spec_extractor.rb
watir-6.5.0 lib/watir/generator/html/spec_extractor.rb
watir-6.4.3 lib/watir/generator/html/spec_extractor.rb
watir-6.4.2 lib/watir/generator/html/spec_extractor.rb
watir-6.4.1 lib/watir/generator/html/spec_extractor.rb
watir-6.4.0 lib/watir/generator/html/spec_extractor.rb
watir-6.4.0.rc2 lib/watir/generator/html/spec_extractor.rb
watir-6.4.0.rc1 lib/watir/generator/html/spec_extractor.rb
watir-6.3.0 lib/watir/generator/html/spec_extractor.rb
watir-6.2.1 lib/watir/generator/html/spec_extractor.rb
watir-6.2.0 lib/watir/generator/html/spec_extractor.rb
watir-6.1.0 lib/watir/generator/html/spec_extractor.rb
watir-6.0.3 lib/watir/generator/html/spec_extractor.rb
watir-6.0.2 lib/watir/generator/html/spec_extractor.rb
watir-6.0.1 lib/watir/generator/html/spec_extractor.rb
watir-webdriver-0.9.9 lib/watir-webdriver/generator/html/spec_extractor.rb
watir-6.0.0 lib/watir/generator/html/spec_extractor.rb
watir-6.0.0.beta5 lib/watir/generator/html/spec_extractor.rb