aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rubygems/util
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rubygems/util')
-rw-r--r--lib/rubygems/util/licenses.rb15
-rw-r--r--lib/rubygems/util/list.rb2
2 files changed, 15 insertions, 2 deletions
diff --git a/lib/rubygems/util/licenses.rb b/lib/rubygems/util/licenses.rb
index 08ebd925f7..f4a99af39e 100644
--- a/lib/rubygems/util/licenses.rb
+++ b/lib/rubygems/util/licenses.rb
@@ -1,5 +1,9 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
+require 'rubygems/text'
+
class Gem::Licenses
+ extend Gem::Text
+
NONSTANDARD = 'Nonstandard'.freeze
# Software Package Data Exchange (SPDX) standard open-source software
@@ -327,4 +331,13 @@ class Gem::Licenses
def self.match?(license)
!REGEXP.match(license).nil?
end
+
+ def self.suggestions(license)
+ by_distance = IDENTIFIERS.group_by do |identifier|
+ levenshtein_distance(identifier, license)
+ end
+ lowest = by_distance.keys.min
+ return unless lowest < license.size
+ by_distance[lowest]
+ end
end
diff --git a/lib/rubygems/util/list.rb b/lib/rubygems/util/list.rb
index 83dc8497c4..9c25f6b6dc 100644
--- a/lib/rubygems/util/list.rb
+++ b/lib/rubygems/util/list.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
module Gem
class List
include Enumerable