From b3522b3bb8986702d011d2c3340ec097de191b11 Mon Sep 17 00:00:00 2001 From: Douglas Eichelberger Date: Tue, 2 Jan 2024 16:54:18 -0800 Subject: [PATCH] Remove ActiveSupport String filters --- .gitignore | 1 - Library/Homebrew/completions.rb | 2 +- Library/Homebrew/global.rb | 1 - Library/Homebrew/utils/gems.rb | 2 +- .../active_support/core_ext/string/filters.rb | 145 ------------------ 5 files changed, 2 insertions(+), 149 deletions(-) delete mode 100644 Library/Homebrew/vendor/bundle/ruby/3.1.0/gems/activesupport-6.1.7.6/lib/active_support/core_ext/string/filters.rb diff --git a/.gitignore b/.gitignore index 205be86300c69..ea397973de444 100644 --- a/.gitignore +++ b/.gitignore @@ -72,7 +72,6 @@ !**/vendor/bundle/ruby/*/gems/activesupport-*/lib/active_support/core_ext/object/deep_dup.rb !**/vendor/bundle/ruby/*/gems/activesupport-*/lib/active_support/core_ext/object/duplicable.rb !**/vendor/bundle/ruby/*/gems/activesupport-*/lib/active_support/core_ext/string/exclude.rb -!**/vendor/bundle/ruby/*/gems/activesupport-*/lib/active_support/core_ext/string/filters.rb !**/vendor/bundle/ruby/*/gems/activesupport-*/lib/active_support/core_ext/string/indent.rb # Ignore partially included gems where we don't need all files diff --git a/Library/Homebrew/completions.rb b/Library/Homebrew/completions.rb index b61499a6e83ca..beafe9df8e487 100644 --- a/Library/Homebrew/completions.rb +++ b/Library/Homebrew/completions.rb @@ -155,7 +155,7 @@ def self.command_options(command) name = option.first desc = option.second if name.start_with? "--[no-]" - options[name.remove("[no-]")] = desc + options[name.gsub("[no-]", "")] = desc options[name.sub("[no-]", "no-")] = desc else options[name] = desc diff --git a/Library/Homebrew/global.rb b/Library/Homebrew/global.rb index 3f6f878341e87..fb76398eebbb6 100644 --- a/Library/Homebrew/global.rb +++ b/Library/Homebrew/global.rb @@ -18,7 +18,6 @@ require "active_support/core_ext/hash/deep_merge" require "active_support/core_ext/hash/keys" require "active_support/core_ext/string/exclude" -require "active_support/core_ext/string/filters" require "active_support/core_ext/string/indent" HOMEBREW_API_DEFAULT_DOMAIN = ENV.fetch("HOMEBREW_API_DEFAULT_DOMAIN").freeze diff --git a/Library/Homebrew/utils/gems.rb b/Library/Homebrew/utils/gems.rb index 60320d17e44b5..c6762c4985651 100644 --- a/Library/Homebrew/utils/gems.rb +++ b/Library/Homebrew/utils/gems.rb @@ -14,7 +14,7 @@ module Homebrew # Bump this whenever a committed vendored gem is later added to gitignore. # This will trigger it to reinstall properly if `brew install-bundler-gems` needs it. - VENDOR_VERSION = 3 + VENDOR_VERSION = 4 private_constant :VENDOR_VERSION RUBY_BUNDLE_VENDOR_DIRECTORY = (HOMEBREW_LIBRARY_PATH/"vendor/bundle/ruby").freeze diff --git a/Library/Homebrew/vendor/bundle/ruby/3.1.0/gems/activesupport-6.1.7.6/lib/active_support/core_ext/string/filters.rb b/Library/Homebrew/vendor/bundle/ruby/3.1.0/gems/activesupport-6.1.7.6/lib/active_support/core_ext/string/filters.rb deleted file mode 100644 index 7f28bd52f244a..0000000000000 --- a/Library/Homebrew/vendor/bundle/ruby/3.1.0/gems/activesupport-6.1.7.6/lib/active_support/core_ext/string/filters.rb +++ /dev/null @@ -1,145 +0,0 @@ -# frozen_string_literal: true - -class String - # Returns the string, first removing all whitespace on both ends of - # the string, and then changing remaining consecutive whitespace - # groups into one space each. - # - # Note that it handles both ASCII and Unicode whitespace. - # - # %{ Multi-line - # string }.squish # => "Multi-line string" - # " foo bar \n \t boo".squish # => "foo bar boo" - def squish - dup.squish! - end - - # Performs a destructive squish. See String#squish. - # str = " foo bar \n \t boo" - # str.squish! # => "foo bar boo" - # str # => "foo bar boo" - def squish! - gsub!(/[[:space:]]+/, " ") - strip! - self - end - - # Returns a new string with all occurrences of the patterns removed. - # str = "foo bar test" - # str.remove(" test") # => "foo bar" - # str.remove(" test", /bar/) # => "foo " - # str # => "foo bar test" - def remove(*patterns) - dup.remove!(*patterns) - end - - # Alters the string by removing all occurrences of the patterns. - # str = "foo bar test" - # str.remove!(" test", /bar/) # => "foo " - # str # => "foo " - def remove!(*patterns) - patterns.each do |pattern| - gsub! pattern, "" - end - - self - end - - # Truncates a given +text+ after a given length if +text+ is longer than length: - # - # 'Once upon a time in a world far far away'.truncate(27) - # # => "Once upon a time in a wo..." - # - # Pass a string or regexp :separator to truncate +text+ at a natural break: - # - # 'Once upon a time in a world far far away'.truncate(27, separator: ' ') - # # => "Once upon a time in a..." - # - # 'Once upon a time in a world far far away'.truncate(27, separator: /\s/) - # # => "Once upon a time in a..." - # - # The last characters will be replaced with the :omission string (defaults to "...") - # for a total length not exceeding length: - # - # 'And they found that many people were sleeping better.'.truncate(25, omission: '... (continued)') - # # => "And they f... (continued)" - def truncate(truncate_at, options = {}) - return dup unless length > truncate_at - - omission = options[:omission] || "..." - length_with_room_for_omission = truncate_at - omission.length - stop = \ - if options[:separator] - rindex(options[:separator], length_with_room_for_omission) || length_with_room_for_omission - else - length_with_room_for_omission - end - - +"#{self[0, stop]}#{omission}" - end - - # Truncates +text+ to at most bytesize bytes in length without - # breaking string encoding by splitting multibyte characters or breaking - # grapheme clusters ("perceptual characters") by truncating at combining - # characters. - # - # >> "🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪".size - # => 20 - # >> "🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪".bytesize - # => 80 - # >> "🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪".truncate_bytes(20) - # => "🔪🔪🔪🔪…" - # - # The truncated text ends with the :omission string, defaulting - # to "…", for a total length not exceeding bytesize. - def truncate_bytes(truncate_at, omission: "…") - omission ||= "" - - case - when bytesize <= truncate_at - dup - when omission.bytesize > truncate_at - raise ArgumentError, "Omission #{omission.inspect} is #{omission.bytesize}, larger than the truncation length of #{truncate_at} bytes" - when omission.bytesize == truncate_at - omission.dup - else - self.class.new.tap do |cut| - cut_at = truncate_at - omission.bytesize - - scan(/\X/) do |grapheme| - if cut.bytesize + grapheme.bytesize <= cut_at - cut << grapheme - else - break - end - end - - cut << omission - end - end - end - - # Truncates a given +text+ after a given number of words (words_count): - # - # 'Once upon a time in a world far far away'.truncate_words(4) - # # => "Once upon a time..." - # - # Pass a string or regexp :separator to specify a different separator of words: - # - # 'Once
upon
a
time
in
a
world'.truncate_words(5, separator: '
') - # # => "Once
upon
a
time
in..." - # - # The last characters will be replaced with the :omission string (defaults to "..."): - # - # 'And they found that many people were sleeping better.'.truncate_words(5, omission: '... (continued)') - # # => "And they found that many... (continued)" - def truncate_words(words_count, options = {}) - sep = options[:separator] || /\s+/ - sep = Regexp.escape(sep.to_s) unless Regexp === sep - if self =~ /\A((?>.+?#{sep}){#{words_count - 1}}.+?)#{sep}.*/m - $1 + (options[:omission] || "...") - else - dup - end - end -end