Xml: Move require outside of #parse_xml

Since we use `REXML::Document` in the type signature for `#parse_xml`,
we can encounter an `uninitialized constant
Homebrew::Livecheck::Strategy::Xml::REXML` error in strategies like
`Sparkle` that use `Xml#parse_xml` internally when the Sorbet runtime
is used. Moving the related require outside of the `#parse_xml` method
and into the `Xml` strategy proper resolves this issue.
This commit is contained in:
Sam Ford 2023-04-29 01:07:27 -04:00
parent 6597ee6fd3
commit a2e966c186
No known key found for this signature in database
GPG Key ID: 7AF5CBEE1DD6F76D

View File

@ -1,6 +1,8 @@
# typed: true
# frozen_string_literal: true
require "rexml/document"
module Homebrew
module Livecheck
module Strategy
@ -53,8 +55,6 @@ module Homebrew
# @return [REXML::Document, nil]
sig { params(content: String).returns(T.nilable(REXML::Document)) }
def self.parse_xml(content)
require "rexml/document"
parsing_tries = 0
begin
REXML::Document.new(content)