Class: Homebrew::Livecheck::Strategy::ExtractPlist Private
- Defined in:
- livecheck/strategy/extract_plist.rb
Overview
This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.
The ExtractPlist strategy downloads the file at a URL and extracts
versions from contained .plist
files using UnversionedCaskChecker.
In practice, this strategy operates by downloading very large files, so it's both slow and data-intensive. As such, the ExtractPlist strategy should only be used as an absolute last resort.
This strategy is not applied automatically and it's necessary to use
strategy :extract_plist
in a livecheck
block to apply it.
Defined Under Namespace
Classes: Item
Constant Summary collapse
- PRIORITY =
This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.
A priority of zero causes livecheck to skip the strategy. We do this for Homebrew::Livecheck::Strategy::ExtractPlist so we can selectively apply it when appropriate.
0
- URL_MATCH_REGEX =
This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.
The
Regexp
used to determine if the strategy applies to the URL. %r{^https?://}i
Class Method Summary collapse
-
.find_versions(cask:, url: nil, regex: nil, **_unused, &block) ⇒ Hash{Symbol => T.untyped}
private
Uses UnversionedCaskChecker on the provided cask to identify versions from
plist
files. -
.match?(url) ⇒ Boolean
private
Whether the strategy can be applied to the provided URL.
-
.versions_from_items(items, regex = nil, &block) ⇒ Array<String>
private
Identify versions from
Item
s produced using UnversionedCaskChecker version information.
Class Method Details
.find_versions(cask:, url: nil, regex: nil, **_unused, &block) ⇒ Hash{Symbol => T.untyped}
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
Uses UnversionedCaskChecker on the provided cask to identify
versions from plist
files.
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'livecheck/strategy/extract_plist.rb', line 92 def self.find_versions(cask:, url: nil, regex: nil, **_unused, &block) if regex.present? && block.blank? raise ArgumentError, "#{Utils.demodulize(T.must(name))} only supports a regex when using a `strategy` block" end unless T.unsafe(cask) raise ArgumentError, "The #{Utils.demodulize(T.must(name))} strategy only supports casks." end match_data = { matches: {}, regex:, url: } unversioned_cask_checker = if url.present? && url != cask.url.to_s # 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 UnversionedCaskChecker.new(cask_copy) else UnversionedCaskChecker.new(cask) end items = unversioned_cask_checker.all_versions.transform_values { |v| Item.new(bundle_version: v) } versions_from_items(items, regex, &block).each do |version_text| match_data[:matches][version_text] = Version.new(version_text) end match_data end |
.match?(url) ⇒ Boolean
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
Whether the strategy can be applied to the provided URL.
32 33 34 |
# File 'livecheck/strategy/extract_plist.rb', line 32 def self.match?(url) URL_MATCH_REGEX.match?(url) end |
.versions_from_items(items, regex = nil, &block) ⇒ Array<String>
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
Identify versions from Item
s produced using
UnversionedCaskChecker version information.
64 65 66 67 68 69 70 71 72 73 |
# File 'livecheck/strategy/extract_plist.rb', line 64 def self.versions_from_items(items, regex = nil, &block) if block block_return_value = regex.present? ? yield(items, regex) : yield(items) return Strategy.handle_block_return(block_return_value) end items.filter_map do |_key, item| item.bundle_version.nice_version end.uniq end |