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:
parent
fc86107ebe
commit
97cce36779
@ -80,6 +80,7 @@ module Cask
|
|||||||
:homepage,
|
:homepage,
|
||||||
:language,
|
:language,
|
||||||
:name,
|
:name,
|
||||||
|
:os,
|
||||||
:sha256,
|
:sha256,
|
||||||
:staged_path,
|
:staged_path,
|
||||||
:url,
|
:url,
|
||||||
|
|||||||
@ -194,9 +194,10 @@ class Livecheck
|
|||||||
end
|
end
|
||||||
|
|
||||||
delegate url_options: :@options
|
delegate url_options: :@options
|
||||||
delegate version: :@package_or_resource
|
|
||||||
delegate arch: :@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.
|
# Returns a `Hash` of all instance variable values.
|
||||||
# @return [Hash]
|
# @return [Hash]
|
||||||
sig { returns(T::Hash[String, T.untyped]) }
|
sig { returns(T::Hash[String, T.untyped]) }
|
||||||
|
|||||||
@ -182,6 +182,32 @@ RSpec.describe Livecheck do
|
|||||||
end
|
end
|
||||||
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
|
describe "#to_hash" do
|
||||||
it "returns a Hash of all instance variables" do
|
it "returns a Hash of all instance variables" do
|
||||||
expect(livecheck_f.to_hash).to eq(
|
expect(livecheck_f.to_hash).to eq(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user