livecheck: add content parameter to strategies
This renames `provided_content` parameters in livecheck strategy `find_versions` methods to `content` (for the sake of brevity) and adds the parameter to those without it. This will be used to implement a caching solution in the future, to avoid fetching duplicate URLs more than once in a given run. In the interim time, this allows us to expand tests for `find_versions` methods, which brings some of these strategies up to 100% code coverage. This change also allows us to remove `allow_incompatible: true` from related `find_versions` method signatures, as they align with what's outlined in `Strategic`. The only exception is `ExtractPlist#find_versions`, which will always differ due to having a `cask` parameter and the `url` parameter being optional (other strategies require a URL to function). Other notable changes: * `GithubReleases.find_versions` calls `GitHub::API.open_rest` and that parses the JSON response by default, so we have to use a `parse_json: false` argument to ensure that `content` is a string and handle the JSON parsing in the strategy. * Similarly, `GithubLatest` uses `GitHub.get_latest_release`, which doesn't support options like `parse_json: false`. `get_latest_release` generates the API URL from the GitHub username and repository before calling `GitHub::API.open_rest` and we already generate the same URL in the strategy, so this switches to an `open_rest` call instead. * `Launchpad.find_versions` uses `DEFAULT_REGEX` as the `regex` parameter's default value but this only applies if the `regex` argument is omitted. If `regex: nil` is used in the `find_versions` call, then `regex` is `nil` instead of the default regex, which isn't what we want. This sets the `regex` parameter's default value to `nil` and uses `regex || DEFAULT_REGEX` in the `PageMatch.find_versions` arguments instead, aligning with other strategies. * The `Xorg` strategy has its own built-in caching (which will be replaced by the general caching solution in the future), so it uses `content || cached_content` for now.
S
Sam Ford committed
5d54cbc57ab3f1e2b9a42ce16b64ec4b2cd27ae5
Parent: 9187b1a