From 6a3a9d5c9ba53a71a116754f17d55cd39177dbce Mon Sep 17 00:00:00 2001 From: Sam Ford <1584702+samford@users.noreply.github.com> Date: Sat, 7 Dec 2024 22:15:48 -0500 Subject: [PATCH] opencat: update livecheck The existing `livecheck` block for `opencat` works as expected but the `strategy` block uses `split(".").length` to determine the number of version parts. I recently used `count(".")` in a similar situation, which accomplishes the same goal but is slightly faster and without the memory allocation of the `#split`/`#length` approach. This updates the `strategy` block to use `#count` and reworks the order of the ternary operator values to prioritize the normal case (rather than the problematic one). --- Casks/o/opencat.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Casks/o/opencat.rb b/Casks/o/opencat.rb index f0fcd3d2c0dcb..c6ee523f3688d 100644 --- a/Casks/o/opencat.rb +++ b/Casks/o/opencat.rb @@ -10,7 +10,7 @@ livecheck do url "https://opencat.app/releases/versions.xml" strategy :sparkle do |item| - short_version = (item.short_version.split(".").length < 3) ? "#{item.short_version}.0" : item.short_version + short_version = (item.short_version.count(".") >= 2) ? item.short_version : "#{item.short_version}.0" "#{short_version},#{item.version}" end end