Sha256: ddb5d55aeb86862fc6ed226308e556ac394cd9edc8fe0dc838a7ef300d04fb23

Contents?: true

Size: 1.35 KB

Versions: 19

Compression:

Stored size: 1.35 KB

Contents

module Watir
  module Generator
    class HTML
      class 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 || 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 # SpecExtractor
    end # HTML
  end # Generator
end # Watir

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
watir-7.1.0 lib/watir/generator/html/spec_extractor.rb
watir-7.0.0 lib/watir/generator/html/spec_extractor.rb
watir-7.0.0.beta5 lib/watir/generator/html/spec_extractor.rb
watir-7.0.0.beta4 lib/watir/generator/html/spec_extractor.rb
watir-7.0.0.beta3 lib/watir/generator/html/spec_extractor.rb
watir-7.0.0.beta2 lib/watir/generator/html/spec_extractor.rb
watir-7.0.0.beta1 lib/watir/generator/html/spec_extractor.rb
watir-6.19.1 lib/watir/generator/html/spec_extractor.rb
watir-6.19.0 lib/watir/generator/html/spec_extractor.rb
watir-6.18.0 lib/watir/generator/html/spec_extractor.rb
watir-6.17.0 lib/watir/generator/html/spec_extractor.rb
watir-6.16.5 lib/watir/generator/html/spec_extractor.rb
watir-6.16.4 lib/watir/generator/html/spec_extractor.rb
watir-6.16.3 lib/watir/generator/html/spec_extractor.rb
watir-6.16.2 lib/watir/generator/html/spec_extractor.rb
watir-6.16.1 lib/watir/generator/html/spec_extractor.rb
watir-6.16.0 lib/watir/generator/html/spec_extractor.rb
watir-6.15.1 lib/watir/generator/html/spec_extractor.rb
watir-6.15.0 lib/watir/generator/html/spec_extractor.rb