Merge pull request #1885 from alyssais/remove_1.8.7

Remove some remnants of Ruby 1.8.7 support
This commit is contained in:
Alyssa Ross 2017-01-24 11:54:44 +00:00 committed by GitHub
commit 35045b2934
5 changed files with 37 additions and 14 deletions

View File

@ -1,17 +1,7 @@
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"
ENV["HOMEBREW_INSTALL_BADGE"] || "🍺"
end
def enabled?

View File

@ -3,7 +3,7 @@ require "tmpdir"
require "etc"
# Homebrew extends Ruby's `FileUtils` to make our code more readable.
# @see http://ruby-doc.org/stdlib-1.8.7/libdoc/fileutils/rdoc/FileUtils.html Ruby's FileUtils API
# @see http://ruby-doc.org/stdlib-2.0.0/libdoc/fileutils/rdoc/FileUtils.html Ruby's FileUtils API
module FileUtils
# Create a temporary directory then yield. When the block returns,
# recursively delete the temporary directory. Passing opts[:retain]

View File

@ -0,0 +1,11 @@
require "testing_env"
require "emoji"
class EmojiTest < Homebrew::TestCase
def test_install_badge
assert_equal "🍺", Emoji.install_badge
ENV["HOMEBREW_INSTALL_BADGE"] = "foo"
assert_equal "foo", Emoji.install_badge
end
end

View File

@ -9,6 +9,10 @@ class UtilTests < Homebrew::TestCase
@dir = Pathname.new(mktmpdir)
end
def esc(code)
/(\e\[\d+m)*\e\[#{code}m/
end
def test_ofail
shutup { ofail "foo" }
assert Homebrew.failed?
@ -22,11 +26,29 @@ class UtilTests < Homebrew::TestCase
end
def test_pretty_installed
$stdout.stubs(:tty?).returns true
ENV.delete("HOMEBREW_NO_EMOJI")
tty_with_emoji_output = /\A#{esc 1}foo #{esc 32}#{esc 0}\Z/
assert_match tty_with_emoji_output, pretty_installed("foo")
ENV["HOMEBREW_NO_EMOJI"] = "1"
tty_no_emoji_output = /\A#{esc 1}foo \(installed\)#{esc 0}\Z/
assert_match tty_no_emoji_output, pretty_installed("foo")
$stdout.stubs(:tty?).returns false
assert_equal "foo", pretty_installed("foo")
end
def test_pretty_uninstalled
$stdout.stubs(:tty?).returns true
ENV.delete("HOMEBREW_NO_EMOJI")
tty_with_emoji_output = /\A#{esc 1}foo #{esc 31}#{esc 0}\Z/
assert_match tty_with_emoji_output, pretty_uninstalled("foo")
ENV["HOMEBREW_NO_EMOJI"] = "1"
tty_no_emoji_output = /\A#{esc 1}foo \(uninstalled\)#{esc 0}\Z/
assert_match tty_no_emoji_output, pretty_uninstalled("foo")
$stdout.stubs(:tty?).returns false
assert_equal "foo", pretty_uninstalled("foo")
end

View File

@ -106,7 +106,7 @@ def pretty_installed(f)
if !$stdout.tty?
f.to_s
elsif Emoji.enabled?
"#{Tty.bold}#{f} #{Formatter.success(Emoji.tick)}#{Tty.reset}"
"#{Tty.bold}#{f} #{Formatter.success("")}#{Tty.reset}"
else
Formatter.success("#{Tty.bold}#{f} (installed)#{Tty.reset}")
end
@ -116,7 +116,7 @@ def pretty_uninstalled(f)
if !$stdout.tty?
f.to_s
elsif Emoji.enabled?
"#{Tty.bold}#{f} #{Formatter.error(Emoji.cross)}#{Tty.reset}"
"#{Tty.bold}#{f} #{Formatter.error("")}#{Tty.reset}"
else
Formatter.error("#{Tty.bold}#{f} (uninstalled)#{Tty.reset}")
end