diff --git a/docs/Cask-Cookbook.md b/docs/Cask-Cookbook.md index 08284c829a..c096a442fc 100644 --- a/docs/Cask-Cookbook.md +++ b/docs/Cask-Cookbook.md @@ -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 app’s own versioning, doesn’t 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` doesn’t 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