aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew
diff options
context:
space:
mode:
authorAlyssa Ross2017-01-24 11:54:44 +0000
committerGitHub2017-01-24 11:54:44 +0000
commit35045b2934d94eabe302693a05b12fb530827454 (patch)
treeb092a10a239b638a8bf361568a1e2484081b9164 /Library/Homebrew
parent714c1013f458855458af62a96479da8651408de5 (diff)
parent5480a84114243fcd0aedda3a650b23b59ae91b2c (diff)
downloadbrew-35045b2934d94eabe302693a05b12fb530827454.tar.bz2
Merge pull request #1885 from alyssais/remove_1.8.7
Remove some remnants of Ruby 1.8.7 support
Diffstat (limited to 'Library/Homebrew')
-rw-r--r--Library/Homebrew/emoji.rb12
-rw-r--r--Library/Homebrew/extend/fileutils.rb2
-rw-r--r--Library/Homebrew/test/emoji_test.rb11
-rw-r--r--Library/Homebrew/test/utils_test.rb22
-rw-r--r--Library/Homebrew/utils.rb4
5 files changed, 37 insertions, 14 deletions
diff --git a/Library/Homebrew/emoji.rb b/Library/Homebrew/emoji.rb
index 8c58ca895..43fa781e6 100644
--- a/Library/Homebrew/emoji.rb
+++ b/Library/Homebrew/emoji.rb
@@ -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?
diff --git a/Library/Homebrew/extend/fileutils.rb b/Library/Homebrew/extend/fileutils.rb
index 4f20d36a3..287a1408f 100644
--- a/Library/Homebrew/extend/fileutils.rb
+++ b/Library/Homebrew/extend/fileutils.rb
@@ -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]
diff --git a/Library/Homebrew/test/emoji_test.rb b/Library/Homebrew/test/emoji_test.rb
new file mode 100644
index 000000000..ea68db8f6
--- /dev/null
+++ b/Library/Homebrew/test/emoji_test.rb
@@ -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
diff --git a/Library/Homebrew/test/utils_test.rb b/Library/Homebrew/test/utils_test.rb
index 520cd4fcd..1f2fb7b55 100644
--- a/Library/Homebrew/test/utils_test.rb
+++ b/Library/Homebrew/test/utils_test.rb
@@ -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
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb
index 614d50eea..70d2787d9 100644
--- a/Library/Homebrew/utils.rb
+++ b/Library/Homebrew/utils.rb
@@ -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