Skip to content
Snippets Groups Projects
Commit a5ec0aa2 authored by Mike McQuaid's avatar Mike McQuaid Committed by GitHub
Browse files

emoji: extract logic into generic OS classes. (#450)

parent 4da99058
No related branches found
No related tags found
No related merge requests found
module Emoji
class << self
def tick
# necessary for 1.8.7 unicode handling since many installs are on 1.8.7
@tick ||= ["2714".hex].pack("U*")
end
def cross
# necessary for 1.8.7 unicode handling since many installs are on 1.8.7
@cross ||= ["2718".hex].pack("U*")
end
def install_badge
ENV["HOMEBREW_INSTALL_BADGE"] || "\xf0\x9f\x8d\xba"
end
def enabled?
!ENV["HOMEBREW_NO_EMOJI"]
end
alias generic_enabled? enabled?
end
end
require "extend/os/emoji"
require "os"
require "emoji"
if OS.mac?
require "extend/os/mac/emoji"
end
module Emoji
class << self
def enabled?
generic_enabled? && MacOS.version >= :lion
end
end
end
......@@ -13,6 +13,7 @@ require "hooks/bottles"
require "debrew"
require "sandbox"
require "requirements/cctools_requirement"
require "emoji"
class FormulaInstaller
include FormulaCellarChecks
......@@ -492,13 +493,9 @@ class FormulaInstaller
unlock
end
def emoji
ENV["HOMEBREW_INSTALL_BADGE"] || "\xf0\x9f\x8d\xba"
end
def summary
s = ""
s << "#{emoji} " if MacOS.version >= :lion && !ENV["HOMEBREW_NO_EMOJI"]
s << "#{Emoji.install_badge} " if Emoji.enabled?
s << "#{formula.prefix}: #{formula.prefix.abv}"
s << ", built in #{pretty_duration build_time}" if build_time
s
......
require "pathname"
require "emoji"
require "exceptions"
require "utils/hash"
require "utils/json"
......@@ -12,16 +13,6 @@ require "utils/curl"
class Tty
class << self
def tick
# necessary for 1.8.7 unicode handling since many installs are on 1.8.7
@tick ||= ["2714".hex].pack("U*")
end
def cross
# necessary for 1.8.7 unicode handling since many installs are on 1.8.7
@cross ||= ["2718".hex].pack("U*")
end
def strip_ansi(string)
string.gsub(/\033\[\d+(;\d+)*m/, "")
end
......@@ -124,20 +115,20 @@ end
def pretty_installed(f)
if !$stdout.tty?
"#{f}"
elsif ENV["HOMEBREW_NO_EMOJI"]
"#{Tty.highlight}#{Tty.green}#{f} (installed)#{Tty.reset}"
elsif Emoji.enabled?
"#{Tty.highlight}#{f} #{Tty.green}#{Emoji.tick}#{Tty.reset}"
else
"#{Tty.highlight}#{f} #{Tty.green}#{Tty.tick}#{Tty.reset}"
"#{Tty.highlight}#{Tty.green}#{f} (installed)#{Tty.reset}"
end
end
def pretty_uninstalled(f)
if !$stdout.tty?
"#{f}"
elsif ENV["HOMEBREW_NO_EMOJI"]
"#{Tty.red}#{f} (uninstalled)#{Tty.reset}"
elsif Emoji.enabled?
"#{f} #{Tty.red}#{Emoji.cross}#{Tty.reset}"
else
"#{f} #{Tty.red}#{Tty.cross}#{Tty.reset}"
"#{Tty.red}#{f} (uninstalled)#{Tty.reset}"
end
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment