Updated get_info
- get_info builds info string by appending helper functions - removed unnecessary returns - fixed indentation in missing_formula - reduced size of regex in info_spec - missing_formula will indicate when it finds a cask with same name
This commit is contained in:
parent
330ae8c6fa
commit
fe643758d7
@ -27,12 +27,18 @@ module Cask
|
||||
end
|
||||
|
||||
def self.get_info(cask)
|
||||
<<~EOS.chomp
|
||||
#{title_info(cask)}
|
||||
#{Formatter.url(cask.homepage) if cask.homepage}
|
||||
#{installation_info(cask)}
|
||||
#{repo_info(cask)}#{name_info(cask)}#{language_info(cask)}#{artifact_info(cask)}#{Installer.print_caveats(cask)}
|
||||
EOS
|
||||
output = title_info(cask) + "\n"
|
||||
if cask.homepage then output << Formatter.url(cask.homepage) + "\n" end
|
||||
output << installation_info(cask)
|
||||
repo = repo_info(cask)
|
||||
output << repo unless repo.nil?
|
||||
output << name_info(cask)
|
||||
language = language_info(cask)
|
||||
output << language unless language.nil?
|
||||
output << artifact_info(cask)
|
||||
caveats = Installer.print_caveats(cask)
|
||||
output << caveats unless caveats.nil?
|
||||
output
|
||||
end
|
||||
|
||||
def self.info(cask)
|
||||
@ -64,9 +70,9 @@ module Cask
|
||||
).concat(")")
|
||||
install_info << "\n"
|
||||
end
|
||||
return install_info.strip
|
||||
install_info
|
||||
else
|
||||
"Not installed"
|
||||
"Not installed\n"
|
||||
end
|
||||
end
|
||||
|
||||
@ -99,15 +105,14 @@ module Cask
|
||||
end
|
||||
|
||||
def self.artifact_info(cask)
|
||||
artifact_output = ohai_title("Artifacts")
|
||||
cask.artifacts.each do |artifact|
|
||||
next unless artifact.respond_to?(:install_phase)
|
||||
next unless DSL::ORDINARY_ARTIFACT_CLASSES.include?(artifact.class)
|
||||
|
||||
return <<~EOS
|
||||
#{ohai_title("Artifacts")}
|
||||
#{artifact}
|
||||
EOS
|
||||
artifact_output << "\n" << artifact.to_s
|
||||
end
|
||||
artifact_output << "\n"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -7,7 +7,7 @@ module Homebrew
|
||||
module MissingFormula
|
||||
class << self
|
||||
def reason(name, silent: false)
|
||||
cask_reason(name, silent: false) || blacklisted_reason(name) ||
|
||||
cask_reason(name, silent: silent) || blacklisted_reason(name) ||
|
||||
tap_migration_reason(name) || deleted_reason(name, silent: silent)
|
||||
end
|
||||
|
||||
@ -191,10 +191,12 @@ module Homebrew
|
||||
end
|
||||
|
||||
def cask_reason(name, silent: false)
|
||||
return if silent
|
||||
cask = Cask::CaskLoader.load(name)
|
||||
return Cask::Cmd::Info.get_info(cask) unless silent
|
||||
rescue Cask::CaskUnavailableError
|
||||
nil
|
||||
reason = "Found the following cask named \"#{name}\" instead:\n"
|
||||
reason << Cask::Cmd::Info.get_info(cask) unless silent
|
||||
rescue Cask::CaskUnavailableError
|
||||
nil
|
||||
end
|
||||
|
||||
require "extend/os/missing_formula"
|
||||
|
||||
@ -23,17 +23,7 @@ describe "brew info", :integration_test do
|
||||
setup_remote_tap "homebrew/cask"
|
||||
|
||||
expect { brew "info", "firefox" }
|
||||
.to output(%r{Error:\sNo\savailable\sformula\swith\sthe\sname\s"firefox"\s\n
|
||||
firefox:\s\d+.?\d*\s\(auto_updates\)\n
|
||||
https:\/\/www.mozilla.org\/firefox\/\n
|
||||
Not\sinstalled\n
|
||||
.*\n
|
||||
==>\sName\n
|
||||
Mozilla\sFirefox\n
|
||||
==>\sLanguages\n
|
||||
.*\n
|
||||
==>\sArtifacts\n
|
||||
Firefox.app\s\(App\)\n}x).to_stderr
|
||||
.to output(/Found the following cask named "firefox" instead:\nfirefox: .+ \(auto_updates\)\n/).to_stderr
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user