36 Commits

Author SHA1 Message Date
Sam Ford
b4757af656
livecheck: Add support for POST requests
livecheck currently doesn't support `POST` requests but it wasn't
entirely clear how best to handle that. I initially approached it as
a `Post` strategy but unfortunately that would have required us to
handle response body parsing (e.g., JSON, XML, etc.) in some fashion.
We could borrow some of the logic from related strategies but we would
still be stuck having to update `Post` whenever we add a strategy for
a new format.

Instead, this implements `POST` support by borrowing ideas from the
`using: :post` and `data` `url` options found in formulae. This uses
a `post_form` option to handle form data and `post_json` to handle
JSON data, encoding the hash argument for each into the appropriate
format. The presence of either option means that curl will use a
`POST` request.

With this approach, we can make a `POST` request using any strategy
that calls `Strategy::page_headers` or `::page_content` (directly or
indirectly) and everything else works the same as usual. The only
change needed in related strategies was to pass the options through
to the `Strategy` methods.

For example, if we need to parse a JSON response from a `POST`
request, we add a `post_data` or `post_json` hash to the `livecheck`
block `url` and use `strategy :json` with a `strategy` block. This
leans on existing patterns that we're already familiar with and
shouldn't require any notable maintenance burden when adding new
strategies, so it seems like a better approach than a `Post` strategy.
2025-02-07 08:53:47 -05:00
Nanda H Krishna
75af672d1f
livecheck: update #formula comment
Co-authored-by: Sam Ford <1584702+samford@users.noreply.github.com>
2025-01-07 02:11:15 +05:30
Nanda H Krishna
e2df3fee81
livecheck: allow parent formula reference in resources 2025-01-07 02:08:21 +05:30
Sam Ford
79e20b3512
Standardize livecheck block language formatting 2024-12-02 10:13:04 -05:00
Patrick Linnane
f2fb863dbd
livecheck: remove outdated comment
Signed-off-by: Patrick Linnane <patrick@linnane.io>
2024-11-26 14:09:13 -08:00
Patrick Linnane
d04430d1a5
brew style --fix
Signed-off-by: Patrick Linnane <patrick@linnane.io>
2024-11-26 14:09:13 -08:00
Douglas Eichelberger
e535699038 Disable false positive 2024-11-15 11:46:32 -08:00
Mike McQuaid
c5dbd3ca24
Rearrange requires
This improves the load time of most brew commands. For an example of
one of the simplest commands this speeds up:

Without Bootsnap:
```
$ hyperfine 'git checkout master; brew help' 'git checkout optimise_requires; brew help'
Benchmark 1: git checkout master; brew help
  Time (mean ± σ):     525.0 ms ±  35.8 ms    [User: 229.9 ms, System: 113.1 ms]
  Range (min … max):   465.3 ms … 576.6 ms    10 runs

Benchmark 2: git checkout optimise_requires; brew help
  Time (mean ± σ):     383.3 ms ±  25.1 ms    [User: 133.0 ms, System: 72.1 ms]
  Range (min … max):   353.0 ms … 443.6 ms    10 runs

Summary
  git checkout optimise_requires; brew help ran
    1.37 ± 0.13 times faster than git checkout master; brew help
```

With Bootsnap:
```
$ hyperfine 'git checkout master; brew help' 'git checkout optimise_requires; brew help'
Benchmark 1: git checkout master; brew help
  Time (mean ± σ):     386.0 ms ±  30.9 ms    [User: 130.2 ms, System: 93.8 ms]
  Range (min … max):   359.5 ms … 469.3 ms    10 runs

Benchmark 2: git checkout optimise_requires; brew help
  Time (mean ± σ):     330.2 ms ±  32.4 ms    [User: 93.4 ms, System: 73.0 ms]
  Range (min … max):   302.9 ms … 413.9 ms    10 runs

Summary
  git checkout optimise_requires; brew help ran
    1.17 ± 0.15 times faster than git checkout master; brew help
```
2024-07-14 08:49:39 -04:00
Sam Ford
7ba189a018
livecheck: expand typed: strict usage
This updates livecheck files to use `typed: script` where feasible.

The remaining exception is `livecheck/strategy.rb`, as I wasn't
able to figure out how to resolve the typing issues around the
`@strategies` variable (I tried a couple of approaches but couldn't
find a working solution). This includes changes to resolve the other
type errors in `strategy.rb` but leaves the file as `typed: true`
for now.
2024-07-04 20:22:14 -04:00
Sam Ford
0f063921c5
livecheck: Update throttle rate parameter type
Co-authored-by: Markus Reiter <me@reitermark.us>
2024-03-21 10:11:50 -04:00
Sam Ford
7681621cd4
livecheck: Reorder throttle 2024-03-21 10:11:50 -04:00
Michael Cho
bfec6eecac
livecheck: support throttle DSL
Signed-off-by: Michael Cho <michael@michaelcho.dev>
2024-03-21 10:11:49 -04:00
Markus Reiter
dfc9d94c5b
Type livecheck.rb. 2023-05-06 03:27:42 +02: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
Rylan Polster
dd72f1ac95
Add arch cask DSL 2022-08-05 17:12:55 -04:00
Mohammad Zain Abbas
f4197fc96e
Minor documentation changes 2022-07-04 10:13:01 -04:00
Sam Ford
ddde0f7589
livecheck: allow inheriting from a formula/cask 2021-08-02 09:12:22 -04:00
Sam Ford
6c4041c026
Livecheck: Do not convert URL symbol to string 2021-01-13 09:35:54 -05:00
Sam Ford
308390ba5b
Address feedback and expand documentation
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
Co-authored-by: Sean Molenaar <1484494+SMillerDev@users.noreply.github.com>
2021-01-11 17:51:41 -05:00
Markus Reiter
7f633cce8c Remove :appcast and rename :cask_url to :url. 2020-12-25 01:02:51 +01:00
Markus Reiter
3a4c7223df
Allow accessing version in livecheck blocks. 2020-12-19 19:34:22 -05:00
Markus Reiter
b3c46ba2b9
Allow extracting URL in Sparkle strategy. 2020-12-19 19:34:17 -05:00
Markus Reiter
3bde9d34a9
Remove version from Livecheck. 2020-12-12 17:43:25 -05:00
Seeker
0e8cebbb5b
Store Livecheck#version as symbol or string 2020-12-12 17:43:22 -05:00
Seeker
4b87da4da9
Initial small fixes
- Skip blank lines in watchlist
- Initialize Livecheck#version as nil
- Simplify livecheck_version logic
- Make test a bit more understandable
2020-12-12 17:43:22 -05:00
Seeker
0a766350b5
Fix :cask_url and allow :appcast 2020-12-12 17:43:21 -05:00
Seeker
6794a78087
livecheck: add support for casks 2020-12-12 17:43:21 -05:00
EricFromCanada
3768b7a6e9 apidoc: update comment wording, punctuation, formatting 2020-11-06 00:21:02 -05:00
Markus Reiter
24ae318a3d Move type annotations into files. 2020-10-10 14:59:39 +02:00
Mike McQuaid
2e5272d04c Deprecate/disable code for Homebrew 2.5.0.
Do the usual "disable deprecations" and "uncomment pending deprecations"
dance and delete/deprecate/disable relevant/related code.
2020-09-03 10:34:22 +01:00
Sam Ford
05b3518b0c
Improve documentation comments for Livecheck DSL 2020-08-07 21:52:10 -04:00
Sam Ford
b99e8626e2
Raise TypeError in Livecheck DSL for invalid arg
We previously added `raise TypeError` logic to the `Livecheck` DSL's
`#strategy` method. This updates the existing methods to follow suit
and modifies the tests accordingly.
2020-08-07 17:25:08 -04:00
Sam Ford
72985277e8
Add strategy to livecheck DSL 2020-08-05 11:54:37 -04:00
nandahkrishna
9ffd0e66af
livecheck: reference Formula URLs 2020-05-31 13:52:55 +05:30
nandahkrishna
77e74e7e69
Adding livecheck Formula DSL 2020-05-11 09:41:13 +05:30