Rename enumeration
to comma_and
.
This commit is contained in:
parent
785750ee63
commit
c6c1eacc18
@ -284,7 +284,7 @@ class Tap
|
||||
|
||||
link_completions_and_manpages
|
||||
|
||||
formatted_contents = Formatter.enumeration(*contents)&.prepend(" ")
|
||||
formatted_contents = Formatter.comma_and(*contents)&.prepend(" ")
|
||||
puts "Tapped#{formatted_contents} (#{path.abv})." unless quiet
|
||||
Descriptions.cache_formulae(formula_names)
|
||||
|
||||
@ -314,7 +314,7 @@ class Tap
|
||||
puts "Untapping #{name}..."
|
||||
|
||||
abv = path.abv
|
||||
formatted_contents = Formatter.enumeration(*contents)&.prepend(" ")
|
||||
formatted_contents = Formatter.comma_and(*contents)&.prepend(" ")
|
||||
|
||||
unpin if pinned?
|
||||
Descriptions.uncache_formulae(formula_names)
|
||||
|
@ -77,21 +77,21 @@ describe Formatter do
|
||||
end
|
||||
end
|
||||
|
||||
describe "::enumeration" do
|
||||
describe "::comma_and" do
|
||||
it "returns nil if given no arguments" do
|
||||
expect(described_class.enumeration).to be nil
|
||||
expect(described_class.comma_and).to be nil
|
||||
end
|
||||
|
||||
it "returns the input as string if there is only one argument" do
|
||||
expect(described_class.enumeration(1)).to eq("1")
|
||||
expect(described_class.comma_and(1)).to eq("1")
|
||||
end
|
||||
|
||||
it "concatenates two items with “and”" do
|
||||
expect(described_class.enumeration(1, 2)).to eq("1 and 2")
|
||||
expect(described_class.comma_and(1, 2)).to eq("1 and 2")
|
||||
end
|
||||
|
||||
it "concatenates all items with a comma and appends the last with “and”" do
|
||||
expect(described_class.enumeration(1, 2, 3)).to eq("1, 2 and 3")
|
||||
expect(described_class.comma_and(1, 2, 3)).to eq("1, 2 and 3")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -109,7 +109,7 @@ module Formatter
|
||||
show_count ? "#{count} #{words}" : words
|
||||
end
|
||||
|
||||
def enumeration(*items)
|
||||
def comma_and(*items)
|
||||
*items, last = items.map(&:to_s)
|
||||
return last if items.empty?
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user