Merge pull request #6409 from EricFromCanada/macos-requirement-json

MacOSRequirement: add to_json method
This commit is contained in:
Mike McQuaid 2019-09-02 08:45:17 +01:00 committed by GitHub
commit a1bcd336d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -42,11 +42,11 @@ class MacOSRequirement < Requirement
versions newer than #{@version.pretty_name} due to an upstream incompatibility.
EOS
when :cask
"This cask does not on macOS versions newer than #{@version.pretty_name}."
"This cask does not run on macOS versions newer than #{@version.pretty_name}."
end
else
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."
end
@ -59,4 +59,11 @@ class MacOSRequirement < Requirement
"macOS #{@comparator} #{@version}"
end
def to_json(*args)
comp = @comparator.to_s
return { comp => @version.map(&:to_s) }.to_json(*args) if @version.is_a?(Array)
{ comp => [@version.to_s] }.to_json(*args)
end
end