Merge pull request #18839 from Homebrew/livecheck/rename-livecheckable
This commit is contained in:
commit
d4c8ce0bba
@ -277,7 +277,7 @@ module Cask
|
|||||||
sig { void }
|
sig { void }
|
||||||
def audit_latest_with_livecheck
|
def audit_latest_with_livecheck
|
||||||
return unless cask.version&.latest?
|
return unless cask.version&.latest?
|
||||||
return unless cask.livecheckable?
|
return unless cask.livecheck_defined?
|
||||||
return if cask.livecheck.skip?
|
return if cask.livecheck.skip?
|
||||||
|
|
||||||
add_error "Casks with a `livecheck` should not use `version :latest`."
|
add_error "Casks with a `livecheck` should not use `version :latest`."
|
||||||
@ -299,7 +299,7 @@ module Cask
|
|||||||
return if cask.version&.latest?
|
return if cask.version&.latest?
|
||||||
return if (url = cask.url).nil?
|
return if (url = cask.url).nil?
|
||||||
return if block_url_offline?
|
return if block_url_offline?
|
||||||
return if cask.livecheckable?
|
return if cask.livecheck_defined?
|
||||||
return if livecheck_result == :auto_detected
|
return if livecheck_result == :auto_detected
|
||||||
|
|
||||||
add_livecheck = "please add a livecheck. See #{Formatter.url(LIVECHECK_REFERENCE_URL)}"
|
add_livecheck = "please add a livecheck. See #{Formatter.url(LIVECHECK_REFERENCE_URL)}"
|
||||||
@ -693,7 +693,7 @@ module Cask
|
|||||||
sig { returns(T.nilable(MacOSVersion)) }
|
sig { returns(T.nilable(MacOSVersion)) }
|
||||||
def livecheck_min_os
|
def livecheck_min_os
|
||||||
return unless online?
|
return unless online?
|
||||||
return unless cask.livecheckable?
|
return unless cask.livecheck_defined?
|
||||||
return if cask.livecheck.strategy != :sparkle
|
return if cask.livecheck.strategy != :sparkle
|
||||||
|
|
||||||
# `Sparkle` strategy blocks that use the `items` argument (instead of
|
# `Sparkle` strategy blocks that use the `items` argument (instead of
|
||||||
@ -924,7 +924,7 @@ module Cask
|
|||||||
sig { void }
|
sig { void }
|
||||||
def audit_livecheck_https_availability
|
def audit_livecheck_https_availability
|
||||||
return unless online?
|
return unless online?
|
||||||
return unless cask.livecheckable?
|
return unless cask.livecheck_defined?
|
||||||
return unless (url = cask.livecheck.url)
|
return unless (url = cask.livecheck.url)
|
||||||
return if url.is_a?(Symbol)
|
return if url.is_a?(Symbol)
|
||||||
|
|
||||||
|
@ -44,6 +44,8 @@ module Cask
|
|||||||
|
|
||||||
def livecheck; end
|
def livecheck; end
|
||||||
|
|
||||||
|
def livecheck_defined?; end
|
||||||
|
|
||||||
def livecheckable?; end
|
def livecheckable?; end
|
||||||
|
|
||||||
def name; end
|
def name; end
|
||||||
|
@ -95,7 +95,8 @@ module Cask
|
|||||||
:disable_replacement,
|
:disable_replacement,
|
||||||
:discontinued?, # TODO: remove once discontinued? is removed (4.5.0)
|
:discontinued?, # TODO: remove once discontinued? is removed (4.5.0)
|
||||||
:livecheck,
|
:livecheck,
|
||||||
:livecheckable?,
|
:livecheck_defined?,
|
||||||
|
:livecheckable?, # TODO: remove once `#livecheckable?` is removed
|
||||||
:on_system_blocks_exist?,
|
:on_system_blocks_exist?,
|
||||||
:on_system_block_min_os,
|
:on_system_block_min_os,
|
||||||
:depends_on_set_in_block?,
|
:depends_on_set_in_block?,
|
||||||
@ -110,7 +111,7 @@ module Cask
|
|||||||
attr_reader :cask, :token, :deprecation_date, :deprecation_reason, :deprecation_replacement, :disable_date,
|
attr_reader :cask, :token, :deprecation_date, :deprecation_reason, :deprecation_replacement, :disable_date,
|
||||||
:disable_reason, :disable_replacement, :on_system_block_min_os
|
:disable_reason, :disable_replacement, :on_system_block_min_os
|
||||||
|
|
||||||
attr_predicate :deprecated?, :disabled?, :livecheckable?, :on_system_blocks_exist?, :depends_on_set_in_block?
|
attr_predicate :deprecated?, :disabled?, :livecheck_defined?, :on_system_blocks_exist?, :depends_on_set_in_block?
|
||||||
|
|
||||||
def initialize(cask)
|
def initialize(cask)
|
||||||
@cask = cask
|
@cask = cask
|
||||||
@ -431,14 +432,22 @@ module Cask
|
|||||||
@livecheck ||= Livecheck.new(cask)
|
@livecheck ||= Livecheck.new(cask)
|
||||||
return @livecheck unless block
|
return @livecheck unless block
|
||||||
|
|
||||||
if !@cask.allow_reassignment && @livecheckable
|
if !@cask.allow_reassignment && @livecheck_defined
|
||||||
raise CaskInvalidError.new(cask, "'livecheck' stanza may only appear once.")
|
raise CaskInvalidError.new(cask, "'livecheck' stanza may only appear once.")
|
||||||
end
|
end
|
||||||
|
|
||||||
@livecheckable = true
|
@livecheck_defined = true
|
||||||
@livecheck.instance_eval(&block)
|
@livecheck.instance_eval(&block)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Whether the cask contains a `livecheck` block. This is a legacy alias
|
||||||
|
# for `#livecheck_defined?`.
|
||||||
|
sig { returns(T::Boolean) }
|
||||||
|
def livecheckable?
|
||||||
|
# odeprecated "`livecheckable?`", "`livecheck_defined?`"
|
||||||
|
@livecheck_defined == true
|
||||||
|
end
|
||||||
|
|
||||||
# Declare that a cask is no longer functional or supported.
|
# Declare that a cask is no longer functional or supported.
|
||||||
#
|
#
|
||||||
# NOTE: A warning will be shown when trying to install this cask.
|
# NOTE: A warning will be shown when trying to install this cask.
|
||||||
|
@ -44,7 +44,7 @@ module Homebrew
|
|||||||
casks = args.named.to_paths(only: :cask, recurse_tap: true).map { |path| Cask::CaskLoader.load(path) }
|
casks = args.named.to_paths(only: :cask, recurse_tap: true).map { |path| Cask::CaskLoader.load(path) }
|
||||||
|
|
||||||
unversioned_casks = casks.select do |cask|
|
unversioned_casks = casks.select do |cask|
|
||||||
cask.url&.unversioned? && !cask.livecheckable?
|
cask.url&.unversioned? && !cask.livecheck_defined?
|
||||||
end
|
end
|
||||||
|
|
||||||
ohai "Unversioned Casks: #{unversioned_casks.count} (#{state.size} cached)"
|
ohai "Unversioned Casks: #{unversioned_casks.count} (#{state.size} cached)"
|
||||||
|
@ -137,7 +137,7 @@ module Homebrew
|
|||||||
def skip_repology?(formula_or_cask)
|
def skip_repology?(formula_or_cask)
|
||||||
return true unless args.repology?
|
return true unless args.repology?
|
||||||
|
|
||||||
(ENV["CI"].present? && args.open_pr? && formula_or_cask.livecheckable?) ||
|
(ENV["CI"].present? && args.open_pr? && formula_or_cask.livecheck_defined?) ||
|
||||||
(formula_or_cask.is_a?(Formula) && formula_or_cask.versioned_formula?)
|
(formula_or_cask.is_a?(Formula) && formula_or_cask.versioned_formula?)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -329,7 +329,7 @@ module Homebrew
|
|||||||
"skipped"
|
"skipped"
|
||||||
elsif repology_latest.is_a?(Version) &&
|
elsif repology_latest.is_a?(Version) &&
|
||||||
repology_latest > current_version_value &&
|
repology_latest > current_version_value &&
|
||||||
!loaded_formula_or_cask.livecheckable? &&
|
!loaded_formula_or_cask.livecheck_defined? &&
|
||||||
current_version_value != "latest"
|
current_version_value != "latest"
|
||||||
repology_latest
|
repology_latest
|
||||||
end.presence
|
end.presence
|
||||||
@ -490,8 +490,8 @@ module Homebrew
|
|||||||
if repology_latest.is_a?(Version) &&
|
if repology_latest.is_a?(Version) &&
|
||||||
repology_latest > current_version.general &&
|
repology_latest > current_version.general &&
|
||||||
repology_latest > new_version.general &&
|
repology_latest > new_version.general &&
|
||||||
formula_or_cask.livecheckable?
|
formula_or_cask.livecheck_defined?
|
||||||
puts "#{title_name} was not bumped to the Repology version because it's livecheckable."
|
puts "#{title_name} was not bumped to the Repology version because it has a `livecheck` block."
|
||||||
end
|
end
|
||||||
if new_version.blank? || versions_equal ||
|
if new_version.blank? || versions_equal ||
|
||||||
(!new_version.general.is_a?(Version) && !version_info.multiple_versions)
|
(!new_version.general.is_a?(Version) && !version_info.multiple_versions)
|
||||||
|
@ -64,7 +64,7 @@ module Homebrew
|
|||||||
:mpd.f.recursive_dependencies.reject(&:installed?)
|
:mpd.f.recursive_dependencies.reject(&:installed?)
|
||||||
|
|
||||||
'vlc'.c # => instance of the vlc cask
|
'vlc'.c # => instance of the vlc cask
|
||||||
:tsh.c.livecheckable?
|
:tsh.c.livecheck_defined?
|
||||||
EOS
|
EOS
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -454,6 +454,11 @@ class Formula
|
|||||||
# @see .livecheck=
|
# @see .livecheck=
|
||||||
delegate livecheck: :"self.class"
|
delegate livecheck: :"self.class"
|
||||||
|
|
||||||
|
# Is a livecheck specification defined for the software?
|
||||||
|
# @!method livecheck_defined?
|
||||||
|
# @see .livecheck_defined?
|
||||||
|
delegate livecheck_defined?: :"self.class"
|
||||||
|
|
||||||
# Is a livecheck specification defined for the software?
|
# Is a livecheck specification defined for the software?
|
||||||
# @!method livecheckable?
|
# @!method livecheckable?
|
||||||
# @see .livecheckable?
|
# @see .livecheckable?
|
||||||
@ -3537,8 +3542,19 @@ class Formula
|
|||||||
# It returns `true` when a `livecheck` block is present in the {Formula}
|
# It returns `true` when a `livecheck` block is present in the {Formula}
|
||||||
# and `false` otherwise.
|
# and `false` otherwise.
|
||||||
sig { returns(T::Boolean) }
|
sig { returns(T::Boolean) }
|
||||||
|
def livecheck_defined?
|
||||||
|
@livecheck_defined == true
|
||||||
|
end
|
||||||
|
|
||||||
|
# Checks whether a `livecheck` specification is defined or not. This is a
|
||||||
|
# legacy alias for `#livecheck_defined?`.
|
||||||
|
#
|
||||||
|
# It returns `true` when a `livecheck` block is present in the {Formula}
|
||||||
|
# and `false` otherwise.
|
||||||
|
sig { returns(T::Boolean) }
|
||||||
def livecheckable?
|
def livecheckable?
|
||||||
@livecheckable == true
|
# odeprecated "`livecheckable?`", "`livecheck_defined?`"
|
||||||
|
@livecheck_defined == true
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks whether a service specification is defined or not.
|
# Checks whether a service specification is defined or not.
|
||||||
@ -4163,7 +4179,7 @@ class Formula
|
|||||||
end
|
end
|
||||||
|
|
||||||
# {Livecheck} can be used to check for newer versions of the software.
|
# {Livecheck} can be used to check for newer versions of the software.
|
||||||
# This method evaluates the DSL specified in the livecheck block of the
|
# This method evaluates the DSL specified in the `livecheck` block of the
|
||||||
# {Formula} (if it exists) and sets the instance variables of a {Livecheck}
|
# {Formula} (if it exists) and sets the instance variables of a {Livecheck}
|
||||||
# object accordingly. This is used by `brew livecheck` to check for newer
|
# object accordingly. This is used by `brew livecheck` to check for newer
|
||||||
# versions of the software.
|
# versions of the software.
|
||||||
@ -4183,7 +4199,7 @@ class Formula
|
|||||||
def livecheck(&block)
|
def livecheck(&block)
|
||||||
return @livecheck unless block
|
return @livecheck unless block
|
||||||
|
|
||||||
@livecheckable = true
|
@livecheck_defined = true
|
||||||
@livecheck.instance_eval(&block)
|
@livecheck.instance_eval(&block)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ class Livecheck
|
|||||||
# Sets the `@referenced_cask_name` instance variable to the provided `String`
|
# Sets the `@referenced_cask_name` instance variable to the provided `String`
|
||||||
# or returns the `@referenced_cask_name` instance variable when no argument
|
# or returns the `@referenced_cask_name` instance variable when no argument
|
||||||
# is provided. Inherited livecheck values from the referenced cask
|
# is provided. Inherited livecheck values from the referenced cask
|
||||||
# (e.g. regex) can be overridden in the livecheck block.
|
# (e.g. regex) can be overridden in the `livecheck` block.
|
||||||
sig {
|
sig {
|
||||||
params(
|
params(
|
||||||
# Name of cask to inherit livecheck info from.
|
# Name of cask to inherit livecheck info from.
|
||||||
@ -56,7 +56,7 @@ class Livecheck
|
|||||||
# Sets the `@referenced_formula_name` instance variable to the provided
|
# Sets the `@referenced_formula_name` instance variable to the provided
|
||||||
# `String` or returns the `@referenced_formula_name` instance variable when
|
# `String` or returns the `@referenced_formula_name` instance variable when
|
||||||
# no argument is provided. Inherited livecheck values from the referenced
|
# no argument is provided. Inherited livecheck values from the referenced
|
||||||
# formula (e.g. regex) can be overridden in the livecheck block.
|
# formula (e.g. regex) can be overridden in the `livecheck` block.
|
||||||
sig {
|
sig {
|
||||||
params(
|
params(
|
||||||
# Name of formula to inherit livecheck info from.
|
# Name of formula to inherit livecheck info from.
|
||||||
|
@ -79,7 +79,7 @@ module Homebrew
|
|||||||
full_name: false,
|
full_name: false,
|
||||||
debug: false
|
debug: false
|
||||||
)
|
)
|
||||||
# Check the livecheck block for a formula or cask reference
|
# Check the `livecheck` block for a formula or cask reference
|
||||||
livecheck = formula_or_cask.livecheck
|
livecheck = formula_or_cask.livecheck
|
||||||
livecheck_formula = livecheck.formula
|
livecheck_formula = livecheck.formula
|
||||||
livecheck_cask = livecheck.cask
|
livecheck_cask = livecheck.cask
|
||||||
@ -347,7 +347,7 @@ module Homebrew
|
|||||||
newer_than_upstream: is_newer_than_upstream,
|
newer_than_upstream: is_newer_than_upstream,
|
||||||
}.compact
|
}.compact
|
||||||
info[:meta] = {
|
info[:meta] = {
|
||||||
livecheckable: formula_or_cask.livecheckable?,
|
livecheck_defined: formula_or_cask.livecheck_defined?,
|
||||||
}
|
}
|
||||||
info[:meta][:head_only] = true if formula&.head_only?
|
info[:meta][:head_only] = true if formula&.head_only?
|
||||||
info[:meta].merge!(version_info[:meta]) if version_info.present? && version_info.key?(:meta)
|
info[:meta].merge!(version_info[:meta]) if version_info.present? && version_info.key?(:meta)
|
||||||
@ -465,7 +465,7 @@ module Homebrew
|
|||||||
status_hash[:messages] = messages if messages.is_a?(Array)
|
status_hash[:messages] = messages if messages.is_a?(Array)
|
||||||
|
|
||||||
status_hash[:meta] = {
|
status_hash[:meta] = {
|
||||||
livecheckable: package_or_resource.livecheckable?,
|
livecheck_defined: package_or_resource.livecheck_defined?,
|
||||||
}
|
}
|
||||||
status_hash[:meta][:head_only] = true if formula&.head_only?
|
status_hash[:meta][:head_only] = true if formula&.head_only?
|
||||||
|
|
||||||
@ -478,7 +478,7 @@ module Homebrew
|
|||||||
package_or_resource_s = info[:resource].present? ? " " : ""
|
package_or_resource_s = info[:resource].present? ? " " : ""
|
||||||
package_or_resource_s += "#{Tty.blue}#{info[:formula] || info[:cask] || info[:resource]}#{Tty.reset}"
|
package_or_resource_s += "#{Tty.blue}#{info[:formula] || info[:cask] || info[:resource]}#{Tty.reset}"
|
||||||
package_or_resource_s += " (cask)" if ambiguous_cask
|
package_or_resource_s += " (cask)" if ambiguous_cask
|
||||||
package_or_resource_s += " (guessed)" if verbose && !info[:meta][:livecheckable]
|
package_or_resource_s += " (guessed)" if verbose && !info[:meta][:livecheck_defined]
|
||||||
|
|
||||||
current_s = if info[:version][:newer_than_upstream]
|
current_s = if info[:version][:newer_than_upstream]
|
||||||
"#{Tty.red}#{info[:version][:current]}#{Tty.reset}"
|
"#{Tty.red}#{info[:version][:current]}#{Tty.reset}"
|
||||||
@ -608,7 +608,7 @@ module Homebrew
|
|||||||
formula = formula_or_cask if formula_or_cask.is_a?(Formula)
|
formula = formula_or_cask if formula_or_cask.is_a?(Formula)
|
||||||
cask = formula_or_cask if formula_or_cask.is_a?(Cask::Cask)
|
cask = formula_or_cask if formula_or_cask.is_a?(Cask::Cask)
|
||||||
|
|
||||||
has_livecheckable = formula_or_cask.livecheckable?
|
livecheck_defined = formula_or_cask.livecheck_defined?
|
||||||
livecheck = formula_or_cask.livecheck
|
livecheck = formula_or_cask.livecheck
|
||||||
referenced_livecheck = referenced_formula_or_cask&.livecheck
|
referenced_livecheck = referenced_formula_or_cask&.livecheck
|
||||||
|
|
||||||
@ -632,7 +632,7 @@ module Homebrew
|
|||||||
elsif cask
|
elsif cask
|
||||||
puts "Cask: #{cask_name(formula_or_cask, full_name:)}"
|
puts "Cask: #{cask_name(formula_or_cask, full_name:)}"
|
||||||
end
|
end
|
||||||
puts "Livecheckable?: #{has_livecheckable ? "Yes" : "No"}"
|
puts "livecheck block?: #{livecheck_defined ? "Yes" : "No"}"
|
||||||
puts "Throttle: #{livecheck_throttle}" if livecheck_throttle
|
puts "Throttle: #{livecheck_throttle}" if livecheck_throttle
|
||||||
|
|
||||||
livecheck_references.each do |ref_formula_or_cask|
|
livecheck_references.each do |ref_formula_or_cask|
|
||||||
@ -736,7 +736,7 @@ module Homebrew
|
|||||||
|
|
||||||
match_version_map.delete_if do |_match, version|
|
match_version_map.delete_if do |_match, version|
|
||||||
next true if version.blank?
|
next true if version.blank?
|
||||||
next false if has_livecheckable
|
next false if livecheck_defined
|
||||||
|
|
||||||
UNSTABLE_VERSION_KEYWORDS.any? do |rejection|
|
UNSTABLE_VERSION_KEYWORDS.any? do |rejection|
|
||||||
version.to_s.include?(rejection)
|
version.to_s.include?(rejection)
|
||||||
@ -839,12 +839,12 @@ module Homebrew
|
|||||||
quiet: false,
|
quiet: false,
|
||||||
verbose: false
|
verbose: false
|
||||||
)
|
)
|
||||||
has_livecheckable = resource.livecheckable?
|
livecheck_defined = resource.livecheck_defined?
|
||||||
|
|
||||||
if debug
|
if debug
|
||||||
puts "\n\n"
|
puts "\n\n"
|
||||||
puts "Resource: #{resource.name}"
|
puts "Resource: #{resource.name}"
|
||||||
puts "Livecheckable?: #{has_livecheckable ? "Yes" : "No"}"
|
puts "livecheck block?: #{livecheck_defined ? "Yes" : "No"}"
|
||||||
end
|
end
|
||||||
|
|
||||||
resource_version_info = {}
|
resource_version_info = {}
|
||||||
@ -939,7 +939,7 @@ module Homebrew
|
|||||||
|
|
||||||
match_version_map.delete_if do |_match, version|
|
match_version_map.delete_if do |_match, version|
|
||||||
next true if version.blank?
|
next true if version.blank?
|
||||||
next false if has_livecheckable
|
next false if livecheck_defined
|
||||||
|
|
||||||
UNSTABLE_VERSION_KEYWORDS.any? do |rejection|
|
UNSTABLE_VERSION_KEYWORDS.any? do |rejection|
|
||||||
version.to_s.include?(rejection)
|
version.to_s.include?(rejection)
|
||||||
@ -978,7 +978,10 @@ module Homebrew
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
resource_version_info[:meta] = { livecheckable: has_livecheckable, url: {} }
|
resource_version_info[:meta] = {
|
||||||
|
livecheck_defined: livecheck_defined,
|
||||||
|
url: {},
|
||||||
|
}
|
||||||
if livecheck_url.is_a?(Symbol) && livecheck_url_string
|
if livecheck_url.is_a?(Symbol) && livecheck_url_string
|
||||||
resource_version_info[:meta][:url][:symbol] = livecheck_url
|
resource_version_info[:meta][:url][:symbol] = livecheck_url
|
||||||
end
|
end
|
||||||
|
@ -9,14 +9,14 @@ module Homebrew
|
|||||||
sig {
|
sig {
|
||||||
params(
|
params(
|
||||||
package_or_resource: T.any(Formula, Cask::Cask, Resource),
|
package_or_resource: T.any(Formula, Cask::Cask, Resource),
|
||||||
livecheckable: T::Boolean,
|
livecheck_defined: T::Boolean,
|
||||||
full_name: T::Boolean,
|
full_name: T::Boolean,
|
||||||
verbose: T::Boolean,
|
verbose: T::Boolean,
|
||||||
).returns(T::Hash[Symbol, T.untyped])
|
).returns(T::Hash[Symbol, T.untyped])
|
||||||
}
|
}
|
||||||
private_class_method def self.package_or_resource_skip(
|
private_class_method def self.package_or_resource_skip(
|
||||||
package_or_resource,
|
package_or_resource,
|
||||||
livecheckable,
|
livecheck_defined,
|
||||||
full_name: false,
|
full_name: false,
|
||||||
verbose: false
|
verbose: false
|
||||||
)
|
)
|
||||||
@ -32,7 +32,7 @@ module Homebrew
|
|||||||
|
|
||||||
skip_message = if package_or_resource.livecheck.skip_msg.present?
|
skip_message = if package_or_resource.livecheck.skip_msg.present?
|
||||||
package_or_resource.livecheck.skip_msg
|
package_or_resource.livecheck.skip_msg
|
||||||
elsif !livecheckable
|
elsif !livecheck_defined
|
||||||
if stable_from_google_code_archive
|
if stable_from_google_code_archive
|
||||||
"Stable URL is from Google Code Archive"
|
"Stable URL is from Google Code Archive"
|
||||||
elsif stable_from_internet_archive
|
elsif stable_from_internet_archive
|
||||||
@ -50,19 +50,19 @@ module Homebrew
|
|||||||
|
|
||||||
sig {
|
sig {
|
||||||
params(
|
params(
|
||||||
formula: Formula,
|
formula: Formula,
|
||||||
_livecheckable: T::Boolean,
|
_livecheck_defined: T::Boolean,
|
||||||
full_name: T::Boolean,
|
full_name: T::Boolean,
|
||||||
verbose: T::Boolean,
|
verbose: T::Boolean,
|
||||||
).returns(T::Hash[Symbol, T.untyped])
|
).returns(T::Hash[Symbol, T.untyped])
|
||||||
}
|
}
|
||||||
private_class_method def self.formula_head_only(formula, _livecheckable, full_name: false, verbose: false)
|
private_class_method def self.formula_head_only(formula, _livecheck_defined, full_name: false, verbose: false)
|
||||||
return {} if !formula.head_only? || formula.any_version_installed?
|
return {} if !formula.head_only? || formula.any_version_installed?
|
||||||
|
|
||||||
Livecheck.status_hash(
|
Livecheck.status_hash(
|
||||||
formula,
|
formula,
|
||||||
"error",
|
"error",
|
||||||
["HEAD only formula must be installed to be livecheckable"],
|
["HEAD only formula must be installed to be checkable"],
|
||||||
full_name:,
|
full_name:,
|
||||||
verbose:,
|
verbose:,
|
||||||
)
|
)
|
||||||
@ -70,86 +70,86 @@ module Homebrew
|
|||||||
|
|
||||||
sig {
|
sig {
|
||||||
params(
|
params(
|
||||||
formula: Formula,
|
formula: Formula,
|
||||||
livecheckable: T::Boolean,
|
livecheck_defined: T::Boolean,
|
||||||
full_name: T::Boolean,
|
full_name: T::Boolean,
|
||||||
verbose: T::Boolean,
|
verbose: T::Boolean,
|
||||||
).returns(T::Hash[Symbol, T.untyped])
|
).returns(T::Hash[Symbol, T.untyped])
|
||||||
}
|
}
|
||||||
private_class_method def self.formula_deprecated(formula, livecheckable, full_name: false, verbose: false)
|
private_class_method def self.formula_deprecated(formula, livecheck_defined, full_name: false, verbose: false)
|
||||||
return {} if !formula.deprecated? || livecheckable
|
return {} if !formula.deprecated? || livecheck_defined
|
||||||
|
|
||||||
Livecheck.status_hash(formula, "deprecated", full_name:, verbose:)
|
Livecheck.status_hash(formula, "deprecated", full_name:, verbose:)
|
||||||
end
|
end
|
||||||
|
|
||||||
sig {
|
sig {
|
||||||
params(
|
params(
|
||||||
formula: Formula,
|
formula: Formula,
|
||||||
livecheckable: T::Boolean,
|
livecheck_defined: T::Boolean,
|
||||||
full_name: T::Boolean,
|
full_name: T::Boolean,
|
||||||
verbose: T::Boolean,
|
verbose: T::Boolean,
|
||||||
).returns(T::Hash[Symbol, T.untyped])
|
).returns(T::Hash[Symbol, T.untyped])
|
||||||
}
|
}
|
||||||
private_class_method def self.formula_disabled(formula, livecheckable, full_name: false, verbose: false)
|
private_class_method def self.formula_disabled(formula, livecheck_defined, full_name: false, verbose: false)
|
||||||
return {} if !formula.disabled? || livecheckable
|
return {} if !formula.disabled? || livecheck_defined
|
||||||
|
|
||||||
Livecheck.status_hash(formula, "disabled", full_name:, verbose:)
|
Livecheck.status_hash(formula, "disabled", full_name:, verbose:)
|
||||||
end
|
end
|
||||||
|
|
||||||
sig {
|
sig {
|
||||||
params(
|
params(
|
||||||
formula: Formula,
|
formula: Formula,
|
||||||
livecheckable: T::Boolean,
|
livecheck_defined: T::Boolean,
|
||||||
full_name: T::Boolean,
|
full_name: T::Boolean,
|
||||||
verbose: T::Boolean,
|
verbose: T::Boolean,
|
||||||
).returns(T::Hash[Symbol, T.untyped])
|
).returns(T::Hash[Symbol, T.untyped])
|
||||||
}
|
}
|
||||||
private_class_method def self.formula_versioned(formula, livecheckable, full_name: false, verbose: false)
|
private_class_method def self.formula_versioned(formula, livecheck_defined, full_name: false, verbose: false)
|
||||||
return {} if !formula.versioned_formula? || livecheckable
|
return {} if !formula.versioned_formula? || livecheck_defined
|
||||||
|
|
||||||
Livecheck.status_hash(formula, "versioned", full_name:, verbose:)
|
Livecheck.status_hash(formula, "versioned", full_name:, verbose:)
|
||||||
end
|
end
|
||||||
|
|
||||||
sig {
|
sig {
|
||||||
params(
|
params(
|
||||||
cask: Cask::Cask,
|
cask: Cask::Cask,
|
||||||
livecheckable: T::Boolean,
|
livecheck_defined: T::Boolean,
|
||||||
full_name: T::Boolean,
|
full_name: T::Boolean,
|
||||||
verbose: T::Boolean,
|
verbose: T::Boolean,
|
||||||
).returns(T::Hash[Symbol, T.untyped])
|
).returns(T::Hash[Symbol, T.untyped])
|
||||||
}
|
}
|
||||||
private_class_method def self.cask_deprecated(cask, livecheckable, full_name: false, verbose: false)
|
private_class_method def self.cask_deprecated(cask, livecheck_defined, full_name: false, verbose: false)
|
||||||
return {} if !cask.deprecated? || livecheckable
|
return {} if !cask.deprecated? || livecheck_defined
|
||||||
|
|
||||||
Livecheck.status_hash(cask, "deprecated", full_name:, verbose:)
|
Livecheck.status_hash(cask, "deprecated", full_name:, verbose:)
|
||||||
end
|
end
|
||||||
|
|
||||||
sig {
|
sig {
|
||||||
params(
|
params(
|
||||||
cask: Cask::Cask,
|
cask: Cask::Cask,
|
||||||
livecheckable: T::Boolean,
|
livecheck_defined: T::Boolean,
|
||||||
full_name: T::Boolean,
|
full_name: T::Boolean,
|
||||||
verbose: T::Boolean,
|
verbose: T::Boolean,
|
||||||
).returns(T::Hash[Symbol, T.untyped])
|
).returns(T::Hash[Symbol, T.untyped])
|
||||||
}
|
}
|
||||||
private_class_method def self.cask_disabled(cask, livecheckable, full_name: false, verbose: false)
|
private_class_method def self.cask_disabled(cask, livecheck_defined, full_name: false, verbose: false)
|
||||||
return {} if !cask.disabled? || livecheckable
|
return {} if !cask.disabled? || livecheck_defined
|
||||||
|
|
||||||
Livecheck.status_hash(cask, "disabled", full_name:, verbose:)
|
Livecheck.status_hash(cask, "disabled", full_name:, verbose:)
|
||||||
end
|
end
|
||||||
|
|
||||||
sig {
|
sig {
|
||||||
params(
|
params(
|
||||||
cask: Cask::Cask,
|
cask: Cask::Cask,
|
||||||
_livecheckable: T::Boolean,
|
_livecheck_defined: T::Boolean,
|
||||||
full_name: T::Boolean,
|
full_name: T::Boolean,
|
||||||
verbose: T::Boolean,
|
verbose: T::Boolean,
|
||||||
extract_plist: T::Boolean,
|
extract_plist: T::Boolean,
|
||||||
).returns(T::Hash[Symbol, T.untyped])
|
).returns(T::Hash[Symbol, T.untyped])
|
||||||
}
|
}
|
||||||
private_class_method def self.cask_extract_plist(
|
private_class_method def self.cask_extract_plist(
|
||||||
cask,
|
cask,
|
||||||
_livecheckable,
|
_livecheck_defined,
|
||||||
full_name: false,
|
full_name: false,
|
||||||
verbose: false,
|
verbose: false,
|
||||||
extract_plist: false
|
extract_plist: false
|
||||||
@ -167,28 +167,28 @@ module Homebrew
|
|||||||
|
|
||||||
sig {
|
sig {
|
||||||
params(
|
params(
|
||||||
cask: Cask::Cask,
|
cask: Cask::Cask,
|
||||||
livecheckable: T::Boolean,
|
livecheck_defined: T::Boolean,
|
||||||
full_name: T::Boolean,
|
full_name: T::Boolean,
|
||||||
verbose: T::Boolean,
|
verbose: T::Boolean,
|
||||||
).returns(T::Hash[Symbol, T.untyped])
|
).returns(T::Hash[Symbol, T.untyped])
|
||||||
}
|
}
|
||||||
private_class_method def self.cask_version_latest(cask, livecheckable, full_name: false, verbose: false)
|
private_class_method def self.cask_version_latest(cask, livecheck_defined, full_name: false, verbose: false)
|
||||||
return {} if !(cask.present? && cask.version&.latest?) || livecheckable
|
return {} if !(cask.present? && cask.version&.latest?) || livecheck_defined
|
||||||
|
|
||||||
Livecheck.status_hash(cask, "latest", full_name:, verbose:)
|
Livecheck.status_hash(cask, "latest", full_name:, verbose:)
|
||||||
end
|
end
|
||||||
|
|
||||||
sig {
|
sig {
|
||||||
params(
|
params(
|
||||||
cask: Cask::Cask,
|
cask: Cask::Cask,
|
||||||
livecheckable: T::Boolean,
|
livecheck_defined: T::Boolean,
|
||||||
full_name: T::Boolean,
|
full_name: T::Boolean,
|
||||||
verbose: T::Boolean,
|
verbose: T::Boolean,
|
||||||
).returns(T::Hash[Symbol, T.untyped])
|
).returns(T::Hash[Symbol, T.untyped])
|
||||||
}
|
}
|
||||||
private_class_method def self.cask_url_unversioned(cask, livecheckable, full_name: false, verbose: false)
|
private_class_method def self.cask_url_unversioned(cask, livecheck_defined, full_name: false, verbose: false)
|
||||||
return {} if !(cask.present? && cask.url&.unversioned?) || livecheckable
|
return {} if !(cask.present? && cask.url&.unversioned?) || livecheck_defined
|
||||||
|
|
||||||
Livecheck.status_hash(cask, "unversioned", full_name:, verbose:)
|
Livecheck.status_hash(cask, "unversioned", full_name:, verbose:)
|
||||||
end
|
end
|
||||||
@ -232,7 +232,7 @@ module Homebrew
|
|||||||
).returns(T::Hash[Symbol, T.untyped])
|
).returns(T::Hash[Symbol, T.untyped])
|
||||||
}
|
}
|
||||||
def self.skip_information(package_or_resource, full_name: false, verbose: false, extract_plist: true)
|
def self.skip_information(package_or_resource, full_name: false, verbose: false, extract_plist: true)
|
||||||
livecheckable = package_or_resource.livecheckable?
|
livecheck_defined = package_or_resource.livecheck_defined?
|
||||||
|
|
||||||
checks = case package_or_resource
|
checks = case package_or_resource
|
||||||
when Formula
|
when Formula
|
||||||
@ -246,9 +246,9 @@ module Homebrew
|
|||||||
checks.each do |method_name|
|
checks.each do |method_name|
|
||||||
skip_hash = case method_name
|
skip_hash = case method_name
|
||||||
when :cask_extract_plist
|
when :cask_extract_plist
|
||||||
send(method_name, package_or_resource, livecheckable, full_name:, verbose:, extract_plist:)
|
send(method_name, package_or_resource, livecheck_defined, full_name:, verbose:, extract_plist:)
|
||||||
else
|
else
|
||||||
send(method_name, package_or_resource, livecheckable, full_name:, verbose:)
|
send(method_name, package_or_resource, livecheck_defined, full_name:, verbose:)
|
||||||
end
|
end
|
||||||
return skip_hash if skip_hash.present?
|
return skip_hash if skip_hash.present?
|
||||||
end
|
end
|
||||||
|
@ -29,7 +29,7 @@ class Resource
|
|||||||
@name = name
|
@name = name
|
||||||
@patches = []
|
@patches = []
|
||||||
@livecheck = Livecheck.new(self)
|
@livecheck = Livecheck.new(self)
|
||||||
@livecheckable = false
|
@livecheck_defined = false
|
||||||
@insecure = false
|
@insecure = false
|
||||||
instance_eval(&block) if block
|
instance_eval(&block) if block
|
||||||
end
|
end
|
||||||
@ -142,7 +142,7 @@ class Resource
|
|||||||
end
|
end
|
||||||
|
|
||||||
# {Livecheck} can be used to check for newer versions of the software.
|
# {Livecheck} can be used to check for newer versions of the software.
|
||||||
# This method evaluates the DSL specified in the livecheck block of the
|
# This method evaluates the DSL specified in the `livecheck` block of the
|
||||||
# {Resource} (if it exists) and sets the instance variables of a {Livecheck}
|
# {Resource} (if it exists) and sets the instance variables of a {Livecheck}
|
||||||
# object accordingly. This is used by `brew livecheck` to check for newer
|
# object accordingly. This is used by `brew livecheck` to check for newer
|
||||||
# versions of the software.
|
# versions of the software.
|
||||||
@ -160,15 +160,28 @@ class Resource
|
|||||||
def livecheck(&block)
|
def livecheck(&block)
|
||||||
return @livecheck unless block
|
return @livecheck unless block
|
||||||
|
|
||||||
@livecheckable = true
|
@livecheck_defined = true
|
||||||
@livecheck.instance_eval(&block)
|
@livecheck.instance_eval(&block)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Whether a livecheck specification is defined or not.
|
# Whether a livecheck specification is defined or not.
|
||||||
# It returns true when a `livecheck` block is present in the {Resource} and
|
#
|
||||||
# false otherwise and is used by livecheck.
|
# It returns `true` when a `livecheck` block is present in the {Resource}
|
||||||
|
# and `false` otherwise.
|
||||||
|
sig { returns(T::Boolean) }
|
||||||
|
def livecheck_defined?
|
||||||
|
@livecheck_defined == true
|
||||||
|
end
|
||||||
|
|
||||||
|
# Whether a livecheck specification is defined or not. This is a legacy alias
|
||||||
|
# for `#livecheck_defined?`.
|
||||||
|
#
|
||||||
|
# It returns `true` when a `livecheck` block is present in the {Resource}
|
||||||
|
# and `false` otherwise.
|
||||||
|
sig { returns(T::Boolean) }
|
||||||
def livecheckable?
|
def livecheckable?
|
||||||
@livecheckable == true
|
# odeprecated "`livecheckable?`", "`livecheck_defined?`"
|
||||||
|
@livecheck_defined == true
|
||||||
end
|
end
|
||||||
|
|
||||||
def sha256(val)
|
def sha256(val)
|
||||||
|
@ -40,8 +40,9 @@ module RuboCop
|
|||||||
method_nodes.select(&:block_type?).each do |node|
|
method_nodes.select(&:block_type?).each do |node|
|
||||||
node.child_nodes.each do |child|
|
node.child_nodes.each do |child|
|
||||||
child.each_node(:send) do |send_node|
|
child.each_node(:send) do |send_node|
|
||||||
# Skip (nested) livecheck blocks as its `url` is different to a download `url`.
|
# Skip (nested) `livecheck` block as its `url` is different
|
||||||
next if send_node.method_name == :livecheck || inside_livecheck_block?(send_node)
|
# from a download `url`.
|
||||||
|
next if send_node.method_name == :livecheck || inside_livecheck_defined?(send_node)
|
||||||
# Skip string interpolations.
|
# Skip string interpolations.
|
||||||
if send_node.ancestors.drop_while { |a| !a.begin_type? }.any? { |a| a.dstr_type? || a.regexp_type? }
|
if send_node.ancestors.drop_while { |a| !a.begin_type? }.any? { |a| a.dstr_type? || a.regexp_type? }
|
||||||
next
|
next
|
||||||
@ -55,15 +56,15 @@ module RuboCop
|
|||||||
names
|
names
|
||||||
end
|
end
|
||||||
|
|
||||||
def inside_livecheck_block?(node)
|
def inside_livecheck_defined?(node)
|
||||||
single_stanza_livecheck_block?(node) || multi_stanza_livecheck_block?(node)
|
single_stanza_livecheck_defined?(node) || multi_stanza_livecheck_defined?(node)
|
||||||
end
|
end
|
||||||
|
|
||||||
def single_stanza_livecheck_block?(node)
|
def single_stanza_livecheck_defined?(node)
|
||||||
node.parent.block_type? && node.parent.method_name == :livecheck
|
node.parent.block_type? && node.parent.method_name == :livecheck
|
||||||
end
|
end
|
||||||
|
|
||||||
def multi_stanza_livecheck_block?(node)
|
def multi_stanza_livecheck_defined?(node)
|
||||||
grandparent_node = node.parent.parent
|
grandparent_node = node.parent.parent
|
||||||
node.parent.begin_type? && grandparent_node.block_type? && grandparent_node.method_name == :livecheck
|
node.parent.begin_type? && grandparent_node.block_type? && grandparent_node.method_name == :livecheck
|
||||||
end
|
end
|
||||||
|
2
Library/Homebrew/sorbet/rbi/dsl/cask/dsl.rbi
generated
2
Library/Homebrew/sorbet/rbi/dsl/cask/dsl.rbi
generated
@ -16,7 +16,7 @@ class Cask::DSL
|
|||||||
def disabled?; end
|
def disabled?; end
|
||||||
|
|
||||||
sig { returns(T::Boolean) }
|
sig { returns(T::Boolean) }
|
||||||
def livecheckable?; end
|
def livecheck_defined?; end
|
||||||
|
|
||||||
sig { returns(T::Boolean) }
|
sig { returns(T::Boolean) }
|
||||||
def on_system_blocks_exist?; end
|
def on_system_blocks_exist?; end
|
||||||
|
3
Library/Homebrew/sorbet/rbi/dsl/formula.rbi
generated
3
Library/Homebrew/sorbet/rbi/dsl/formula.rbi
generated
@ -90,6 +90,9 @@ class Formula
|
|||||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||||
def livecheck(*args, &block); end
|
def livecheck(*args, &block); end
|
||||||
|
|
||||||
|
sig { params(args: T.untyped, block: T.untyped).returns(T::Boolean) }
|
||||||
|
def livecheck_defined?(*args, &block); end
|
||||||
|
|
||||||
sig { params(args: T.untyped, block: T.untyped).returns(T::Boolean) }
|
sig { params(args: T.untyped, block: T.untyped).returns(T::Boolean) }
|
||||||
def livecheckable?(*args, &block); end
|
def livecheckable?(*args, &block); end
|
||||||
|
|
||||||
|
@ -508,13 +508,13 @@ RSpec.describe Cask::Audit, :cask do
|
|||||||
let(:online) { true }
|
let(:online) { true }
|
||||||
let(:message) { /Version '[^']*' differs from '[^']*' retrieved by livecheck\./ }
|
let(:message) { /Version '[^']*' differs from '[^']*' retrieved by livecheck\./ }
|
||||||
|
|
||||||
context "when the Cask has a livecheck block using skip" do
|
context "when the Cask has a `livecheck` block using skip" do
|
||||||
let(:cask_token) { "livecheck-skip" }
|
let(:cask_token) { "livecheck-skip" }
|
||||||
|
|
||||||
it { is_expected.not_to error_with(message) }
|
it { is_expected.not_to error_with(message) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when the Cask has a livecheck block referencing a Cask using skip" do
|
context "when the Cask has a `livecheck` block referencing a Cask using skip" do
|
||||||
let(:cask_token) { "livecheck-skip-reference" }
|
let(:cask_token) { "livecheck-skip-reference" }
|
||||||
|
|
||||||
it { is_expected.not_to error_with(message) }
|
it { is_expected.not_to error_with(message) }
|
||||||
@ -526,7 +526,7 @@ RSpec.describe Cask::Audit, :cask do
|
|||||||
it { is_expected.not_to error_with(message) }
|
it { is_expected.not_to error_with(message) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when the Cask has a livecheck block referencing a deprecated Cask" do
|
context "when the Cask has a `livecheck` block referencing a deprecated Cask" do
|
||||||
let(:cask_token) { "livecheck-deprecated-reference" }
|
let(:cask_token) { "livecheck-deprecated-reference" }
|
||||||
|
|
||||||
it { is_expected.not_to error_with(message) }
|
it { is_expected.not_to error_with(message) }
|
||||||
@ -538,7 +538,7 @@ RSpec.describe Cask::Audit, :cask do
|
|||||||
it { is_expected.not_to error_with(message) }
|
it { is_expected.not_to error_with(message) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when the Cask has a livecheck block referencing a disabled Cask" do
|
context "when the Cask has a `livecheck` block referencing a disabled Cask" do
|
||||||
let(:cask_token) { "livecheck-disabled-reference" }
|
let(:cask_token) { "livecheck-disabled-reference" }
|
||||||
|
|
||||||
it { is_expected.not_to error_with(message) }
|
it { is_expected.not_to error_with(message) }
|
||||||
@ -550,7 +550,7 @@ RSpec.describe Cask::Audit, :cask do
|
|||||||
it { is_expected.not_to error_with(message) }
|
it { is_expected.not_to error_with(message) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when the Cask has a livecheck block referencing a Cask where version is :latest" do
|
context "when the Cask has a `livecheck` block referencing a Cask where version is :latest" do
|
||||||
let(:cask_token) { "livecheck-version-latest-reference" }
|
let(:cask_token) { "livecheck-version-latest-reference" }
|
||||||
|
|
||||||
it { is_expected.not_to error_with(message) }
|
it { is_expected.not_to error_with(message) }
|
||||||
@ -562,7 +562,7 @@ RSpec.describe Cask::Audit, :cask do
|
|||||||
it { is_expected.not_to error_with(message) }
|
it { is_expected.not_to error_with(message) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when the Cask has a livecheck block referencing a Cask with an unversioned url" do
|
context "when the Cask has a `livecheck` block referencing a Cask with an unversioned url" do
|
||||||
let(:cask_token) { "livecheck-url-unversioned-reference" }
|
let(:cask_token) { "livecheck-url-unversioned-reference" }
|
||||||
|
|
||||||
it { is_expected.not_to error_with(message) }
|
it { is_expected.not_to error_with(message) }
|
||||||
|
@ -704,16 +704,16 @@ RSpec.describe Formula do
|
|||||||
expect(f.livecheck.regex).to eq(/test-v?(\d+(?:\.\d+)+)\.t/i)
|
expect(f.livecheck.regex).to eq(/test-v?(\d+(?:\.\d+)+)\.t/i)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#livecheckable?" do
|
describe "#livecheck_defined?" do
|
||||||
specify "no livecheck block defined" do
|
specify "no `livecheck` block defined" do
|
||||||
f = formula do
|
f = formula do
|
||||||
url "https://brew.sh/test-1.0.tbz"
|
url "https://brew.sh/test-1.0.tbz"
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(f.livecheckable?).to be false
|
expect(f.livecheck_defined?).to be false
|
||||||
end
|
end
|
||||||
|
|
||||||
specify "livecheck block defined" do
|
specify "`livecheck` block defined" do
|
||||||
f = formula do
|
f = formula do
|
||||||
url "https://brew.sh/test-1.0.tbz"
|
url "https://brew.sh/test-1.0.tbz"
|
||||||
livecheck do
|
livecheck do
|
||||||
@ -721,7 +721,7 @@ RSpec.describe Formula do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(f.livecheckable?).to be true
|
expect(f.livecheck_defined?).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
specify "livecheck references Formula URL" do
|
specify "livecheck references Formula URL" do
|
||||||
|
@ -77,7 +77,7 @@ RSpec.describe Homebrew::Livecheck do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe "::resolve_livecheck_reference" do
|
describe "::resolve_livecheck_reference" do
|
||||||
context "when a formula/cask has a livecheck block without formula/cask methods" do
|
context "when a formula/cask has a `livecheck` block without formula/cask methods" do
|
||||||
it "returns [nil, []]" do
|
it "returns [nil, []]" do
|
||||||
expect(livecheck.resolve_livecheck_reference(f)).to eq([nil, []])
|
expect(livecheck.resolve_livecheck_reference(f)).to eq([nil, []])
|
||||||
expect(livecheck.resolve_livecheck_reference(c)).to eq([nil, []])
|
expect(livecheck.resolve_livecheck_reference(c)).to eq([nil, []])
|
||||||
@ -111,7 +111,7 @@ RSpec.describe Homebrew::Livecheck do
|
|||||||
status: "error",
|
status: "error",
|
||||||
messages: ["Unable to get versions"],
|
messages: ["Unable to get versions"],
|
||||||
meta: {
|
meta: {
|
||||||
livecheckable: true,
|
livecheck_defined: true,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
@ -123,7 +123,7 @@ RSpec.describe Homebrew::Livecheck do
|
|||||||
status: "error",
|
status: "error",
|
||||||
messages: ["Unable to get versions"],
|
messages: ["Unable to get versions"],
|
||||||
meta: {
|
meta: {
|
||||||
livecheckable: true,
|
livecheck_defined: true,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
@ -178,30 +178,30 @@ RSpec.describe Homebrew::Livecheck::SkipConditions do
|
|||||||
formula: "test_deprecated",
|
formula: "test_deprecated",
|
||||||
status: "deprecated",
|
status: "deprecated",
|
||||||
meta: {
|
meta: {
|
||||||
livecheckable: false,
|
livecheck_defined: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
disabled: {
|
disabled: {
|
||||||
formula: "test_disabled",
|
formula: "test_disabled",
|
||||||
status: "disabled",
|
status: "disabled",
|
||||||
meta: {
|
meta: {
|
||||||
livecheckable: false,
|
livecheck_defined: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
versioned: {
|
versioned: {
|
||||||
formula: "test@0.0.1",
|
formula: "test@0.0.1",
|
||||||
status: "versioned",
|
status: "versioned",
|
||||||
meta: {
|
meta: {
|
||||||
livecheckable: false,
|
livecheck_defined: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
head_only: {
|
head_only: {
|
||||||
formula: "test_head_only",
|
formula: "test_head_only",
|
||||||
status: "error",
|
status: "error",
|
||||||
messages: ["HEAD only formula must be installed to be livecheckable"],
|
messages: ["HEAD only formula must be installed to be checkable"],
|
||||||
meta: {
|
meta: {
|
||||||
head_only: true,
|
livecheck_defined: false,
|
||||||
livecheckable: false,
|
head_only: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
gist: {
|
gist: {
|
||||||
@ -209,7 +209,7 @@ RSpec.describe Homebrew::Livecheck::SkipConditions do
|
|||||||
status: "skipped",
|
status: "skipped",
|
||||||
messages: ["Stable URL is a GitHub Gist"],
|
messages: ["Stable URL is a GitHub Gist"],
|
||||||
meta: {
|
meta: {
|
||||||
livecheckable: false,
|
livecheck_defined: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
google_code_archive: {
|
google_code_archive: {
|
||||||
@ -217,7 +217,7 @@ RSpec.describe Homebrew::Livecheck::SkipConditions do
|
|||||||
status: "skipped",
|
status: "skipped",
|
||||||
messages: ["Stable URL is from Google Code Archive"],
|
messages: ["Stable URL is from Google Code Archive"],
|
||||||
meta: {
|
meta: {
|
||||||
livecheckable: false,
|
livecheck_defined: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
internet_archive: {
|
internet_archive: {
|
||||||
@ -225,14 +225,14 @@ RSpec.describe Homebrew::Livecheck::SkipConditions do
|
|||||||
status: "skipped",
|
status: "skipped",
|
||||||
messages: ["Stable URL is from Internet Archive"],
|
messages: ["Stable URL is from Internet Archive"],
|
||||||
meta: {
|
meta: {
|
||||||
livecheckable: false,
|
livecheck_defined: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
skip: {
|
skip: {
|
||||||
formula: "test_skip",
|
formula: "test_skip",
|
||||||
status: "skipped",
|
status: "skipped",
|
||||||
meta: {
|
meta: {
|
||||||
livecheckable: true,
|
livecheck_defined: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
skip_with_message: {
|
skip_with_message: {
|
||||||
@ -240,7 +240,7 @@ RSpec.describe Homebrew::Livecheck::SkipConditions do
|
|||||||
status: "skipped",
|
status: "skipped",
|
||||||
messages: ["Not maintained"],
|
messages: ["Not maintained"],
|
||||||
meta: {
|
meta: {
|
||||||
livecheckable: true,
|
livecheck_defined: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -249,14 +249,14 @@ RSpec.describe Homebrew::Livecheck::SkipConditions do
|
|||||||
cask: "test_deprecated",
|
cask: "test_deprecated",
|
||||||
status: "deprecated",
|
status: "deprecated",
|
||||||
meta: {
|
meta: {
|
||||||
livecheckable: false,
|
livecheck_defined: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
disabled: {
|
disabled: {
|
||||||
cask: "test_disabled",
|
cask: "test_disabled",
|
||||||
status: "disabled",
|
status: "disabled",
|
||||||
meta: {
|
meta: {
|
||||||
livecheckable: false,
|
livecheck_defined: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
extract_plist: {
|
extract_plist: {
|
||||||
@ -264,28 +264,28 @@ RSpec.describe Homebrew::Livecheck::SkipConditions do
|
|||||||
status: "skipped",
|
status: "skipped",
|
||||||
messages: ["Use `--extract-plist` to enable checking multiple casks with ExtractPlist strategy"],
|
messages: ["Use `--extract-plist` to enable checking multiple casks with ExtractPlist strategy"],
|
||||||
meta: {
|
meta: {
|
||||||
livecheckable: true,
|
livecheck_defined: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
latest: {
|
latest: {
|
||||||
cask: "test_latest",
|
cask: "test_latest",
|
||||||
status: "latest",
|
status: "latest",
|
||||||
meta: {
|
meta: {
|
||||||
livecheckable: false,
|
livecheck_defined: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
unversioned: {
|
unversioned: {
|
||||||
cask: "test_unversioned",
|
cask: "test_unversioned",
|
||||||
status: "unversioned",
|
status: "unversioned",
|
||||||
meta: {
|
meta: {
|
||||||
livecheckable: false,
|
livecheck_defined: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
skip: {
|
skip: {
|
||||||
cask: "test_skip",
|
cask: "test_skip",
|
||||||
status: "skipped",
|
status: "skipped",
|
||||||
meta: {
|
meta: {
|
||||||
livecheckable: true,
|
livecheck_defined: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
skip_with_message: {
|
skip_with_message: {
|
||||||
@ -293,7 +293,7 @@ RSpec.describe Homebrew::Livecheck::SkipConditions do
|
|||||||
status: "skipped",
|
status: "skipped",
|
||||||
messages: ["Not maintained"],
|
messages: ["Not maintained"],
|
||||||
meta: {
|
meta: {
|
||||||
livecheckable: true,
|
livecheck_defined: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -301,21 +301,21 @@ RSpec.describe Homebrew::Livecheck::SkipConditions do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe "::skip_information" do
|
describe "::skip_information" do
|
||||||
context "when a formula without a livecheckable is deprecated" do
|
context "when a formula without a `livecheck` block is deprecated" do
|
||||||
it "skips" do
|
it "skips" do
|
||||||
expect(skip_conditions.skip_information(formulae[:deprecated]))
|
expect(skip_conditions.skip_information(formulae[:deprecated]))
|
||||||
.to eq(status_hashes[:formula][:deprecated])
|
.to eq(status_hashes[:formula][:deprecated])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when a formula without a livecheckable is disabled" do
|
context "when a formula without a `livecheck` block is disabled" do
|
||||||
it "skips" do
|
it "skips" do
|
||||||
expect(skip_conditions.skip_information(formulae[:disabled]))
|
expect(skip_conditions.skip_information(formulae[:disabled]))
|
||||||
.to eq(status_hashes[:formula][:disabled])
|
.to eq(status_hashes[:formula][:disabled])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when a formula without a livecheckable is versioned" do
|
context "when a formula without a `livecheck` block is versioned" do
|
||||||
it "skips" do
|
it "skips" do
|
||||||
expect(skip_conditions.skip_information(formulae[:versioned]))
|
expect(skip_conditions.skip_information(formulae[:versioned]))
|
||||||
.to eq(status_hashes[:formula][:versioned])
|
.to eq(status_hashes[:formula][:versioned])
|
||||||
@ -329,21 +329,21 @@ RSpec.describe Homebrew::Livecheck::SkipConditions do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when a formula without a livecheckable has a GitHub Gist stable URL" do
|
context "when a formula without a `livecheck` block has a GitHub Gist stable URL" do
|
||||||
it "skips" do
|
it "skips" do
|
||||||
expect(skip_conditions.skip_information(formulae[:gist]))
|
expect(skip_conditions.skip_information(formulae[:gist]))
|
||||||
.to eq(status_hashes[:formula][:gist])
|
.to eq(status_hashes[:formula][:gist])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when a formula without a livecheckable has a Google Code Archive stable URL" do
|
context "when a formula without a `livecheck` block has a Google Code Archive stable URL" do
|
||||||
it "skips" do
|
it "skips" do
|
||||||
expect(skip_conditions.skip_information(formulae[:google_code_archive]))
|
expect(skip_conditions.skip_information(formulae[:google_code_archive]))
|
||||||
.to eq(status_hashes[:formula][:google_code_archive])
|
.to eq(status_hashes[:formula][:google_code_archive])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when a formula without a livecheckable has an Internet Archive stable URL" do
|
context "when a formula without a `livecheck` block has an Internet Archive stable URL" do
|
||||||
it "skips" do
|
it "skips" do
|
||||||
expect(skip_conditions.skip_information(formulae[:internet_archive]))
|
expect(skip_conditions.skip_information(formulae[:internet_archive]))
|
||||||
.to eq(status_hashes[:formula][:internet_archive])
|
.to eq(status_hashes[:formula][:internet_archive])
|
||||||
@ -360,14 +360,14 @@ RSpec.describe Homebrew::Livecheck::SkipConditions do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when a cask without a livecheckable is deprecated" do
|
context "when a cask without a `livecheck` block is deprecated" do
|
||||||
it "skips" do
|
it "skips" do
|
||||||
expect(skip_conditions.skip_information(casks[:deprecated]))
|
expect(skip_conditions.skip_information(casks[:deprecated]))
|
||||||
.to eq(status_hashes[:cask][:deprecated])
|
.to eq(status_hashes[:cask][:deprecated])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when a cask without a livecheckable is disabled" do
|
context "when a cask without a `livecheck` block is disabled" do
|
||||||
it "skips" do
|
it "skips" do
|
||||||
expect(skip_conditions.skip_information(casks[:disabled]))
|
expect(skip_conditions.skip_information(casks[:disabled]))
|
||||||
.to eq(status_hashes[:cask][:disabled])
|
.to eq(status_hashes[:cask][:disabled])
|
||||||
@ -381,14 +381,14 @@ RSpec.describe Homebrew::Livecheck::SkipConditions do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when a cask without a livecheckable has `version :latest`" do
|
context "when a cask without a `livecheck` block has `version :latest`" do
|
||||||
it "skips" do
|
it "skips" do
|
||||||
expect(skip_conditions.skip_information(casks[:latest]))
|
expect(skip_conditions.skip_information(casks[:latest]))
|
||||||
.to eq(status_hashes[:cask][:latest])
|
.to eq(status_hashes[:cask][:latest])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when a cask without a livecheckable has an unversioned URL" do
|
context "when a cask without a `livecheck` block has an unversioned URL" do
|
||||||
it "skips" do
|
it "skips" do
|
||||||
expect(skip_conditions.skip_information(casks[:unversioned]))
|
expect(skip_conditions.skip_information(casks[:unversioned]))
|
||||||
.to eq(status_hashes[:cask][:unversioned])
|
.to eq(status_hashes[:cask][:unversioned])
|
||||||
@ -417,21 +417,21 @@ RSpec.describe Homebrew::Livecheck::SkipConditions do
|
|||||||
describe "::referenced_skip_information" do
|
describe "::referenced_skip_information" do
|
||||||
let(:original_name) { "original" }
|
let(:original_name) { "original" }
|
||||||
|
|
||||||
context "when a formula without a livecheckable is deprecated" do
|
context "when a formula without a `livecheck` block is deprecated" do
|
||||||
it "errors" do
|
it "errors" do
|
||||||
expect { skip_conditions.referenced_skip_information(formulae[:deprecated], original_name) }
|
expect { skip_conditions.referenced_skip_information(formulae[:deprecated], original_name) }
|
||||||
.to raise_error(RuntimeError, "Referenced formula (test_deprecated) is skipped as deprecated")
|
.to raise_error(RuntimeError, "Referenced formula (test_deprecated) is skipped as deprecated")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when a formula without a livecheckable is disabled" do
|
context "when a formula without a `livecheck` block is disabled" do
|
||||||
it "errors" do
|
it "errors" do
|
||||||
expect { skip_conditions.referenced_skip_information(formulae[:disabled], original_name) }
|
expect { skip_conditions.referenced_skip_information(formulae[:disabled], original_name) }
|
||||||
.to raise_error(RuntimeError, "Referenced formula (test_disabled) is skipped as disabled")
|
.to raise_error(RuntimeError, "Referenced formula (test_disabled) is skipped as disabled")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when a formula without a livecheckable is versioned" do
|
context "when a formula without a `livecheck` block is versioned" do
|
||||||
it "errors" do
|
it "errors" do
|
||||||
expect { skip_conditions.referenced_skip_information(formulae[:versioned], original_name) }
|
expect { skip_conditions.referenced_skip_information(formulae[:versioned], original_name) }
|
||||||
.to raise_error(RuntimeError, "Referenced formula (test@0.0.1) is skipped as versioned")
|
.to raise_error(RuntimeError, "Referenced formula (test@0.0.1) is skipped as versioned")
|
||||||
@ -445,21 +445,21 @@ RSpec.describe Homebrew::Livecheck::SkipConditions do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when a formula without a livecheckable has a GitHub Gist stable URL" do
|
context "when a formula without a `livecheck` block has a GitHub Gist stable URL" do
|
||||||
it "errors" do
|
it "errors" do
|
||||||
expect { skip_conditions.referenced_skip_information(formulae[:gist], original_name) }
|
expect { skip_conditions.referenced_skip_information(formulae[:gist], original_name) }
|
||||||
.to raise_error(RuntimeError, "Referenced formula (test_gist) is automatically skipped")
|
.to raise_error(RuntimeError, "Referenced formula (test_gist) is automatically skipped")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when a formula without a livecheckable has a Google Code Archive stable URL" do
|
context "when a formula without a `livecheck` block has a Google Code Archive stable URL" do
|
||||||
it "errors" do
|
it "errors" do
|
||||||
expect { skip_conditions.referenced_skip_information(formulae[:google_code_archive], original_name) }
|
expect { skip_conditions.referenced_skip_information(formulae[:google_code_archive], original_name) }
|
||||||
.to raise_error(RuntimeError, "Referenced formula (test_google_code_archive) is automatically skipped")
|
.to raise_error(RuntimeError, "Referenced formula (test_google_code_archive) is automatically skipped")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when a formula without a livecheckable has an Internet Archive stable URL" do
|
context "when a formula without a `livecheck` block has an Internet Archive stable URL" do
|
||||||
it "errors" do
|
it "errors" do
|
||||||
expect { skip_conditions.referenced_skip_information(formulae[:internet_archive], original_name) }
|
expect { skip_conditions.referenced_skip_information(formulae[:internet_archive], original_name) }
|
||||||
.to raise_error(RuntimeError, "Referenced formula (test_internet_archive) is automatically skipped")
|
.to raise_error(RuntimeError, "Referenced formula (test_internet_archive) is automatically skipped")
|
||||||
@ -476,14 +476,14 @@ RSpec.describe Homebrew::Livecheck::SkipConditions do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when a cask without a livecheckable is deprecated" do
|
context "when a cask without a `livecheck` block is deprecated" do
|
||||||
it "errors" do
|
it "errors" do
|
||||||
expect { skip_conditions.referenced_skip_information(casks[:deprecated], original_name) }
|
expect { skip_conditions.referenced_skip_information(casks[:deprecated], original_name) }
|
||||||
.to raise_error(RuntimeError, "Referenced cask (test_deprecated) is skipped as deprecated")
|
.to raise_error(RuntimeError, "Referenced cask (test_deprecated) is skipped as deprecated")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when a cask without a livecheckable is disabled" do
|
context "when a cask without a `livecheck` block is disabled" do
|
||||||
it "errors" do
|
it "errors" do
|
||||||
expect { skip_conditions.referenced_skip_information(casks[:disabled], original_name) }
|
expect { skip_conditions.referenced_skip_information(casks[:disabled], original_name) }
|
||||||
.to raise_error(RuntimeError, "Referenced cask (test_disabled) is skipped as disabled")
|
.to raise_error(RuntimeError, "Referenced cask (test_disabled) is skipped as disabled")
|
||||||
@ -499,14 +499,14 @@ RSpec.describe Homebrew::Livecheck::SkipConditions do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when a cask without a livecheckable has `version :latest`" do
|
context "when a cask without a `livecheck` block has `version :latest`" do
|
||||||
it "errors" do
|
it "errors" do
|
||||||
expect { skip_conditions.referenced_skip_information(casks[:latest], original_name) }
|
expect { skip_conditions.referenced_skip_information(casks[:latest], original_name) }
|
||||||
.to raise_error(RuntimeError, "Referenced cask (test_latest) is skipped as latest")
|
.to raise_error(RuntimeError, "Referenced cask (test_latest) is skipped as latest")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when a cask without a livecheckable has an unversioned URL" do
|
context "when a cask without a `livecheck` block has an unversioned URL" do
|
||||||
it "errors" do
|
it "errors" do
|
||||||
expect { skip_conditions.referenced_skip_information(casks[:unversioned], original_name) }
|
expect { skip_conditions.referenced_skip_information(casks[:unversioned], original_name) }
|
||||||
.to raise_error(RuntimeError, "Referenced cask (test_unversioned) is skipped as unversioned")
|
.to raise_error(RuntimeError, "Referenced cask (test_unversioned) is skipped as unversioned")
|
||||||
@ -533,7 +533,7 @@ RSpec.describe Homebrew::Livecheck::SkipConditions do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe "::print_skip_information" do
|
describe "::print_skip_information" do
|
||||||
context "when a formula without a livecheckable is deprecated" do
|
context "when a formula without a `livecheck` block is deprecated" do
|
||||||
it "prints skip information" do
|
it "prints skip information" do
|
||||||
expect { skip_conditions.print_skip_information(status_hashes[:formula][:deprecated]) }
|
expect { skip_conditions.print_skip_information(status_hashes[:formula][:deprecated]) }
|
||||||
.to output("test_deprecated: deprecated\n").to_stdout
|
.to output("test_deprecated: deprecated\n").to_stdout
|
||||||
@ -541,7 +541,7 @@ RSpec.describe Homebrew::Livecheck::SkipConditions do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when a formula without a livecheckable is disabled" do
|
context "when a formula without a `livecheck` block is disabled" do
|
||||||
it "prints skip information" do
|
it "prints skip information" do
|
||||||
expect { skip_conditions.print_skip_information(status_hashes[:formula][:disabled]) }
|
expect { skip_conditions.print_skip_information(status_hashes[:formula][:disabled]) }
|
||||||
.to output("test_disabled: disabled\n").to_stdout
|
.to output("test_disabled: disabled\n").to_stdout
|
||||||
@ -549,7 +549,7 @@ RSpec.describe Homebrew::Livecheck::SkipConditions do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when a formula without a livecheckable is versioned" do
|
context "when a formula without a `livecheck` block is versioned" do
|
||||||
it "prints skip information" do
|
it "prints skip information" do
|
||||||
expect { skip_conditions.print_skip_information(status_hashes[:formula][:versioned]) }
|
expect { skip_conditions.print_skip_information(status_hashes[:formula][:versioned]) }
|
||||||
.to output("test@0.0.1: versioned\n").to_stdout
|
.to output("test@0.0.1: versioned\n").to_stdout
|
||||||
@ -560,7 +560,7 @@ RSpec.describe Homebrew::Livecheck::SkipConditions do
|
|||||||
context "when a formula is HEAD-only and not installed" do
|
context "when a formula is HEAD-only and not installed" do
|
||||||
it "prints skip information" do
|
it "prints skip information" do
|
||||||
expect { skip_conditions.print_skip_information(status_hashes[:formula][:head_only]) }
|
expect { skip_conditions.print_skip_information(status_hashes[:formula][:head_only]) }
|
||||||
.to output("test_head_only: HEAD only formula must be installed to be livecheckable\n").to_stdout
|
.to output("test_head_only: HEAD only formula must be installed to be checkable\n").to_stdout
|
||||||
.and not_to_output.to_stderr
|
.and not_to_output.to_stderr
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -601,7 +601,7 @@ RSpec.describe Homebrew::Livecheck::SkipConditions do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when the cask is deprecated without a livecheckable" do
|
context "when the cask is deprecated without a `livecheck` block" do
|
||||||
it "prints skip information" do
|
it "prints skip information" do
|
||||||
expect { skip_conditions.print_skip_information(status_hashes[:cask][:deprecated]) }
|
expect { skip_conditions.print_skip_information(status_hashes[:cask][:deprecated]) }
|
||||||
.to output("test_deprecated: deprecated\n").to_stdout
|
.to output("test_deprecated: deprecated\n").to_stdout
|
||||||
@ -609,7 +609,7 @@ RSpec.describe Homebrew::Livecheck::SkipConditions do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when the cask is disabled without a livecheckable" do
|
context "when the cask is disabled without a `livecheck` block" do
|
||||||
it "prints skip information" do
|
it "prints skip information" do
|
||||||
expect { skip_conditions.print_skip_information(status_hashes[:cask][:disabled]) }
|
expect { skip_conditions.print_skip_information(status_hashes[:cask][:disabled]) }
|
||||||
.to output("test_disabled: disabled\n").to_stdout
|
.to output("test_disabled: disabled\n").to_stdout
|
||||||
@ -617,7 +617,7 @@ RSpec.describe Homebrew::Livecheck::SkipConditions do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when the cask has `version :latest` without a livecheckable" do
|
context "when the cask has `version :latest` without a `livecheck` block" do
|
||||||
it "prints skip information" do
|
it "prints skip information" do
|
||||||
expect { skip_conditions.print_skip_information(status_hashes[:cask][:latest]) }
|
expect { skip_conditions.print_skip_information(status_hashes[:cask][:latest]) }
|
||||||
.to output("test_latest: latest\n").to_stdout
|
.to output("test_latest: latest\n").to_stdout
|
||||||
@ -625,7 +625,7 @@ RSpec.describe Homebrew::Livecheck::SkipConditions do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when the cask has an unversioned URL without a livecheckable" do
|
context "when the cask has an unversioned URL without a `livecheck` block" do
|
||||||
it "prints skip information" do
|
it "prints skip information" do
|
||||||
expect { skip_conditions.print_skip_information(status_hashes[:cask][:unversioned]) }
|
expect { skip_conditions.print_skip_information(status_hashes[:cask][:unversioned]) }
|
||||||
.to output("test_unversioned: unversioned\n").to_stdout
|
.to output("test_unversioned: unversioned\n").to_stdout
|
||||||
|
@ -11,7 +11,7 @@ RSpec.describe Livecheck do
|
|||||||
head "https://github.com/Homebrew/brew.git"
|
head "https://github.com/Homebrew/brew.git"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
let(:livecheckable_f) { described_class.new(f.class) }
|
let(:livecheck_f) { described_class.new(f.class) }
|
||||||
|
|
||||||
let(:c) do
|
let(:c) do
|
||||||
Cask::CaskLoader.load(+<<-RUBY)
|
Cask::CaskLoader.load(+<<-RUBY)
|
||||||
@ -25,89 +25,89 @@ RSpec.describe Livecheck do
|
|||||||
end
|
end
|
||||||
RUBY
|
RUBY
|
||||||
end
|
end
|
||||||
let(:livecheckable_c) { described_class.new(c) }
|
let(:livecheck_c) { described_class.new(c) }
|
||||||
|
|
||||||
describe "#formula" do
|
describe "#formula" do
|
||||||
it "returns nil if not set" do
|
it "returns nil if not set" do
|
||||||
expect(livecheckable_f.formula).to be_nil
|
expect(livecheck_f.formula).to be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns the String if set" do
|
it "returns the String if set" do
|
||||||
livecheckable_f.formula("other-formula")
|
livecheck_f.formula("other-formula")
|
||||||
expect(livecheckable_f.formula).to eq("other-formula")
|
expect(livecheck_f.formula).to eq("other-formula")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raises a TypeError if the argument isn't a String" do
|
it "raises a TypeError if the argument isn't a String" do
|
||||||
expect do
|
expect do
|
||||||
livecheckable_f.formula(123)
|
livecheck_f.formula(123)
|
||||||
end.to raise_error TypeError
|
end.to raise_error TypeError
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#cask" do
|
describe "#cask" do
|
||||||
it "returns nil if not set" do
|
it "returns nil if not set" do
|
||||||
expect(livecheckable_c.cask).to be_nil
|
expect(livecheck_c.cask).to be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns the String if set" do
|
it "returns the String if set" do
|
||||||
livecheckable_c.cask("other-cask")
|
livecheck_c.cask("other-cask")
|
||||||
expect(livecheckable_c.cask).to eq("other-cask")
|
expect(livecheck_c.cask).to eq("other-cask")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#regex" do
|
describe "#regex" do
|
||||||
it "returns nil if not set" do
|
it "returns nil if not set" do
|
||||||
expect(livecheckable_f.regex).to be_nil
|
expect(livecheck_f.regex).to be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns the Regexp if set" do
|
it "returns the Regexp if set" do
|
||||||
livecheckable_f.regex(/foo/)
|
livecheck_f.regex(/foo/)
|
||||||
expect(livecheckable_f.regex).to eq(/foo/)
|
expect(livecheck_f.regex).to eq(/foo/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#skip" do
|
describe "#skip" do
|
||||||
it "sets @skip to true when no argument is provided" do
|
it "sets @skip to true when no argument is provided" do
|
||||||
expect(livecheckable_f.skip).to be true
|
expect(livecheck_f.skip).to be true
|
||||||
expect(livecheckable_f.instance_variable_get(:@skip)).to be true
|
expect(livecheck_f.instance_variable_get(:@skip)).to be true
|
||||||
expect(livecheckable_f.instance_variable_get(:@skip_msg)).to be_nil
|
expect(livecheck_f.instance_variable_get(:@skip_msg)).to be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
it "sets @skip to true and @skip_msg to the provided String" do
|
it "sets @skip to true and @skip_msg to the provided String" do
|
||||||
expect(livecheckable_f.skip("foo")).to be true
|
expect(livecheck_f.skip("foo")).to be true
|
||||||
expect(livecheckable_f.instance_variable_get(:@skip)).to be true
|
expect(livecheck_f.instance_variable_get(:@skip)).to be true
|
||||||
expect(livecheckable_f.instance_variable_get(:@skip_msg)).to eq("foo")
|
expect(livecheck_f.instance_variable_get(:@skip_msg)).to eq("foo")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#skip?" do
|
describe "#skip?" do
|
||||||
it "returns the value of @skip" do
|
it "returns the value of @skip" do
|
||||||
expect(livecheckable_f.skip?).to be false
|
expect(livecheck_f.skip?).to be false
|
||||||
|
|
||||||
livecheckable_f.skip
|
livecheck_f.skip
|
||||||
expect(livecheckable_f.skip?).to be true
|
expect(livecheck_f.skip?).to be true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#strategy" do
|
describe "#strategy" do
|
||||||
it "returns nil if not set" do
|
it "returns nil if not set" do
|
||||||
expect(livecheckable_f.strategy).to be_nil
|
expect(livecheck_f.strategy).to be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns the Symbol if set" do
|
it "returns the Symbol if set" do
|
||||||
livecheckable_f.strategy(:page_match)
|
livecheck_f.strategy(:page_match)
|
||||||
expect(livecheckable_f.strategy).to eq(:page_match)
|
expect(livecheck_f.strategy).to eq(:page_match)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#throttle" do
|
describe "#throttle" do
|
||||||
it "returns nil if not set" do
|
it "returns nil if not set" do
|
||||||
expect(livecheckable_f.throttle).to be_nil
|
expect(livecheck_f.throttle).to be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns the Integer if set" do
|
it "returns the Integer if set" do
|
||||||
livecheckable_f.throttle(10)
|
livecheck_f.throttle(10)
|
||||||
expect(livecheckable_f.throttle).to eq(10)
|
expect(livecheck_f.throttle).to eq(10)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -115,38 +115,38 @@ RSpec.describe Livecheck do
|
|||||||
let(:url_string) { "https://brew.sh" }
|
let(:url_string) { "https://brew.sh" }
|
||||||
|
|
||||||
it "returns nil if not set" do
|
it "returns nil if not set" do
|
||||||
expect(livecheckable_f.url).to be_nil
|
expect(livecheck_f.url).to be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns a string when set to a string" do
|
it "returns a string when set to a string" do
|
||||||
livecheckable_f.url(url_string)
|
livecheck_f.url(url_string)
|
||||||
expect(livecheckable_f.url).to eq(url_string)
|
expect(livecheck_f.url).to eq(url_string)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns the URL symbol if valid" do
|
it "returns the URL symbol if valid" do
|
||||||
livecheckable_f.url(:head)
|
livecheck_f.url(:head)
|
||||||
expect(livecheckable_f.url).to eq(:head)
|
expect(livecheck_f.url).to eq(:head)
|
||||||
|
|
||||||
livecheckable_f.url(:homepage)
|
livecheck_f.url(:homepage)
|
||||||
expect(livecheckable_f.url).to eq(:homepage)
|
expect(livecheck_f.url).to eq(:homepage)
|
||||||
|
|
||||||
livecheckable_f.url(:stable)
|
livecheck_f.url(:stable)
|
||||||
expect(livecheckable_f.url).to eq(:stable)
|
expect(livecheck_f.url).to eq(:stable)
|
||||||
|
|
||||||
livecheckable_c.url(:url)
|
livecheck_c.url(:url)
|
||||||
expect(livecheckable_c.url).to eq(:url)
|
expect(livecheck_c.url).to eq(:url)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raises an ArgumentError if the argument isn't a valid Symbol" do
|
it "raises an ArgumentError if the argument isn't a valid Symbol" do
|
||||||
expect do
|
expect do
|
||||||
livecheckable_f.url(:not_a_valid_symbol)
|
livecheck_f.url(:not_a_valid_symbol)
|
||||||
end.to raise_error ArgumentError
|
end.to raise_error ArgumentError
|
||||||
end
|
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(livecheckable_f.to_hash).to eq(
|
expect(livecheck_f.to_hash).to eq(
|
||||||
{
|
{
|
||||||
"cask" => nil,
|
"cask" => nil,
|
||||||
"formula" => nil,
|
"formula" => nil,
|
||||||
|
@ -65,19 +65,19 @@ RSpec.describe Resource do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe "#livecheck" do
|
describe "#livecheck" do
|
||||||
specify "when livecheck block is set" do
|
specify "when `livecheck` block is set" do
|
||||||
expect(livecheck_resource.livecheck.url).to eq("https://brew.sh/test/releases")
|
expect(livecheck_resource.livecheck.url).to eq("https://brew.sh/test/releases")
|
||||||
expect(livecheck_resource.livecheck.regex).to eq(/foo[._-]v?(\d+(?:\.\d+)+)\.t/i)
|
expect(livecheck_resource.livecheck.regex).to eq(/foo[._-]v?(\d+(?:\.\d+)+)\.t/i)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#livecheckable?" do
|
describe "#livecheck_defined?" do
|
||||||
it "returns false if livecheck block is not set in resource" do
|
it "returns false if `livecheck` block is not set in resource" do
|
||||||
expect(resource.livecheckable?).to be false
|
expect(resource.livecheck_defined?).to be false
|
||||||
end
|
end
|
||||||
|
|
||||||
specify "livecheck block defined in resources" do
|
specify "`livecheck` block defined in resources" do
|
||||||
expect(livecheck_resource.livecheckable?).to be true
|
expect(livecheck_resource.livecheck_defined?).to be true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ require "rubocops/livecheck"
|
|||||||
RSpec.describe RuboCop::Cop::FormulaAudit::LivecheckRegexParentheses do
|
RSpec.describe RuboCop::Cop::FormulaAudit::LivecheckRegexParentheses do
|
||||||
subject(:cop) { described_class.new }
|
subject(:cop) { described_class.new }
|
||||||
|
|
||||||
it "reports an offense when the `regex` call in the livecheck block does not use parentheses" do
|
it "reports an offense when the `regex` call in the `livecheck` block does not use parentheses" do
|
||||||
expect_offense(<<~RUBY)
|
expect_offense(<<~RUBY)
|
||||||
class Foo < Formula
|
class Foo < Formula
|
||||||
url "https://brew.sh/foo-1.0.tgz"
|
url "https://brew.sh/foo-1.0.tgz"
|
||||||
@ -30,7 +30,7 @@ RSpec.describe RuboCop::Cop::FormulaAudit::LivecheckRegexParentheses do
|
|||||||
RUBY
|
RUBY
|
||||||
end
|
end
|
||||||
|
|
||||||
it "reports no offenses when the `regex` call in the livecheck block uses parentheses" do
|
it "reports no offenses when the `regex` call in the `livecheck` block uses parentheses" do
|
||||||
expect_no_offenses(<<~RUBY)
|
expect_no_offenses(<<~RUBY)
|
||||||
class Foo < Formula
|
class Foo < Formula
|
||||||
url "https://brew.sh/foo-1.0.tgz"
|
url "https://brew.sh/foo-1.0.tgz"
|
||||||
|
@ -5,7 +5,7 @@ require "rubocops/livecheck"
|
|||||||
RSpec.describe RuboCop::Cop::FormulaAudit::LivecheckSkip do
|
RSpec.describe RuboCop::Cop::FormulaAudit::LivecheckSkip do
|
||||||
subject(:cop) { described_class.new }
|
subject(:cop) { described_class.new }
|
||||||
|
|
||||||
it "reports an offense when a skipped formula's livecheck block contains other information" do
|
it "reports an offense when a skipped formula's `livecheck` block contains other information" do
|
||||||
expect_offense(<<~RUBY)
|
expect_offense(<<~RUBY)
|
||||||
class Foo < Formula
|
class Foo < Formula
|
||||||
url "https://brew.sh/foo-1.0.tgz"
|
url "https://brew.sh/foo-1.0.tgz"
|
||||||
@ -29,7 +29,7 @@ RSpec.describe RuboCop::Cop::FormulaAudit::LivecheckSkip do
|
|||||||
RUBY
|
RUBY
|
||||||
end
|
end
|
||||||
|
|
||||||
it "reports no offenses when a skipped formula's livecheck block contains no other information" do
|
it "reports no offenses when a skipped formula's `livecheck` block contains no other information" do
|
||||||
expect_no_offenses(<<~RUBY)
|
expect_no_offenses(<<~RUBY)
|
||||||
class Foo < Formula
|
class Foo < Formula
|
||||||
url "https://brew.sh/foo-1.0.tgz"
|
url "https://brew.sh/foo-1.0.tgz"
|
||||||
|
@ -5,7 +5,7 @@ require "rubocops/livecheck"
|
|||||||
RSpec.describe RuboCop::Cop::FormulaAudit::LivecheckUrlProvided do
|
RSpec.describe RuboCop::Cop::FormulaAudit::LivecheckUrlProvided do
|
||||||
subject(:cop) { described_class.new }
|
subject(:cop) { described_class.new }
|
||||||
|
|
||||||
it "reports an offense when a `url` is not specified in a livecheck block" do
|
it "reports an offense when a `url` is not specified in a `livecheck` block" do
|
||||||
expect_offense(<<~RUBY)
|
expect_offense(<<~RUBY)
|
||||||
class Foo < Formula
|
class Foo < Formula
|
||||||
url "https://brew.sh/foo-1.0.tgz"
|
url "https://brew.sh/foo-1.0.tgz"
|
||||||
@ -29,7 +29,7 @@ RSpec.describe RuboCop::Cop::FormulaAudit::LivecheckUrlProvided do
|
|||||||
RUBY
|
RUBY
|
||||||
end
|
end
|
||||||
|
|
||||||
it "reports no offenses when a `url` and `regex` are specified in the livecheck block" do
|
it "reports no offenses when a `url` and `regex` are specified in the `livecheck` block" do
|
||||||
expect_no_offenses(<<~RUBY)
|
expect_no_offenses(<<~RUBY)
|
||||||
class Foo < Formula
|
class Foo < Formula
|
||||||
url "https://brew.sh/foo-1.0.tgz"
|
url "https://brew.sh/foo-1.0.tgz"
|
||||||
@ -42,7 +42,7 @@ RSpec.describe RuboCop::Cop::FormulaAudit::LivecheckUrlProvided do
|
|||||||
RUBY
|
RUBY
|
||||||
end
|
end
|
||||||
|
|
||||||
it "reports no offenses when a `url` and `strategy` are specified in the livecheck block" do
|
it "reports no offenses when a `url` and `strategy` are specified in the `livecheck` block" do
|
||||||
expect_no_offenses(<<~RUBY)
|
expect_no_offenses(<<~RUBY)
|
||||||
class Foo < Formula
|
class Foo < Formula
|
||||||
url "https://brew.sh/foo-1.0.tgz"
|
url "https://brew.sh/foo-1.0.tgz"
|
||||||
|
@ -5,7 +5,7 @@ require "rubocops/livecheck"
|
|||||||
RSpec.describe RuboCop::Cop::FormulaAudit::LivecheckUrlSymbol do
|
RSpec.describe RuboCop::Cop::FormulaAudit::LivecheckUrlSymbol do
|
||||||
subject(:cop) { described_class.new }
|
subject(:cop) { described_class.new }
|
||||||
|
|
||||||
it "reports an offense when the `url` specified in the livecheck block is identical to a formula URL" do
|
it "reports an offense when the `url` specified in the `livecheck` block is identical to a formula URL" do
|
||||||
expect_offense(<<~RUBY)
|
expect_offense(<<~RUBY)
|
||||||
class Foo < Formula
|
class Foo < Formula
|
||||||
url "https://brew.sh/foo-1.0.tgz"
|
url "https://brew.sh/foo-1.0.tgz"
|
||||||
@ -28,7 +28,7 @@ RSpec.describe RuboCop::Cop::FormulaAudit::LivecheckUrlSymbol do
|
|||||||
RUBY
|
RUBY
|
||||||
end
|
end
|
||||||
|
|
||||||
it "reports no offenses when the `url` specified in the livecheck block is not identical to a formula URL" do
|
it "reports no offenses when the `url` specified in the `livecheck` block is not identical to a formula URL" do
|
||||||
expect_no_offenses(<<~RUBY)
|
expect_no_offenses(<<~RUBY)
|
||||||
class Foo < Formula
|
class Foo < Formula
|
||||||
url "https://brew.sh/foo-1.0.tgz"
|
url "https://brew.sh/foo-1.0.tgz"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user