Class: Watir::Generator::Base::SpecExtractor

Inherits:
Object
  • Object
show all
Defined in:
lib/watir/generator/base/spec_extractor.rb

Direct Known Subclasses

HTML::SpecExtractor, SVG::SpecExtractor

Defined Under Namespace

Classes: InterfaceNotFound

Constant Summary collapse

IDL_SELECTOR =
"//pre[contains(@class, 'idl')]".freeze

Instance Method Summary collapse

Constructor Details

#initialize(uri) ⇒ SpecExtractor

Returns a new instance of SpecExtractor.


9
10
11
# File 'lib/watir/generator/base/spec_extractor.rb', line 9

def initialize(uri)
  @uri = uri
end

Instance Method Details

#errorsObject


24
25
26
# File 'lib/watir/generator/base/spec_extractor.rb', line 24

def errors
  @errors ||= []
end

#fetch_interface(interface) ⇒ Object


45
46
47
# File 'lib/watir/generator/base/spec_extractor.rb', line 45

def fetch_interface(interface)
  @interfaces_by_name[interface] || raise(InterfaceNotFound, "#{interface} not found in IDL")
end

40
41
42
43
# File 'lib/watir/generator/base/spec_extractor.rb', line 40

def print_hierarchy
  process if @interfaces.nil?
  idl_sorter.print
end

#processObject


13
14
15
16
17
18
19
20
21
22
# File 'lib/watir/generator/base/spec_extractor.rb', line 13

def process
  download_and_parse
  extract_idl_parts
  extract_interface_map
  drop_issued_interfaces
  build_result
rescue StandardError
  p errors
  raise
end

#sorted_interfacesObject

returns a topoligically sorted array of WebIDL::Ast::Interface objects


32
33
34
35
36
37
38
# File 'lib/watir/generator/base/spec_extractor.rb', line 32

def sorted_interfaces
  process if @interfaces.nil?

  idl_sorter.sort.map { |name|
    @interfaces.find { |i| i.name == name } || puts("ignoring interface: #{name}")
  }.compact
end