diff options
| author | Markus Reiter | 2016-08-30 21:38:13 +0200 |
|---|---|---|
| committer | Markus Reiter | 2016-10-01 20:00:49 +0200 |
| commit | 75e8b59aad4814112a53119f68ed629d60b3f97b (patch) | |
| tree | adca80e4cbeb07c208d9ea1b7b203bec653fb815 /Library/Homebrew/cask/lib/hbc | |
| parent | 6d8ee395fa5878282a1ce3975b632103448be042 (diff) | |
| download | brew-75e8b59aad4814112a53119f68ed629d60b3f97b.tar.bz2 | |
Add `Formatter` module.
Diffstat (limited to 'Library/Homebrew/cask/lib/hbc')
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/artifact/moved.rb | 6 | ||||
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/artifact/symlinked.rb | 15 | ||||
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/checkable.rb | 10 | ||||
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/cli/doctor.rb | 4 | ||||
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/cli/info.rb | 8 | ||||
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/installer.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/utils.rb | 8 |
7 files changed, 27 insertions, 26 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/artifact/moved.rb b/Library/Homebrew/cask/lib/hbc/artifact/moved.rb index ff6e5f273..22124005c 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/moved.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/moved.rb @@ -79,12 +79,10 @@ module Hbc load_specification artifact_spec if target.exist? - target_abv = " (#{target.abv})" + "#{printable_target} (#{target.abv})" else - error = "#{Tty.red}Missing #{self.class.artifact_english_name}:#{Tty.reset} " + Formatter.error(printable_target, label: "Missing #{self.class.artifact_english_name}") end - - "#{error}#{printable_target}#{target_abv}" end end end diff --git a/Library/Homebrew/cask/lib/hbc/artifact/symlinked.rb b/Library/Homebrew/cask/lib/hbc/artifact/symlinked.rb index 3ab45cccc..46dd42322 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/symlinked.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/symlinked.rb @@ -57,12 +57,17 @@ module Hbc def summarize_artifact(artifact_spec) load_specification artifact_spec - return unless self.class.islink?(target) - - link_description = "#{Tty.red}Broken Link#{Tty.reset}: " unless target.exist? - target_readlink_abv = " (#{target.readlink.abv})" if target.readlink.exist? + if self.class.islink?(target) && target.exist? && target.readlink.exist? + "#{printable_target} -> #{target.readlink} (#{target.readlink.abv})" + else + string = if self.class.islink?(target) + "#{printable_target} -> #{target.readlink}" + else + printable_target + end - "#{link_description}#{printable_target} -> #{target.readlink}#{target_readlink_abv}" + Formatter.error(string, label: "Broken Link") + end end end end diff --git a/Library/Homebrew/cask/lib/hbc/checkable.rb b/Library/Homebrew/cask/lib/hbc/checkable.rb index 42c47ea78..03f052629 100644 --- a/Library/Homebrew/cask/lib/hbc/checkable.rb +++ b/Library/Homebrew/cask/lib/hbc/checkable.rb @@ -28,11 +28,11 @@ module Hbc def result if errors? - "#{Tty.red}failed#{Tty.reset}" + Formatter.error("failed") elsif warnings? - "#{Tty.yellow}warning#{Tty.reset}" + Formatter.warning("warning") else - "#{Tty.green}passed#{Tty.reset}" + Formatter.success("passed") end end @@ -40,11 +40,11 @@ module Hbc summary = ["#{summary_header}: #{result}"] errors.each do |error| - summary << " #{Tty.red}-#{Tty.reset} #{error}" + summary << " #{Formatter.error("-")} #{error}" end warnings.each do |warning| - summary << " #{Tty.yellow}-#{Tty.reset} #{warning}" + summary << " #{Formatter.warning("-")} #{warning}" end summary.join("\n") diff --git a/Library/Homebrew/cask/lib/hbc/cli/doctor.rb b/Library/Homebrew/cask/lib/hbc/cli/doctor.rb index 34f000b29..e36999200 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/doctor.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/doctor.rb @@ -122,11 +122,11 @@ module Hbc end def self.notfound_string - "#{Tty.red}Not Found - Unknown Error#{Tty.reset}" + Formatter.error("Not Found - Unknown Error") end def self.error_string(string = "Error") - "#{Tty.red}(#{string})#{Tty.reset}" + Formatter.error("(#{string})") end def self.render_with_none(string) diff --git a/Library/Homebrew/cask/lib/hbc/cli/info.rb b/Library/Homebrew/cask/lib/hbc/cli/info.rb index e2f360296..0957ba4fd 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/info.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/info.rb @@ -18,9 +18,9 @@ module Hbc def self.info(cask) puts "#{cask.token}: #{cask.version}" - puts formatted_url(cask.homepage) if cask.homepage + puts Formatter.url(cask.homepage) if cask.homepage installation_info(cask) - puts "From: #{formatted_url(github_info(cask))}" if github_info(cask) + puts "From: #{Formatter.url(github_info(cask))}" if github_info(cask) name_info(cask) artifact_info(cask) Installer.print_caveats(cask) @@ -37,7 +37,7 @@ module Hbc puts versioned_staged_path.to_s .concat(" (") - .concat(versioned_staged_path.exist? ? versioned_staged_path.abv : "#{Tty.red}does not exist#{Tty.reset}") + .concat(versioned_staged_path.exist? ? versioned_staged_path.abv : Formatter.error("does not exist")) .concat(")") end else @@ -47,7 +47,7 @@ module Hbc def self.name_info(cask) ohai cask.name.size > 1 ? "Names" : "Name" - puts cask.name.empty? ? "#{Tty.red}None#{Tty.reset}" : cask.name + puts cask.name.empty? ? Formatter.error("None") : cask.name end def self.github_info(cask) diff --git a/Library/Homebrew/cask/lib/hbc/installer.rb b/Library/Homebrew/cask/lib/hbc/installer.rb index 1002be460..4d29acb75 100644 --- a/Library/Homebrew/cask/lib/hbc/installer.rb +++ b/Library/Homebrew/cask/lib/hbc/installer.rb @@ -87,7 +87,7 @@ module Hbc s = if MacOS.version >= :lion && !ENV["HOMEBREW_NO_EMOJI"] (ENV["HOMEBREW_INSTALL_BADGE"] || "\xf0\x9f\x8d\xba") + " " else - "#{Tty.blue}==>#{Tty.reset} #{Tty.bold}Success!#{Tty.reset} " + Formatter.headline("Success! ", color: :blue) end s << "#{@cask} was successfully installed!" end diff --git a/Library/Homebrew/cask/lib/hbc/utils.rb b/Library/Homebrew/cask/lib/hbc/utils.rb index c6a970fca..d42d78ef7 100644 --- a/Library/Homebrew/cask/lib/hbc/utils.rb +++ b/Library/Homebrew/cask/lib/hbc/utils.rb @@ -32,7 +32,7 @@ end def odebug(title, *sput) return unless Hbc.respond_to?(:debug) return unless Hbc.debug - puts "#{Tty.magenta}==>#{Tty.reset} #{Tty.white}#{title}#{Tty.reset}" + puts Formatter.headline(title, color: :magenta) puts sput unless sput.empty? end @@ -146,12 +146,10 @@ module Hbc def self.error_message_with_suggestions <<-EOS.undent Most likely, this means you have an outdated version of Homebrew-Cask. Please run: - - #{Tty.green}#{UPDATE_CMD}#{Tty.reset} + #{UPDATE_CMD} If this doesn’t fix the problem, please report this bug: - - #{Tty.underline}#{ISSUES_URL}#{Tty.reset} + #{Formatter.url(ISSUES_URL)} EOS end |
