diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index eecfb5823d..83411ab5b9 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 @@ -1777,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 @@ -2771,6 +2787,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 +2802,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 +2821,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 +2840,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]