From 2eb34b0b27160ed26f46594ff21bd2a629176398 Mon Sep 17 00:00:00 2001 From: Rylan Polster Date: Wed, 23 Dec 2020 02:58:14 -0500 Subject: [PATCH 1/2] formula: add deprecation_date and disable_date methods --- Library/Homebrew/formula.rb | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index eecfb5823d..92a8ad6293 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -1165,6 +1165,12 @@ class Formula # @return [Boolean] delegate deprecated?: :"self.class" + # The date that this {Formula} was or becomes deprecated. + # Returns `nil` if no date is specified. + # @!method deprecation_date + # @return Date + delegate deprecation_date: :"self.class" + # The reason this {Formula} is deprecated. # Returns `nil` if no reason is specified or the formula is not deprecated. # @!method deprecation_reason @@ -1177,6 +1183,12 @@ class Formula # @return [Boolean] delegate disabled?: :"self.class" + # The date that this {Formula} was or becomes disabled. + # Returns `nil` if no date is specified. + # @!method disable_date + # @return Date + delegate disable_date: :"self.class" + # The reason this {Formula} is disabled. # Returns `nil` if no reason is specified or the formula is not disabled. # @!method disable_reason @@ -2771,6 +2783,8 @@ class Formula odeprecated "`deprecate!` without a reason", "`deprecate! because: \"reason\"`" if because.blank? odeprecated "`deprecate!` without a date", "`deprecate! date: \"#{Date.today}\"`" if date.blank? + @deprecation_date = Date.parse(date) if date.present? + return if date.present? && Date.parse(date) > Date.today @deprecation_reason = because if because.present? @@ -2784,6 +2798,11 @@ class Formula @deprecated == true end + # The date that this {Formula} was or becomes deprecated. + # Returns `nil` if no date is specified. + # @return Date + attr_reader :deprecation_date + # The reason for deprecation of a {Formula}. # @return [nil] if no reason was provided or the formula is not deprecated. # @return [String, Symbol] @@ -2798,7 +2817,9 @@ class Formula odeprecated "`disable!` without a reason", "`disable! because: \"reason\"`" if because.blank? odeprecated "`disable!` without a date", "`disable! date: \"#{Date.today}\"`" if date.blank? - if date.present? && Date.parse(date) > Date.today + @disable_date = Date.parse(date) if date.present? + + if @disable_date && @disable_date > Date.today @deprecation_reason = because if because.present? @deprecated = true return @@ -2815,6 +2836,11 @@ class Formula @disabled == true end + # The date that this {Formula} was or becomes disabled. + # Returns `nil` if no date is specified. + # @return Date + attr_reader :disable_date + # The reason this {Formula} is disabled. # Returns `nil` if no reason was provided or the formula is not disabled. # @return [String, Symbol] From 5f10a8ea76429d788fb4d1d997b42c242e480622 Mon Sep 17 00:00:00 2001 From: Rylan Polster Date: Wed, 23 Dec 2020 09:56:46 -0500 Subject: [PATCH 2/2] formula: add disable/deprecation dates and reasons to json output --- Library/Homebrew/formula.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 92a8ad6293..83411ab5b9 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -1789,7 +1789,11 @@ class Formula "pinned" => pinned?, "outdated" => outdated?, "deprecated" => deprecated?, + "deprecation_date" => deprecation_date, + "deprecation_reason" => deprecation_reason, "disabled" => disabled?, + "disable_date" => disable_date, + "disable_reason" => disable_reason, } if stable