Sha256: b9c5d25cd1d9be1067c6ed30ff1e0bd213781e0912343ce42c0485eab775b0a1

Contents?: true

Size: 1.51 KB

Versions: 19

Compression:

Stored size: 1.51 KB

Contents

module Watir
  module Generator
    class SVG
      class SpecExtractor < Base::SpecExtractor
        private

        def extract_interface_map
          list = @doc.search("//div[@id='chapter-eltindex']//ul/li")
          list.any? || raise('could not find elements list')

          @interface_map = parse_list(list)
        end

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

        def parse_list(list)
          {}.tap do |result|
            list.each do |node|
              tag_name = node.css('a span').inner_text.strip
              id = node.css('a').attr('href').to_s

              next if external_interface?(id)

              interface_css = 'div.element-summary a.idlinterface'
              interface_definitions = @doc.css("#{id} #{interface_css}, #{id} ~ #{interface_css}")

              # TSpan is defined along with Text so the first IDL definition is SVGTextElement
              idx = tag_name == 'tspan' ? 1 : 0

              result[tag_name] = interface_definitions[idx].inner_text.strip
            end
          end
        end

        def issued_interfaces
          []
        end

        # Some interfaces are actually defined in different specs
        # (for example, clipPath), so we ignore them for now.
        def external_interface?(id)
          id !~ /^#.+/
        end
      end # SpecExtractor
    end # SVG
  end # Generator
end # Watir

Version data entries

19 entries across 19 versions & 1 rubygems

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