Merge pull request #1885 from alyssais/remove_1.8.7
Remove some remnants of Ruby 1.8.7 support
This commit is contained in:
commit
35045b2934
@ -1,17 +1,7 @@
|
|||||||
module Emoji
|
module Emoji
|
||||||
class << self
|
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
|
def install_badge
|
||||||
ENV["HOMEBREW_INSTALL_BADGE"] || "\xf0\x9f\x8d\xba"
|
ENV["HOMEBREW_INSTALL_BADGE"] || "🍺"
|
||||||
end
|
end
|
||||||
|
|
||||||
def enabled?
|
def enabled?
|
||||||
|
@ -3,7 +3,7 @@ require "tmpdir"
|
|||||||
require "etc"
|
require "etc"
|
||||||
|
|
||||||
# Homebrew extends Ruby's `FileUtils` to make our code more readable.
|
# 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
|
module FileUtils
|
||||||
# Create a temporary directory then yield. When the block returns,
|
# Create a temporary directory then yield. When the block returns,
|
||||||
# recursively delete the temporary directory. Passing opts[:retain]
|
# recursively delete the temporary directory. Passing opts[:retain]
|
||||||
|
11
Library/Homebrew/test/emoji_test.rb
Normal file
11
Library/Homebrew/test/emoji_test.rb
Normal 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
|
@ -9,6 +9,10 @@ class UtilTests < Homebrew::TestCase
|
|||||||
@dir = Pathname.new(mktmpdir)
|
@dir = Pathname.new(mktmpdir)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def esc(code)
|
||||||
|
/(\e\[\d+m)*\e\[#{code}m/
|
||||||
|
end
|
||||||
|
|
||||||
def test_ofail
|
def test_ofail
|
||||||
shutup { ofail "foo" }
|
shutup { ofail "foo" }
|
||||||
assert Homebrew.failed?
|
assert Homebrew.failed?
|
||||||
@ -22,11 +26,29 @@ class UtilTests < Homebrew::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_pretty_installed
|
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
|
$stdout.stubs(:tty?).returns false
|
||||||
assert_equal "foo", pretty_installed("foo")
|
assert_equal "foo", pretty_installed("foo")
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_pretty_uninstalled
|
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
|
$stdout.stubs(:tty?).returns false
|
||||||
assert_equal "foo", pretty_uninstalled("foo")
|
assert_equal "foo", pretty_uninstalled("foo")
|
||||||
end
|
end
|
||||||
|
@ -106,7 +106,7 @@ def pretty_installed(f)
|
|||||||
if !$stdout.tty?
|
if !$stdout.tty?
|
||||||
f.to_s
|
f.to_s
|
||||||
elsif Emoji.enabled?
|
elsif Emoji.enabled?
|
||||||
"#{Tty.bold}#{f} #{Formatter.success(Emoji.tick)}#{Tty.reset}"
|
"#{Tty.bold}#{f} #{Formatter.success("✔")}#{Tty.reset}"
|
||||||
else
|
else
|
||||||
Formatter.success("#{Tty.bold}#{f} (installed)#{Tty.reset}")
|
Formatter.success("#{Tty.bold}#{f} (installed)#{Tty.reset}")
|
||||||
end
|
end
|
||||||
@ -116,7 +116,7 @@ def pretty_uninstalled(f)
|
|||||||
if !$stdout.tty?
|
if !$stdout.tty?
|
||||||
f.to_s
|
f.to_s
|
||||||
elsif Emoji.enabled?
|
elsif Emoji.enabled?
|
||||||
"#{Tty.bold}#{f} #{Formatter.error(Emoji.cross)}#{Tty.reset}"
|
"#{Tty.bold}#{f} #{Formatter.error("✘")}#{Tty.reset}"
|
||||||
else
|
else
|
||||||
Formatter.error("#{Tty.bold}#{f} (uninstalled)#{Tty.reset}")
|
Formatter.error("#{Tty.bold}#{f} (uninstalled)#{Tty.reset}")
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user