Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion Library/Homebrew/formula.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,12 @@ def link_overwrite?(path)
# @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"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be nice to have a delegate ... :"self.class" helper method because it's used in a tonne of places (as a follow-up PR).

Copy link
Copy Markdown
Member Author

@Rylan12 Rylan12 Dec 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed but I'll opt for the follow-up PR.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, thanks!


# The reason this {Formula} is deprecated.
# Returns `nil` if no reason is specified or the formula is not deprecated.
# @!method deprecation_reason
Expand All @@ -1177,6 +1183,12 @@ def link_overwrite?(path)
# @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
Expand Down Expand Up @@ -1777,7 +1789,11 @@ def to_hash
"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
Expand Down Expand Up @@ -2771,6 +2787,8 @@ def deprecate!(date: nil, because: nil)
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?
Expand All @@ -2784,6 +2802,11 @@ def deprecated?
@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]
Expand All @@ -2798,7 +2821,9 @@ def disable!(date: nil, because: nil)
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
Expand All @@ -2815,6 +2840,11 @@ def disabled?
@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]
Expand Down