aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMarkus Reiter2017-03-11 11:31:44 +0100
committerMarkus Reiter2017-03-11 21:16:37 +0100
commit44d367edca03acaa737a3156d05bf462f79f0fc3 (patch)
tree0c6716cdd000e2f45f823450faecf798db957426 /Library
parent00306a4ced339f9bf2384a4fd94b26530995dd6c (diff)
downloadbrew-44d367edca03acaa737a3156d05bf462f79f0fc3.tar.bz2
Deprecate `#plural`.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/compat/utils.rb5
-rw-r--r--Library/Homebrew/test/utils_spec.rb7
-rw-r--r--Library/Homebrew/utils.rb4
-rw-r--r--Library/Homebrew/utils/formatter.rb8
4 files changed, 8 insertions, 16 deletions
diff --git a/Library/Homebrew/compat/utils.rb b/Library/Homebrew/compat/utils.rb
index ed6063472..56b0824ba 100644
--- a/Library/Homebrew/compat/utils.rb
+++ b/Library/Homebrew/compat/utils.rb
@@ -21,3 +21,8 @@ def puts_columns(items)
odeprecated "puts_columns", "puts Formatter.columns"
puts Formatter.columns(items)
end
+
+def plural(n, s = "s")
+ odeprecated "#plural", "Formatter.pluralize"
+ n == 1 ? "" : s
+end
diff --git a/Library/Homebrew/test/utils_spec.rb b/Library/Homebrew/test/utils_spec.rb
index 90eed7d88..314c299a8 100644
--- a/Library/Homebrew/test/utils_spec.rb
+++ b/Library/Homebrew/test/utils_spec.rb
@@ -219,13 +219,6 @@ describe "globally-scoped helper methods" do
end
end
- specify "#plural" do
- expect(plural(1)).to eq("")
- expect(plural(0)).to eq("s")
- expect(plural(42)).to eq("s")
- expect(plural(42, "")).to eq("")
- end
-
specify "#disk_usage_readable" do
expect(disk_usage_readable(1)).to eq("1B")
expect(disk_usage_readable(1000)).to eq("1000B")
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb
index d9f2ac895..46a8cc68e 100644
--- a/Library/Homebrew/utils.rb
+++ b/Library/Homebrew/utils.rb
@@ -139,10 +139,6 @@ def pretty_duration(s)
res << Formatter.pluralize(s, "second")
end
-def plural(n, s = "s")
- n == 1 ? "" : s
-end
-
def interactive_shell(f = nil)
unless f.nil?
ENV["HOMEBREW_DEBUG_PREFIX"] = f.prefix
diff --git a/Library/Homebrew/utils/formatter.rb b/Library/Homebrew/utils/formatter.rb
index 88616c6f8..099b1c6d3 100644
--- a/Library/Homebrew/utils/formatter.rb
+++ b/Library/Homebrew/utils/formatter.rb
@@ -96,11 +96,9 @@ module Formatter
*adjectives, noun = singular.split(" ")
- if plural.nil?
- plural = {
- "formula" => "formulae",
- }.fetch(noun, "#{noun}s")
- end
+ plural ||= {
+ "formula" => "formulae",
+ }.fetch(noun, "#{noun}s")
words = adjectives << plural