macos_requirement: fix version_specified?, improve outputs

This commit is contained in:
Nanda H Krishna 2023-03-02 23:26:38 -05:00
parent bd309509da
commit 56703a49ed
No known key found for this signature in database
GPG Key ID: 067E5FCD58ADF3AA

View File

@ -51,12 +51,12 @@ class MacOSRequirement < Requirement
end end
def version_specified? def version_specified?
OS.mac? && @version @version.present?
end end
satisfy(build_env: false) do satisfy(build_env: false) do
T.bind(self, MacOSRequirement) T.bind(self, MacOSRequirement)
next Array(@version).any? { |v| MacOS.version.public_send(@comparator, v) } if version_specified? next Array(@version).any? { |v| MacOS.version.public_send(@comparator, v) } if OS.mac? && version_specified?
next true if OS.mac? next true if OS.mac?
next true if @version next true if @version
@ -68,7 +68,7 @@ class MacOSRequirement < Requirement
case @comparator case @comparator
when ">=" when ">="
"macOS #{@version.pretty_name} or newer is required for this software." "This software does not run on macOS versions older than #{@version.pretty_name}."
when "<=" when "<="
case type case type
when :formula when :formula
@ -82,10 +82,10 @@ class MacOSRequirement < Requirement
else else
if @version.respond_to?(:to_ary) if @version.respond_to?(:to_ary)
*versions, last = @version.map(&:pretty_name) *versions, last = @version.map(&:pretty_name)
return "macOS #{versions.join(", ")} or #{last} is required for this software." return "This software does not run on macOS versions other than #{versions.join(", ")} and #{last}."
end end
"macOS #{@version.pretty_name} is required for this software." "This software does not run on macOS versions other than #{@version.pretty_name}."
end end
end end
@ -107,9 +107,9 @@ class MacOSRequirement < Requirement
def display_s def display_s
if version_specified? if version_specified?
if @version.respond_to?(:to_ary) if @version.respond_to?(:to_ary)
"macOS #{@comparator} #{version.join(" / ")}" "macOS #{@comparator} #{version.join(" / ")} (or Linux)"
else else
"macOS #{@comparator} #{@version}" "macOS #{@comparator} #{@version} (or Linux)"
end end
else else
"macOS" "macOS"