From e6e0ba0521576ee81630bd25abe60b412a529408 Mon Sep 17 00:00:00 2001 From: Bevan Kay Date: Sat, 30 Oct 2021 14:34:18 +1100 Subject: [PATCH] cask cookbook: update livecheck blocks This change causes `livecheck` to return a nicer error if no match is found from the regex. --- docs/Cask-Cookbook.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/Cask-Cookbook.md b/docs/Cask-Cookbook.md index 4a71bd58da..5a7f374fbf 100644 --- a/docs/Cask-Cookbook.md +++ b/docs/Cask-Cookbook.md @@ -748,6 +748,8 @@ If the version depends on multiple header fields, a block can be specified, e.g. strategy :header_match do |headers| v = headers["content-disposition"][/MyApp-(\d+(?:\.\d+)*)\.zip/i, 1] id = headers["location"][%r{/(\d+)/download$}i, 1] + next if v.blank? || id.blank? + "#{v},#{id}" end ``` @@ -757,6 +759,8 @@ Similarly, the `:page_match` strategy can also be used for more complex versions ```ruby strategy :page_match do |page| match = page.match(%r{href=.*?/(\d+)/MyApp-(\d+(?:\.\d+)*)\.zip}i) + next if match.blank? + "#{match[2]},#{match[1]}" end ```