From 00b588068fb8c2ae26cfd739968207a3259d43bc Mon Sep 17 00:00:00 2001 From: Bo Anderson Date: Sat, 11 Dec 2021 23:30:06 +0000 Subject: [PATCH] formula: add keg_only_reason to formula hash --- Library/Homebrew/formula.rb | 1 + Library/Homebrew/formula_support.rb | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 1d4afac8b956f..32e62090d4515 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -1942,6 +1942,7 @@ def to_hash "version_scheme" => version_scheme, "bottle" => {}, "keg_only" => keg_only?, + "keg_only_reason" => keg_only_reason&.to_hash, "bottle_disabled" => bottle_disabled?, "options" => [], "build_dependencies" => dependencies.select(&:build?) diff --git a/Library/Homebrew/formula_support.rb b/Library/Homebrew/formula_support.rb index b9c0b49426863..127f45383be22 100644 --- a/Library/Homebrew/formula_support.rb +++ b/Library/Homebrew/formula_support.rb @@ -60,6 +60,19 @@ def to_s @reason end.strip end + + def to_hash + reason_string = if @reason.is_a?(Symbol) + @reason.inspect + else + @reason.to_s + end + + { + "reason" => reason_string, + "explanation" => @explanation, + } + end end # Used to annotate formulae that don't require compiling or cannot build a bottle.