aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMike McQuaid2016-08-26 10:05:35 +0100
committerGitHub2016-08-26 10:05:35 +0100
commit9c09f0573020e253e979af44d623ce049a4a2bd6 (patch)
tree860829f8cc0b02bb43f14b6542502286432fec08 /Library
parent373159deddc70589e94998abee8fe5cbf43a01ca (diff)
parent65579f27dd905e4026bb514f60e875cfc41cc368 (diff)
downloadbrew-9c09f0573020e253e979af44d623ce049a4a2bd6.tar.bz2
Merge pull request #794 from AnastasiaSulyagina/tty
cask tty removed
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cask/lib/hbc.rb1
-rw-r--r--Library/Homebrew/cask/lib/hbc/artifact/moved.rb2
-rw-r--r--Library/Homebrew/cask/lib/hbc/artifact/symlinked.rb2
-rw-r--r--Library/Homebrew/cask/lib/hbc/checkable.rb10
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli/doctor.rb4
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli/info.rb6
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli/style.rb2
-rw-r--r--Library/Homebrew/cask/lib/hbc/installer.rb2
-rw-r--r--Library/Homebrew/cask/lib/hbc/utils.rb12
-rw-r--r--Library/Homebrew/cask/lib/hbc/utils/tty.rb125
10 files changed, 20 insertions, 146 deletions
diff --git a/Library/Homebrew/cask/lib/hbc.rb b/Library/Homebrew/cask/lib/hbc.rb
index 29fad59af..b45a9f375 100644
--- a/Library/Homebrew/cask/lib/hbc.rb
+++ b/Library/Homebrew/cask/lib/hbc.rb
@@ -35,6 +35,7 @@ require "hbc/url_checker"
require "hbc/utils"
require "hbc/verify"
require "hbc/version"
+require "utils"
require "vendor/plist/plist"
diff --git a/Library/Homebrew/cask/lib/hbc/artifact/moved.rb b/Library/Homebrew/cask/lib/hbc/artifact/moved.rb
index c6b52f30f..8565ab836 100644
--- a/Library/Homebrew/cask/lib/hbc/artifact/moved.rb
+++ b/Library/Homebrew/cask/lib/hbc/artifact/moved.rb
@@ -80,7 +80,7 @@ class Hbc::Artifact::Moved < Hbc::Artifact::Relocated
target_abv = " (#{target.abv})"
else
warning = "Missing #{self.class.artifact_english_name}"
- warning = "#{Hbc::Utils::Tty.red.underline}#{warning}#{Hbc::Utils::Tty.reset}: "
+ warning = "#{Tty.red}#{warning}#{Tty.reset}: "
end
"#{warning}#{printable_target}#{target_abv}"
diff --git a/Library/Homebrew/cask/lib/hbc/artifact/symlinked.rb b/Library/Homebrew/cask/lib/hbc/artifact/symlinked.rb
index 749b0b98b..7432df577 100644
--- a/Library/Homebrew/cask/lib/hbc/artifact/symlinked.rb
+++ b/Library/Homebrew/cask/lib/hbc/artifact/symlinked.rb
@@ -57,7 +57,7 @@ class Hbc::Artifact::Symlinked < Hbc::Artifact::Relocated
return unless self.class.islink?(target)
- link_description = "#{Hbc::Utils::Tty.red.underline}Broken Link#{Hbc::Utils::Tty.reset}: " unless target.exist?
+ link_description = "#{Tty.red}Broken Link#{Tty.reset}: " unless target.exist?
target_readlink_abv = " (#{target.readlink.abv})" if target.readlink.exist?
"#{link_description}#{printable_target} -> #{target.readlink}#{target_readlink_abv}"
diff --git a/Library/Homebrew/cask/lib/hbc/checkable.rb b/Library/Homebrew/cask/lib/hbc/checkable.rb
index 630a3f063..9c12f80ca 100644
--- a/Library/Homebrew/cask/lib/hbc/checkable.rb
+++ b/Library/Homebrew/cask/lib/hbc/checkable.rb
@@ -27,11 +27,11 @@ module Hbc::Checkable
def result
if errors?
- "#{Hbc::Utils::Tty.red.underline}failed#{Hbc::Utils::Tty.reset}"
+ "#{Tty.red}failed#{Tty.reset}"
elsif warnings?
- "#{Hbc::Utils::Tty.yellow.underline}warning#{Hbc::Utils::Tty.reset}"
+ "#{Tty.yellow}warning#{Tty.reset}"
else
- "#{Hbc::Utils::Tty.green}passed#{Hbc::Utils::Tty.reset}"
+ "#{Tty.green}passed#{Tty.reset}"
end
end
@@ -39,11 +39,11 @@ module Hbc::Checkable
summary = ["#{summary_header}: #{result}"]
errors.each do |error|
- summary << " #{Hbc::Utils::Tty.red}-#{Hbc::Utils::Tty.reset} #{error}"
+ summary << " #{Tty.red}-#{Tty.reset} #{error}"
end
warnings.each do |warning|
- summary << " #{Hbc::Utils::Tty.yellow}-#{Hbc::Utils::Tty.reset} #{warning}"
+ summary << " #{Tty.yellow}-#{Tty.reset} #{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 57ab22e3e..857471420 100644
--- a/Library/Homebrew/cask/lib/hbc/cli/doctor.rb
+++ b/Library/Homebrew/cask/lib/hbc/cli/doctor.rb
@@ -124,11 +124,11 @@ class Hbc::CLI::Doctor < Hbc::CLI::Base
end
def self.notfound_string
- "#{Hbc::Utils::Tty.red.underline}Not Found - Unknown Error#{Hbc::Utils::Tty.reset}"
+ "#{Tty.red}Not Found - Unknown Error#{Tty.reset}"
end
def self.error_string(string = "Error")
- "#{Hbc::Utils::Tty.red.underline}(#{string})#{Hbc::Utils::Tty.reset}"
+ "#{Tty.red}(#{string})#{Tty.reset}"
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 dda405705..76f2d1366 100644
--- a/Library/Homebrew/cask/lib/hbc/cli/info.rb
+++ b/Library/Homebrew/cask/lib/hbc/cli/info.rb
@@ -25,7 +25,7 @@ class Hbc::CLI::Info < Hbc::CLI::Base
end
def self.formatted_url(url)
- "#{Hbc::Utils::Tty.underline}#{url}#{Hbc::Utils::Tty.reset}"
+ "#{Tty.em}#{url}#{Tty.reset}"
end
def self.installation_info(cask)
@@ -35,7 +35,7 @@ class Hbc::CLI::Info < Hbc::CLI::Base
puts versioned_staged_path.to_s
.concat(" (")
- .concat(versioned_staged_path.exist? ? versioned_staged_path.abv : "#{Hbc::Utils::Tty.red}does not exist#{Hbc::Utils::Tty.reset}")
+ .concat(versioned_staged_path.exist? ? versioned_staged_path.abv : "#{Tty.red}does not exist#{Tty.reset}")
.concat(")")
end
else
@@ -45,7 +45,7 @@ class Hbc::CLI::Info < Hbc::CLI::Base
def self.name_info(cask)
ohai cask.name.size > 1 ? "Names" : "Name"
- puts cask.name.empty? ? "#{Hbc::Utils::Tty.red}None#{Hbc::Utils::Tty.reset}" : cask.name
+ puts cask.name.empty? ? "#{Tty.red}None#{Tty.reset}" : cask.name
end
def self.github_info(cask)
diff --git a/Library/Homebrew/cask/lib/hbc/cli/style.rb b/Library/Homebrew/cask/lib/hbc/cli/style.rb
index ac7cbfb44..8793d2afd 100644
--- a/Library/Homebrew/cask/lib/hbc/cli/style.rb
+++ b/Library/Homebrew/cask/lib/hbc/cli/style.rb
@@ -28,7 +28,7 @@ class Hbc::CLI::Style < Hbc::CLI::Base
begin
Homebrew.install_gem_setup_path! "rubocop-cask", RUBOCOP_CASK_VERSION, "rubocop"
rescue SystemExit
- raise Hbc::CaskError, $stderr.string.chomp.sub("#{::Tty.red}Error#{::Tty.reset}: ", "")
+ raise Hbc::CaskError, $stderr.string.chomp.sub("#{Tty.red}Error#{Tty.reset}: ", "")
end
end
end
diff --git a/Library/Homebrew/cask/lib/hbc/installer.rb b/Library/Homebrew/cask/lib/hbc/installer.rb
index 8f43884a3..72a9b3077 100644
--- a/Library/Homebrew/cask/lib/hbc/installer.rb
+++ b/Library/Homebrew/cask/lib/hbc/installer.rb
@@ -86,7 +86,7 @@ class Hbc::Installer
s = if MacOS.version >= :lion && !ENV["HOMEBREW_NO_EMOJI"]
(ENV["HOMEBREW_INSTALL_BADGE"] || "\xf0\x9f\x8d\xba") + " "
else
- "#{Hbc::Utils::Tty.blue.bold}==>#{Hbc::Utils::Tty.reset.bold} Success!#{Hbc::Utils::Tty.reset} "
+ "#{Tty.blue}==>#{Tty.reset} #{Tty.white}Success!#{Tty.reset} "
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 6fc52cc93..e151b0c1e 100644
--- a/Library/Homebrew/cask/lib/hbc/utils.rb
+++ b/Library/Homebrew/cask/lib/hbc/utils.rb
@@ -5,7 +5,6 @@ require "open3"
require "stringio"
require "hbc/utils/file"
-require "hbc/utils/tty"
UPDATE_CMD = "brew uninstall --force brew-cask; brew untap phinze/cask; brew untap caskroom/cask; brew update; brew cleanup; brew cask cleanup".freeze
ISSUES_URL = "https://github.com/caskroom/homebrew-cask#reporting-bugs".freeze
@@ -34,11 +33,11 @@ end
def odebug(title, *sput)
if Hbc.respond_to?(:debug) && Hbc.debug
- width = Hbc::Utils::Tty.width * 4 - 6
+ width = Tty.width * 4 - 6
if $stdout.tty? && title.to_s.length > width
title = title.to_s[0, width - 3] + "..."
end
- puts "#{Hbc::Utils::Tty.magenta.bold}==>#{Hbc::Utils::Tty.reset.bold} #{title}#{Hbc::Utils::Tty.reset}"
+ puts "#{Tty.magenta}==> #{title}#{Tty.reset}"
puts sput unless sput.empty?
end
end
@@ -151,14 +150,13 @@ module Hbc::Utils
def self.error_message_with_suggestions
<<-EOS.undent
- #{Hbc::Utils::Tty.reset.bold}
Most likely, this means you have an outdated version of Homebrew-Cask. Please run:
- #{Hbc::Utils::Tty.green.normal}#{UPDATE_CMD}
+ #{Tty.green}#{UPDATE_CMD}
- #{Hbc::Utils::Tty.reset.bold}If this doesn’t fix the problem, please report this bug:
+ #{Tty.reset}If this doesn’t fix the problem, please report this bug:
- #{Hbc::Utils::Tty.underline}#{ISSUES_URL}#{Hbc::Utils::Tty.reset}
+ #{Tty.em}#{ISSUES_URL}#{Tty.reset}
EOS
end
diff --git a/Library/Homebrew/cask/lib/hbc/utils/tty.rb b/Library/Homebrew/cask/lib/hbc/utils/tty.rb
deleted file mode 100644
index c383df828..000000000
--- a/Library/Homebrew/cask/lib/hbc/utils/tty.rb
+++ /dev/null
@@ -1,125 +0,0 @@
-# originally from Homebrew utils.rb
-
-class Hbc::Utils::Tty
- COLORS = {
- black: 0,
- red: 1,
- green: 2,
- yellow: 3,
- blue: 4,
- magenta: 5,
- cyan: 6,
- white: 7,
- default: 9,
- }.freeze
-
- ATTRIBUTES = {
- reset: 0,
- bold: 1,
- dim: 2,
- italic: 3,
- underline: 4,
- blink: 5,
- inverse: 7,
- invisible: 8,
- strikethrough: 9,
- normal: 22,
- }.freeze
-
- @sequence = []
-
- class << self
- COLORS.keys.each do |sym|
- define_method(sym) do
- foreground(COLORS[sym])
- end
- define_method("fg_#{sym}".to_sym) do
- foreground(COLORS[sym])
- end
- define_method("bg_#{sym}".to_sym) do
- background(COLORS[sym])
- end
- end
-
- ATTRIBUTES.keys.each do |sym|
- define_method(sym) do
- deferred_emit(ATTRIBUTES[sym])
- end
- end
-
- def width
- `/usr/bin/tput cols`.strip.to_i
- end
-
- def truncate(str)
- str.to_s[0, width - 4]
- end
-
- private
-
- def foreground(color)
- deferred_emit(to_foreground_code(color))
- end
-
- def background(color)
- deferred_emit(to_background_code(color))
- end
-
- def to_color_code(space, color)
- return unless (num = to_color_number(color))
- return space + num if num < space
- return space + 9 if num > space
- num
- end
-
- def to_foreground_code(color)
- to_color_code(30, color)
- end
-
- def to_background_code(color)
- to_color_code(40, color)
- end
-
- def to_color_number(color)
- COLORS[color] || color.is_a?(Integer) ? color : nil
- end
-
- def to_attribute_number(attribute)
- ATTRIBUTES[attribute] || attribute.is_a?(Integer) ? attribute : nil
- end
-
- def sanitize_integer(arg)
- return arg.to_i if arg.is_a?(Integer)
- return 0 if arg.to_s =~ %r{^0+$}
- if arg.respond_to?(:to_i) && (int = arg.to_i) > 0
- return int
- end
- $stderr.puts "Warning: bad Tty code #{arg}"
- ATTRIBUTES[:reset]
- end
-
- def deferred_emit(*codes)
- @sequence.concat Array(*codes).map(&method(:sanitize_integer))
- Hbc::Utils::Tty
- end
-
- def to_s
- sequence = @sequence
- @sequence = []
- return "" unless $stdout.tty?
- if sequence.empty?
- $stderr.puts "Warning: empty Tty sequence"
- sequence = [ATTRIBUTES[:reset]]
- end
- "#{initiate}#{sequence.join(';')}#{terminate}"
- end
-
- def initiate
- "\033["
- end
-
- def terminate
- "m"
- end
- end
-end