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
|
end
|
||||||
|
|
||||||
def self.get_info(cask)
|
def self.get_info(cask)
|
||||||
<<~EOS.chomp
|
output = title_info(cask) + "\n"
|
||||||
#{title_info(cask)}
|
if cask.homepage then output << Formatter.url(cask.homepage) + "\n" end
|
||||||
#{Formatter.url(cask.homepage) if cask.homepage}
|
output << installation_info(cask)
|
||||||
#{installation_info(cask)}
|
repo = repo_info(cask)
|
||||||
#{repo_info(cask)}#{name_info(cask)}#{language_info(cask)}#{artifact_info(cask)}#{Installer.print_caveats(cask)}
|
output << repo unless repo.nil?
|
||||||
EOS
|
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
|
end
|
||||||
|
|
||||||
def self.info(cask)
|
def self.info(cask)
|
||||||
@ -64,9 +70,9 @@ module Cask
|
|||||||
).concat(")")
|
).concat(")")
|
||||||
install_info << "\n"
|
install_info << "\n"
|
||||||
end
|
end
|
||||||
return install_info.strip
|
install_info
|
||||||
else
|
else
|
||||||
"Not installed"
|
"Not installed\n"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -99,15 +105,14 @@ module Cask
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.artifact_info(cask)
|
def self.artifact_info(cask)
|
||||||
|
artifact_output = ohai_title("Artifacts")
|
||||||
cask.artifacts.each do |artifact|
|
cask.artifacts.each do |artifact|
|
||||||
next unless artifact.respond_to?(:install_phase)
|
next unless artifact.respond_to?(:install_phase)
|
||||||
next unless DSL::ORDINARY_ARTIFACT_CLASSES.include?(artifact.class)
|
next unless DSL::ORDINARY_ARTIFACT_CLASSES.include?(artifact.class)
|
||||||
|
|
||||||
return <<~EOS
|
artifact_output << "\n" << artifact.to_s
|
||||||
#{ohai_title("Artifacts")}
|
end
|
||||||
#{artifact}
|
artifact_output << "\n"
|
||||||
EOS
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -7,7 +7,7 @@ module Homebrew
|
|||||||
module MissingFormula
|
module MissingFormula
|
||||||
class << self
|
class << self
|
||||||
def reason(name, silent: false)
|
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)
|
tap_migration_reason(name) || deleted_reason(name, silent: silent)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -191,8 +191,10 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def cask_reason(name, silent: false)
|
def cask_reason(name, silent: false)
|
||||||
|
return if silent
|
||||||
cask = Cask::CaskLoader.load(name)
|
cask = Cask::CaskLoader.load(name)
|
||||||
return Cask::Cmd::Info.get_info(cask) unless silent
|
reason = "Found the following cask named \"#{name}\" instead:\n"
|
||||||
|
reason << Cask::Cmd::Info.get_info(cask) unless silent
|
||||||
rescue Cask::CaskUnavailableError
|
rescue Cask::CaskUnavailableError
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|||||||
@ -23,17 +23,7 @@ describe "brew info", :integration_test do
|
|||||||
setup_remote_tap "homebrew/cask"
|
setup_remote_tap "homebrew/cask"
|
||||||
|
|
||||||
expect { brew "info", "firefox" }
|
expect { brew "info", "firefox" }
|
||||||
.to output(%r{Error:\sNo\savailable\sformula\swith\sthe\sname\s"firefox"\s\n
|
.to output(/Found the following cask named "firefox" instead:\nfirefox: .+ \(auto_updates\)\n/).to_stderr
|
||||||
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
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user