From c6c1eacc18de6ad9580aeb43d4f2d90f9ad4c5bb Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sun, 1 Jul 2018 01:35:47 +0200 Subject: [PATCH] Rename `enumeration` to `comma_and`. --- Library/Homebrew/tap.rb | 4 ++-- Library/Homebrew/test/formatter_spec.rb | 10 +++++----- Library/Homebrew/utils/formatter.rb | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb index 83eb197c32..5f7d691bff 100644 --- a/Library/Homebrew/tap.rb +++ b/Library/Homebrew/tap.rb @@ -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) diff --git a/Library/Homebrew/test/formatter_spec.rb b/Library/Homebrew/test/formatter_spec.rb index 8d5ca8f41a..1c97bf6f8f 100644 --- a/Library/Homebrew/test/formatter_spec.rb +++ b/Library/Homebrew/test/formatter_spec.rb @@ -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 diff --git a/Library/Homebrew/utils/formatter.rb b/Library/Homebrew/utils/formatter.rb index e6bdf6f034..4db1abf54d 100644 --- a/Library/Homebrew/utils/formatter.rb +++ b/Library/Homebrew/utils/formatter.rb @@ -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?