Make os available in cask livecheck blocks

Casks now support an `os` DSL method, similar to `arch`. This makes
it available in `livecheck` blocks, like we do with `arch`.
This commit is contained in:
Sam Ford 2025-04-03 19:28:02 -04:00
parent fc86107ebe
commit 97cce36779
No known key found for this signature in database
GPG Key ID: 7AF5CBEE1DD6F76D
3 changed files with 30 additions and 2 deletions

View File

@ -80,6 +80,7 @@ module Cask
:homepage,
:language,
:name,
:os,
:sha256,
:staged_path,
:url,

View File

@ -194,9 +194,10 @@ class Livecheck
end
delegate url_options: :@options
delegate version: :@package_or_resource
delegate arch: :@package_or_resource
private :version, :arch
delegate os: :@package_or_resource
delegate version: :@package_or_resource
private :arch, :os, :version
# Returns a `Hash` of all instance variable values.
# @return [Hash]
sig { returns(T::Hash[String, T.untyped]) }

View File

@ -182,6 +182,32 @@ RSpec.describe Livecheck do
end
end
describe "#os" do
let(:c_os) do
Cask::Cask.new("c-os") do
os macos: "macos", linux: "linux"
version "0.0.1"
url "https://brew.sh/test-0.0.1.dmg"
name "Test"
desc "Test cask"
homepage "https://brew.sh"
livecheck do
url "https://brew.sh/#{os}"
end
end
end
[:needs_macos, :needs_linux].each do |needs_os|
os_value = needs_os.to_s.delete_prefix("needs_")
it "delegates `os` in `livecheck` block to `package_or_resource`", needs_os do
expect(c_os.livecheck.url).to eq("https://brew.sh/#{os_value}")
end
end
end
describe "#to_hash" do
it "returns a Hash of all instance variables" do
expect(livecheck_f.to_hash).to eq(