Deprecate #plural.

This commit is contained in:
Markus Reiter 2017-03-11 11:31:44 +01:00
parent 00306a4ced
commit 44d367edca
4 changed files with 8 additions and 16 deletions

View File

@ -21,3 +21,8 @@ def puts_columns(items)
odeprecated "puts_columns", "puts Formatter.columns" odeprecated "puts_columns", "puts Formatter.columns"
puts Formatter.columns(items) puts Formatter.columns(items)
end end
def plural(n, s = "s")
odeprecated "#plural", "Formatter.pluralize"
n == 1 ? "" : s
end

View File

@ -219,13 +219,6 @@ describe "globally-scoped helper methods" do
end end
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 specify "#disk_usage_readable" do
expect(disk_usage_readable(1)).to eq("1B") expect(disk_usage_readable(1)).to eq("1B")
expect(disk_usage_readable(1000)).to eq("1000B") expect(disk_usage_readable(1000)).to eq("1000B")

View File

@ -139,10 +139,6 @@ def pretty_duration(s)
res << Formatter.pluralize(s, "second") res << Formatter.pluralize(s, "second")
end end
def plural(n, s = "s")
n == 1 ? "" : s
end
def interactive_shell(f = nil) def interactive_shell(f = nil)
unless f.nil? unless f.nil?
ENV["HOMEBREW_DEBUG_PREFIX"] = f.prefix ENV["HOMEBREW_DEBUG_PREFIX"] = f.prefix

View File

@ -96,11 +96,9 @@ module Formatter
*adjectives, noun = singular.split(" ") *adjectives, noun = singular.split(" ")
if plural.nil? plural ||= {
plural = { "formula" => "formulae",
"formula" => "formulae", }.fetch(noun, "#{noun}s")
}.fetch(noun, "#{noun}s")
end
words = adjectives << plural words = adjectives << plural