Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MacOSRequirement: add to_json method #6409

Merged
merged 1 commit into from Sep 2, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions Library/Homebrew/requirements/macos_requirement.rb
Expand Up @@ -42,11 +42,11 @@ def message(type: :formula)
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

Expand All @@ -59,4 +59,11 @@ def display_s

"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