diff options
Diffstat (limited to 'lib/rubygems/text.rb')
-rw-r--r-- | lib/rubygems/text.rb | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/rubygems/text.rb b/lib/rubygems/text.rb index acf25a0bcd..da0795b771 100644 --- a/lib/rubygems/text.rb +++ b/lib/rubygems/text.rb @@ -4,12 +4,11 @@ # A collection of text-wrangling methods module Gem::Text - ## # Remove any non-printable characters and make the text suitable for # printing. def clean_text(text) - text.gsub(/[\000-\b\v-\f\016-\037\177]/, ".".freeze) + text.gsub(/[\000-\b\v-\f\016-\037\177]/, ".") end def truncate_text(text, description, max_length = 100_000) @@ -51,7 +50,7 @@ module Gem::Text # Returns a value representing the "cost" of transforming str1 into str2 # Vendored version of DidYouMean::Levenshtein.distance from the ruby/did_you_mean gem @ 1.4.0 - # https://git.io/JJgZI + # https://github.com/ruby/did_you_mean/blob/2ddf39b874808685965dbc47d344cf6c7651807c/lib/did_you_mean/levenshtein.rb#L7-L37 def levenshtein_distance(str1, str2) n = str1.length m = str2.length @@ -67,7 +66,7 @@ module Gem::Text str1.each_codepoint.with_index(1) do |char1, i| j = 0 while j < m - cost = (char1 == str2_codepoints[j]) ? 0 : 1 + cost = char1 == str2_codepoints[j] ? 0 : 1 x = min3( d[j + 1] + 1, # insertion i + 1, # deletion |