Merge pull request #11610 from samford/replace-nokogiri-with-rexml-part-two
Replace Nokogiri with REXML
This commit is contained in:
commit
b3d95b89e4
@ -30,15 +30,15 @@ module Homebrew
|
||||
|
||||
sig { params(package_info_path: Pathname).returns(T.nilable(T.attached_class)) }
|
||||
def self.from_package_info(package_info_path)
|
||||
Homebrew.install_bundler_gems!
|
||||
require "nokogiri"
|
||||
require "rexml/document"
|
||||
|
||||
xml = Nokogiri::XML(package_info_path.read)
|
||||
xml = REXML::Document.new(package_info_path.read)
|
||||
|
||||
bundle_id = xml.xpath("//pkg-info//bundle-version//bundle").first&.attr("id")
|
||||
return unless bundle_id
|
||||
bundle_version_bundle = xml.get_elements("//pkg-info//bundle-version//bundle").first
|
||||
bundle_id = bundle_version_bundle["id"] if bundle_version_bundle
|
||||
return if bundle_id.blank?
|
||||
|
||||
bundle = xml.xpath("//pkg-info//bundle").find { |b| b["id"] == bundle_id }
|
||||
bundle = xml.get_elements("//pkg-info//bundle").find { |b| b["id"] == bundle_id }
|
||||
return unless bundle
|
||||
|
||||
short_version = bundle["CFBundleShortVersionString"]
|
||||
|
||||
@ -176,13 +176,13 @@ module Homebrew
|
||||
|
||||
distribution_path = extract_dir/"Distribution"
|
||||
if distribution_path.exist?
|
||||
Homebrew.install_bundler_gems!
|
||||
require "nokogiri"
|
||||
require "rexml/document"
|
||||
|
||||
xml = Nokogiri::XML(distribution_path.read)
|
||||
xml = REXML::Document.new(distribution_path.read)
|
||||
|
||||
product_version = xml.xpath("//installer-gui-script//product").first&.attr("version")
|
||||
return product_version if product_version
|
||||
product = xml.get_elements("//installer-gui-script//product").first
|
||||
product_version = product["version"] if product
|
||||
return product_version if product_version.present?
|
||||
end
|
||||
|
||||
opoo "#{pkg_path.basename} contains multiple packages: #{packages}" if packages.count != 1
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user