Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cask/cask: pass args when initalising methods #18438

Merged
merged 5 commits into from
Oct 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/cask.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def refresh
end

::Cask::DSL::DSL_METHODS.each do |method_name|
define_method(method_name) { |&block| @dsl.send(method_name, &block) }
define_method(method_name) { |*args, &block| @dsl.send(method_name, *args, &block) }
end

sig { params(caskroom_path: Pathname).returns(T::Array[[String, String]]) }
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/livecheck/strategy/extract_plist.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
# Create a copy of the `cask` that uses the `livecheck` block URL
cask_copy = Cask::CaskLoader.load(cask.sourcefile_path)
cask_copy.allow_reassignment = true
cask_copy.url { url }
bevanjkay marked this conversation as resolved.
Show resolved Hide resolved
cask_copy.url url

Check warning on line 107 in Library/Homebrew/livecheck/strategy/extract_plist.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/livecheck/strategy/extract_plist.rb#L107

Added line #L107 was not covered by tests
UnversionedCaskChecker.new(cask_copy)
else
UnversionedCaskChecker.new(cask)
Expand Down
10 changes: 10 additions & 0 deletions Library/Homebrew/test/livecheck/strategy/extract_plist_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,15 @@
expect(installer_artifact).to be_a(Cask::Artifact::Installer)
expect(installer_artifact.path).to be_a(Pathname)
end

it "uses the provided livecheck url", :needs_macos do
cask = Cask::CaskLoader.load(cask_path("livecheck/livecheck-extract-plist"))
livecheck_url = "file://#{TEST_FIXTURE_DIR}/cask/caffeine-with-plist.zip"

expect(Homebrew::UnversionedCaskChecker).to receive(:new).with(cask).and_call_original
result = described_class.find_versions(cask:, url: livecheck_url)
expect(result)
.to eq({ matches: { "1.2.3"=> @version="1.2.3" }, regex: nil, url: livecheck_url })
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
cask "livecheck-extract-plist" do
version "1.2.3"
sha256 "78c670559a609f5d89a5d75eee49e2a2dab48aa3ea36906d14d5f7104e483bb9"

url "file://#{TEST_FIXTURE_DIR}/cask/caffeine-suite.zip"
name "With Extract Plist Livecheck"
desc "Cask with a an ExtractPlist livecheck strategy"
homepage "https://brew.sh/"

livecheck do
url "file://#{TEST_FIXTURE_DIR}/cask/caffeine-with-plist.zip"
strategy :extract_plist
end

app "Caffeine.app"
end
Binary file not shown.
Loading