Sha256: ba382ac104a68a73f904a41794064f474592273aa9cd36846d2613cf30b70ad4
Contents?: true
Size: 802 Bytes
Versions: 3
Compression:
Stored size: 802 Bytes
Contents
# frozen_string_literal: true # Define a method on each doc for recording unparsable links. # Unparsable links are recorded as broken links by Finder. class Wgit::Document def unparsable_links @unparsable_links ||= [] end end # Returns a Wgit::Url or nil (if link is unparsable). # A proc is preferrable to a function to avoid polluting the global namespace. parse_link = lambda do |doc, link| Wgit::Url.new(link) rescue StandardError doc.unparsable_links << link nil end # Define a custom extractor for all page links we're interested in checking. Wgit::Document.define_extractor( :all_links, lambda { BrokenLinkFinder::link_xpath }, singleton: false, text_content_only: true ) do |links, doc| links .uniq .map { |link| parse_link.call(doc, link) } .compact end
Version data entries
3 entries across 3 versions & 1 rubygems