lib/watir/generator/html/spec_extractor.rb in watir-6.13.0 vs lib/watir/generator/html/spec_extractor.rb in watir-6.14.0

- old
+ new

@@ -1,50 +1,50 @@ module Watir module Generator - class HTML::SpecExtractor < Base::SpecExtractor + module HTML + class SpecExtractor < Base::SpecExtractor + private - 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') - 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 = {} - @interface_map = {} - - parse_table(table).each do |row| - row['Element'].split(", ").each { |tag| @interface_map[tag] = row['Interface'] } + parse_table(table).each do |row| + row['Element'].split(', ').each { |tag| @interface_map[tag] = row['Interface'] } + end end - end - def build_result - {}.tap do |result| - @interface_map.each do |tag, interface| - result[tag] = fetch_interface(interface) - 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') + # missing from the elements-1 table + result['frameset'] = fetch_interface('HTMLFrameSetElement') + end end - end - def parse_table(table) - headers = table.css("thead th").map { |e| e.inner_text.strip } + def parse_table(table) + headers = table.css('thead th').map { |e| e.inner_text.strip } - table.css("tbody tr").map do |row| - result = {} + 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 + row.css('th, td').each_with_index do |node, idx| + result[headers[idx]] = node.inner_text.strip + end - result + result + end end - end - def issued_interfaces - [] - end - - end # HTML:;SpecExtractor + def issued_interfaces + [] + end + end # SpecExtractor + end # HTML end # Generator end # Watir