lib/watir/generator/base/spec_extractor.rb in watir-7.1.0 vs lib/watir/generator/base/spec_extractor.rb in watir-7.2.0
- old
+ new
@@ -1,10 +1,12 @@
+# frozen_string_literal: true
+
module Watir
module Generator
class Base
class SpecExtractor
- IDL_SELECTOR = "//pre[contains(@class, 'idl')]".freeze
+ IDL_SELECTOR = "//pre[contains(@class, 'idl')]"
class InterfaceNotFound < StandardError; end
def initialize(uri)
@uri = uri
@@ -30,13 +32,13 @@
#
def sorted_interfaces
process if @interfaces.nil?
- idl_sorter.sort.map { |name|
+ idl_sorter.sort.filter_map do |name|
@interfaces.find { |i| i.name == name } || puts("ignoring interface: #{name}")
- }.compact
+ end
end
def print_hierarchy
process if @interfaces.nil?
idl_sorter.print
@@ -51,10 +53,10 @@
def download_and_parse
File.open(@uri) { |io| @doc = Nokogiri.HTML(io) }
end
def extract_idl_parts
- parsed = @doc.search(IDL_SELECTOR).map { |e| parse_idl(e.inner_text) }.compact
+ parsed = @doc.search(IDL_SELECTOR).filter_map { |e| parse_idl(e.inner_text) }
implements = []
includes = []
@interfaces = []