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 2, 2025

This is a WIP based on #21092.

This is just a temporary PR, because I haven't had a chance yet to resolve conflicts on the other PR.

Essentially, this adds a new, simple way to define the combined, reduced JSON schema based on the regular formula JSON using things like this:

class FormulaHash < T::Struct
  include Homebrew::API::GeneratorMixin

  # By default, this populates from the "name" key
  elem :name, String

  # Use `from` to specify which key to populate from. In this case, `hash["versions"]["stable"]`
  elem :stable_version, String, from: ["versions", "stable"]

  # Use nested structs
  elem :head_url, hash_as: HeadUrlHash

  # For more complex transformations, use a block on the original hash
  elem :complex, Integer do |hash|
    hash["some_key"].count
  end
end

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