Refactoring in progress

This commit is contained in:
Mohammad Zain Abbas 2022-07-27 21:28:28 +02:00
parent 825707a219
commit 806f0be69a

View File

@ -367,13 +367,13 @@ module Homebrew
next info
end
if check_resources && has_resources && debug
puts <<~EOS
# if check_resources && has_resources && debug
# puts <<~EOS
----------
# ----------
EOS
end
# EOS
# end
print_latest_version(info, verbose: verbose, ambiguous_cask: ambiguous_casks.include?(formula_or_cask))
if check_resources && has_resources
@ -404,8 +404,11 @@ module Homebrew
}
resources_info << info
end
print_latest_resource_version(resources_info, verbose: verbose,
ambiguous_cask: ambiguous_casks.include?(formula_or_cask))
print_latest_resource_version(
resources_info,
verbose: verbose,
ambiguous_cask: ambiguous_casks.include?(formula_or_cask)
)
end
nil
@ -675,34 +678,30 @@ module Homebrew
homebrew_curl_root_domains.include?(url_root_domain)
end
# Identifies the latest version of the resources in a given Formulae/Casks and returns an Array of Hash containing
# the version information for all the resources. Returns an Array with nil value if a latest version
# Identifies the latest version of the resource in a given Formulae/Casks and returns a Hash containing
# the version information for a resource. Returns a nil value if a latest version
# couldn't be found for a given resource.
sig {
params(
formula_or_cask: T.any(Formula, Cask::Cask),
resource: T.any(Resource),
json: T::Boolean,
full_name: T::Boolean,
verbose: T::Boolean,
debug: T::Boolean,
).returns(Array(T.nilable(Hash)))
).returns(T.nilable(Hash))
}
def resource_version(
formula_or_cask,
resource,
json: false,
full_name: false,
verbose: false,
debug: false
)
resources_version = []
formula_or_cask.resources.each do |resource|
has_livecheckable = resource.livecheckable?
if debug
puts <<~EOS
----------
EOS
odebug "Resource: #{resource_name(resource, full_name: full_name)}"
odebug "Livecheckable?: #{has_livecheckable ? "Yes" : "No"}"
@ -840,7 +839,7 @@ module Homebrew
LivecheckVersion.create(resource, v)
end)
next unless json && verbose
next unless json
resource_version_info[:meta] = {}
resource_version_info[:meta][:livecheckable] = has_livecheckable ? "Yes" : "No"
@ -884,9 +883,7 @@ module Homebrew
resource_version_info[:meta][:url] = resource.url.to_s
end
end
resources_version << resource_version_info
end
resources_version
resource_version_info
end
# Identifies the latest version of the formula and returns a Hash containing