WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@Rylan12
Copy link
Member

@Rylan12 Rylan12 commented Dec 4, 2025

This PR adds a new FormulaStruct to serve as an intermediary between the API and the formula loading in Formulary.

This doesn't do much right now, but it is a good starting point to show that this idea will work. Eventually, this will be able to load from the internal API, and will be a bit more robust. Also, nested hashes should, ideally, become nested structs so we can do things like formula_struct.urls.stable.checksum.

Also, there are likely several optimizations that can happen here to make the Formulary logic much cleaner, which I will continue to explore.

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Looks great so far! Goal here would be to simplify the formulary logic as much as possible while still making it responsible for actually calling the relevant DSL methods.

Feel free to punt on the map comments etc.: that could be instead done in another, later PR/pass.

Comment on lines +238 to 242
uses_from_macos_names = formula_struct.uses_from_macos.map do |dep|
next dep unless dep.is_a? Hash

dep.keys.first
end
Copy link
Member

Choose a reason for hiding this comment

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

I think ideally this (and others below) wouldn't need mapped (or filtered/nexted) but are instead already in the format needed for the DSL.

Comment on lines +400 to 405
if (disable_date = formula_struct.disable_date.presence)
reason = DeprecateDisable.to_reason_string_or_symbol formula_struct.disable_reason, type: :formula
replacement_formula = formula_struct.disable_replacement_formula
replacement_cask = formula_struct.disable_replacement_cask
disable! date: disable_date, because: reason, replacement_formula:, replacement_cask:
end
Copy link
Member

Choose a reason for hiding this comment

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

Similarly this looks perhaps like a formula_struct.disable or something should contain all relevant detail but also be nilable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants