Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Json: Add #parse_json method and tidy up tests #14858

Merged

Conversation

samford
Copy link
Member

@samford samford commented Mar 1, 2023

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

After working on the Xml strategy, I came back to the Json strategy to make a few changes to better align the two. For example, the Xml strategy provides a #parse_xml method that only includes the parsing logic, so other strategies can selectively use this method if that's all they need (instead of Xml#find_versions). This PR modifies the Json strategy to provide a similar Json#parse_json method.

This also renames the simple_content* variables in json_spec to content_simple*, to align the variable name with the naming convention used in the Xml strategy (e.g., content_version_text, content_version_attr, content_simple, etc.). This doesn't make a functional difference but is a little more tidy/predictable.

I've also tweaked a few tests to use content_simple in place of content in tests where the content isn't actually used (aligning with similar Xml tests). It doesn't make a difference other than passing a smaller string as the argument.

This setup mimics the `#parse_xml` method that was implemented in the
`Xml` strategy. Isolating the parsing code means that other strategies
can take only what they need from `Json` (i.e., it's not required for
them to use `Json#find_versions`).
This renames `simple_content` to `content_simple`, which makes the
`content_*` variable name convention more consistent (as is in the
`Xml` strategy tests).
@BrewTestBot
Copy link
Member

Review period will end on 2023-03-02 at 23:02:52 UTC.

@BrewTestBot BrewTestBot added the waiting for feedback Merging is blocked until sufficient time has passed for review label Mar 1, 2023
@BrewTestBot
Copy link
Member

Review period ended.

@BrewTestBot BrewTestBot removed the waiting for feedback Merging is blocked until sufficient time has passed for review label Mar 3, 2023
@samford samford merged commit 4a41f01 into Homebrew:master Mar 3, 2023
@samford samford deleted the livecheck/json-rework-after-xml-strategy branch March 3, 2023 04:27
@MikeMcQuaid
Copy link
Member

Thanks @samford!

@github-actions github-actions bot added the outdated PR was locked due to age label Apr 3, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants