353 Commits

Author SHA1 Message Date
Mike McQuaid
63d8de3600
brew style --fix 2023-04-07 19:10:22 +01:00
Douglas Eichelberger
47ffcd5cb7 Add types to block params 2023-04-04 22:42:27 -07:00
Douglas Eichelberger
f3a8241e69 Remove useless T.unsafe wrappers 2023-04-03 17:34:39 -07:00
Douglas Eichelberger
6397229f68 Enable types in extensions, etc. 2023-04-01 18:56:42 -07:00
Mike McQuaid
ec15acf7dc
Revert "Remove --request GET workaround for HEAD requests." 2023-03-31 09:07:02 +01:00
Markus Reiter
593c37de26
Merge pull request #15085 from reitermarkus/appcast
Deprecate `appcast`.
2023-03-31 00:13:08 +02:00
Markus Reiter
c876530eff
Remove --request GET workaround for HEAD requests. 2023-03-30 05:02:51 +02:00
Markus Reiter
bdd6523ce8
Deprecate appcast. 2023-03-30 03:29:06 +02:00
Douglas Eichelberger
544960b4fc Replace String#underscore with util 2023-03-07 10:13:38 -08:00
Sam Ford
f997557c3f
livecheck: Skip #preprocess_url for new strategies
I forgot to add the new `Json`, `Xml`, and `Yaml` strategies to the
list of strategies where `#preprocess_url` should be skipped and this
was causing issues for a user in their tap. This is unfortunately
another bug that wasn't surfaced when I tested all the related checks
in our first-party taps.
2023-03-05 10:05:06 -05:00
Mike McQuaid
066a8afe61
Merge pull request #14868 from samford/livecheck/add-yaml-strategy
livecheck: Add Yaml strategy
2023-03-04 00:06:11 +00:00
Sam Ford
74370fe604
ElectronBuilder: Update to use Yaml#find_versions
This updates `ElectronBuilder` to use `Yaml#find_versions`, as the
only code unique to that strategy is to restrict regex usage and
use default version-finding logic when a `strategy` block isn't
provided. This is similar to how we have various strategies that
use `PageMatch#find_versions` internally.

This allows us to remove `ElectronBuilder#versions_from_content`
entirely, along with the related tests. I've added support for
`provided_content` to `ElectronBuilder#find_versions` as a way of
adding tests and maintaining code coverage.
2023-03-02 16:23:32 -05:00
Sam Ford
33268e4fb0
livecheck: Add Yaml strategy
This adds a generic `Yaml` strategy to livecheck that requires a
`strategy` block to operate. The YAML-parsing code is taken from the
existing approach in the `ElectronBuilder` strategy.

We don't currently have any `strategy` blocks in first-party taps
that manually parse YAML. However, creating a generic `Yaml` strategy
allows us to simplify `ElectronBuilder` (and any future strategy
that works with YAML) while making it easy to create custom `Yaml`
`strategy` blocks in formulae/casks as needed.
2023-03-02 16:20:39 -05:00
Sam Ford
7f0a735828
Json: Fix a whitespace oversight in comment 2023-03-01 17:27:33 -05:00
Sam Ford
cebb951baf
Json: Add #parse_json method
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`).
2023-03-01 17:27:33 -05:00
Sam Ford
7d9e1a50e8
livecheck: Add Xml strategy
This adds a generic `Xml` strategy to livecheck that requires a
`strategy` block to operate. The XML-parsing code is taken from the
existing approach in the `Sparkle` strategy. As such, `Sparkle` has
been updated to use the `Xml#parse_xml` method instead.

Unlike the `Json` strategy, we don't currently have any `strategy`
blocks in first-party taps that manually parse XML. However, we had a
user request support for something like this and I was already working
on an `Xml` strategy (as a way of extracting the XML-parsing code
from `Sparkle` into something general-purpose), so here we are.

Future strategies that parse simple XML data can potentially use the
`Xml#find_versions` method (similar to how we have strategies that
leverage `PageMatch#find_versions`) instead of having to implement
something bespoke like `Sparkle`.
2023-02-28 14:58:11 -05:00
Mike McQuaid
4986a1aa26
Merge pull request #14830 from samford/livecheck/rework-json-match
Strategy#from_url: Amend conditions for Json
2023-02-28 11:41:41 +00:00
Douglas Eichelberger
f9f73f3ef6 Tidy up 2023-02-27 21:42:47 -08:00
Douglas Eichelberger
1ab278f74c Fix style/type violations 2023-02-27 20:34:07 -08:00
Douglas Eichelberger
0eccc0e987 git grep -l Utils::Inflection | xargs gsed -i 's|Utils::Inflection|Utils|g' 2023-02-27 20:18:27 -08:00
Douglas Eichelberger
cfdb0c2e4b Fix type error 2023-02-27 20:18:10 -08:00
Douglas Eichelberger
2400c6daed brew style --fix 2023-02-27 20:17:33 -08:00
Douglas Eichelberger
d62211d3af Replace demodulize inflection with util 2023-02-27 20:17:33 -08:00
Sam Ford
ec7fd75934
Strategy#from_url: Replace #from_symbol call
Passing the strategy symbol into the `#from_url` `select` block
means that we can also get rid of a `#from_symbol` call in a
different conditional branch, as we can directly compare the
`livecheck_strategy` symbol to `strategy_symbol`.
2023-02-27 18:58:15 -05:00
Sam Ford
03823b5698
Strategy#from_url: Amend conditions for Json
When the `Json` strategy was introduced, I forgot to also ensure
that it's only treated as usable (in `Strategy#from_url`) if a
`livecheck` block uses `strategy :json`. As a result, `Json` is
incorrectly treated as a usable strategy for all formulae/casks that
contain a `strategy` block.

Since all of these `livecheck` blocks specify a strategy, this bug
doesn't meaningfully impact livecheck's behavior (i.e., these checks
continue to use their explicitly-specified strategy). The only
practical difference is that `Json` incorrectly appears in the list
of usable strategies in livecheck's verbose JSON output.

This commit modifies `Strategy#from_url` to address this issue. The
easiest way to enforce this rule involved passing in the
`@strategies` key (a symbol) into the `select` block, so we can
compare it to `livecheck_strategy` (the strategy symbol specified in
the `livecheck` block).
2023-02-27 18:58:13 -05:00
Mike McQuaid
9fd50a9ab0
Merge pull request #14785 from samford/livecheck/add-json-strategy
livecheck: Add `Json` strategy
2023-02-24 18:02:40 +00:00
Douglas Eichelberger
8a01478fb1 Remove stray rubocop:enable comments 2023-02-24 08:26:22 -08:00
Sam Ford
a0a366e22d
PageMatch: Tweak documentation comments 2023-02-23 13:41:56 -05:00
Sam Ford
7735036c56
livecheck: Add Json strategy
This adds a generic `Json` strategy to livecheck that requires a
`strategy` block to operate. This is primarily intended as a
replacement for existing `strategy` blocks in formulae/casks that
use `JSON#parse`, as it allows us to internalize/standardize that
boilerplate while improving error-handling.

Additionally, future strategies that parse JSON data can use the
`Json#find_versions` method instead of having to reinvent the wheel
(similar to how we currently have a number of strategies that
leverage `PageMatch#find_versions`).
2023-02-23 13:17:35 -05:00
Markus Reiter
62ac2dda8b
Don't preprocess URL for :extract_plist strategy. 2023-02-22 10:37:51 +01:00
Issy Long
298bb65dfb
rubocop: Entirely disable Metrics cops
- These are arbitrary length limits that had a load of disables in code.
- The limits were only increasing over time rather than decreasing.
- Fixing the problematic code to be shorter would take a long time for
  questionable gain since the problem has been around so long.
2023-02-21 00:34:17 +00:00
Michael Cho
476f83d38d
livecheck_version: only split on commas in cask version 2023-02-12 15:32:32 -08:00
Sam Ford
f03a400e28
Extract latest_version string to a constant 2022-12-19 18:15:51 -05:00
Nanda H Krishna
f2fbbfe70c
Enable use of latest formula version in resource livecheck URLs 2022-12-19 00:12:16 -05:00
Mike McQuaid
77c0d38c35
brew style --fix 2022-12-13 11:37:06 +00:00
Sam Ford
e56735a171
ElectronBuilder: Allow Date/Time deserialization
The `ElectronBuilder` strategy uses `YAML#safe_load` to parse YAML
content and this limits deserialization to appropriate classes. We
recently encountered a `Tried to load unspecified class: Time` error
when using the `ElectronBuilder` strategy on a `latest-mac.yml` file
containing `releaseDate: 2022-12-01T02:02:46.419Z`.

The electron-builder YAML files we usually encounter use single
quotes around the `releaseDate` value to ensure it's treated as a
string (e.g., `releaseDate: '2022-10-12T17:55:26.718Z'`) and this is
what we do in `electron_builder_spec.rb`. The aforementioned YAML
file doesn't use single quotes around the value, so it's treated as
a timestamp and apparently this makes Psych use `Time` (which
`#safe_load` doesn't allow by default).

Seeing as we can't control the YAML content and there's a chance we
may encounter other files like this in the future, this commit
modifies the related `#safe_load` call to allow `Time` (and `Date`
for good measure). This will resolve the aforementioned error and
allow the `ElectronBuilder` strategy to work as expected in this
scenario.
2022-12-05 21:45:18 -05:00
Tim Visher
fc31d5560c livecheck/strategy/sparkle.rb: Add macos to the candidate os values list
As can be seen by TextExpander's Sparkle Feed, `macos` is a possible
value.

```
$ date -u '+%FT%T%z' && xmlstarlet sel -t -v '//rss//channel//item//enclosure/@*[name()="url" or name()="sparkle:version" or name()="sparkle:shortVersionString" or name()="sparkle:os"]' <(curl --location --silent https://textexpander.com/appcast/TextExpander-macOS.xml)
2022-10-22T17:07:06+0000
https://cdn.textexpander.com/mac/731.2/TextExpander_7.3.1.dmg
731.2
7.3.1
macos
https://cdn.textexpander.com/mac/720.16/TextExpander_7.2.dmg
720.16
7.2
macos
https://cdn.textexpander.com/mac/710.6/TextExpander_7.1.dmg
710.6
7.1
macos
https://cdn.textexpander.com/mac/702.2/TextExpander_7.0.2.dmg
702.2
7.0.2
macos
https://cdn.textexpander.com/mac/701.2/TextExpander_7.0.1.dmg
701.2
7.0.1
macos
https://cdn.textexpander.com/mac/700.33/TextExpander_7.0.dmg
700.33
7.0
macos
https://cdn.textexpander.com/mac/685.6/TextExpander_6.8.5.zip
685.6
6.8.5
https://cdn.textexpander.com/mac/684.8/TextExpander_6.8.4.zip
684.8
6.8.4
https://cdn.textexpander.com/mac/683.2/TextExpander_6.8.3.zip
683.2
6.8.3
https://cdn.textexpander.com/mac/682.10/TextExpander_6.8.2.zip
682.10
6.8.2
https://cdn.textexpander.com/mac/681.3/TextExpander_6.8.1.zip
681.3
6.8.1
https://cdn.textexpander.com/mac/680.30/TextExpander_6.8.zip
680.30
6.8
https://cdn.textexpander.com/mac/TextExpander_6.5.6.zip
656.3
6.5.6
https://cdn.textexpander.com/mac/TextExpander_6.5.5.zip
655.0
6.5.5
https://cdn.textexpander.com/mac/TextExpander_6.5.4.zip
654.3
6.5.4
https://cdn.textexpander.com/mac/TextExpander_6.5.3.zip
653.3
6.5.3
https://cdn.textexpander.com/mac/TextExpander_6.5.2.zip
652.0
6.5.2
https://smilesoftware.com/downloads/test/TextExpander_6.5.1.zip
651.5
6.5.1
```

Co-authored-by: Sam Ford <1584702+samford@users.noreply.github.com>
2022-12-04 14:21:27 -05:00
Bo Anderson
eac32f0b20
Additional fixes for Ruby 3 compatibility 2022-10-18 01:54:59 +01:00
Issy Long
b7d997e80d
sorbet: Bump some files from typed: false to typed: true
- This was done with `brew typecheck --update --suggest-typed` which
  (as of the previous commit) uses Spoom, yet another gem. I thought I'd
  see how well it works. There are no Sorbet errors after these changes!
2022-10-11 01:09:03 +01:00
Nanda H Krishna
b5c8841980
Modified text in comments 2022-09-27 00:59:37 -07:00
Sam Ford
bd9c436d50
Remove unnecessary parameter from method
A boolean `resource` parameter was added to `#print_latest_version`
but its only purpose is to identify whether `info` corresponds to a
resource. This can be achieved using `info[:resource].present?`, so
this additional parameter isn't necessary and can be removed.
2022-09-27 00:36:33 -04:00
Sam Ford
fb653c00d8
Improve consistency of *_version methods
Minimizing the differences between the `#resource_version` and
`#latest_version` methods will help to ease the process of potentially
merging them into one method in the future.
2022-09-27 00:27:26 -04:00
Sam Ford
7ffeba6380
Convert some multiline code into a single line
Using a multiline format in these areas isn't necessary and we can
clean up these lines by converting them to a single line format.
2022-09-27 00:21:18 -04:00
Sam Ford
40b0070beb
Modify comments and other text
The `check_for_resources` code arguably speaks for itself, so it
doesn't feel like a necessary addition. Besides that, this cleans up
some other comments and text to better align with existing examples.
2022-09-27 00:18:20 -04:00
Mohammad Zain Abbas
e3cab15e93 Set Homebrew.failed = true to get correct status code 2022-09-26 19:37:46 +02:00
Mohammad Zain Abbas
e26da060f0 Merge branch 'mohammad' of https://github.com/mohammadzainabbas/brew into mohammad 2022-09-25 20:48:45 +02:00
Mohammad Zain Abbas
ae031041a2 Refactored code 2022-09-25 20:48:44 +02:00
Mohammad Zain Abbas
2f74eb5b5b
Update Library/Homebrew/livecheck/livecheck.rb
Co-authored-by: Sam Ford <1584702+samford@users.noreply.github.com>
2022-09-25 22:21:04 +05:00
Mohammad Zain Abbas
03c372ef52 Minor fixes 2022-09-25 02:06:23 +02:00
Mohammad Zain Abbas
6d993fa642 Fixed minor issues and applied suggestions 2022-09-25 00:53:44 +02:00