Tweak version :latest docs.

This commit is contained in:
Markus Reiter 2023-02-08 17:52:28 +01:00
parent 2bc0f01a26
commit fa9d8057ab
No known key found for this signature in database
GPG Key ID: 245293B51702655B

View File

@ -705,11 +705,12 @@ Every `livecheck` block must contain a `url`, which can be either a string or a
Additionally, a `livecheck` should specify which `strategy` should be used to extract the version:
| `strategy` | description |
|---------------- | ----------- |
| `:header_match` | extract version from HTTP headers (e.g. `Location` or `Content-Disposition`)
| `:page_match` | extract version from page contents
| `:sparkle` | extract version from Sparkle appcast contents
| `strategy` | description |
|----------------- | ----------- |
| `:header_match` | extract version from HTTP headers (e.g. `Location` or `Content-Disposition`)
| `:page_match` | extract version from page contents
| `:sparkle` | extract version from Sparkle appcast contents
| `:extract_plist` | extract version from a `.plist` in the downloaded artifact
Here is a basic example, extracting a simple version from a page:
@ -1210,43 +1211,34 @@ This is possible by returning a two-element array as a block result. The first e
`version`, while related to the apps own versioning, doesnt have to follow it exactly. It is common to change it slightly so it can be [interpolated](https://en.wikipedia.org/wiki/String_interpolation#Ruby_/_Crystal) in other stanzas, usually in `url` to create a cask that only needs `version` and `sha256` changes when updated. This can be taken further, when needed, with [Ruby String methods](https://ruby-doc.org/core/String.html).
For example, instead of:
For example, instead of
```ruby
version "1.2.3"
url "https://example.com/file-version-123.dmg"
```
we can use:
we can use
```ruby
version "1.2.3"
url "https://example.com/file-version-#{version.delete('.')}.dmg"
```
We can also leverage the power of regular expressions. So instead of:
We can also leverage the power of regular expressions. So instead of
```ruby
version "1.2.3build4"
url "https://example.com/1.2.3/file-version-1.2.3build4.dmg"
```
we can use:
we can use
```ruby
version "1.2.3build4"
url "https://example.com/#{version.sub(%r{build\d+}, '')}/file-version-#{version}.dmg"
```
#### `version :latest`
The special value `:latest` is used in casks for which either:
1. `url` doesnt contain a version, or
2. having a correct value for `version` is too difficult or impractical, even with our automated systems.
Example: [chromium.rb](https://github.com/Homebrew/homebrew-cask/blob/f3e9de24ba57d7b1d949132504e581759725d0c5/Casks/chromium.rb#L4)
#### `version` Methods
The examples above can become hard to read, however. Since many of these changes are common, we provide a number of helpers to clearly interpret otherwise obtuse cases:
@ -1268,6 +1260,16 @@ Similar to `dots_to_hyphens`, we provide methods for all logical permutations of
Finally, there is `csv` which returns an array of comma-separated values. `csv`, `before_comma` and `after_comma` are extra-special to allow for otherwise complex cases, and should be used sparingly. There should be no more than two of `,` per `version`.
#### `version :latest`
The special value `:latest` is used when
* `url` does not contain any version information and there is no way to retrieve
the version using a `livecheck`, or
* having a correct value for `version` is too difficult or impractical, even with our automated systems. For example,
[chromium.rb](https://github.com/Homebrew/homebrew-cask/blob/f3e9de24ba57d7b1d949132504e581759725d0c5/Casks/chromium.rb#L4)
releases multiple versions a day.
### Stanza: `zap`
#### `zap` Purpose