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