summaryrefslogtreecommitdiff
path: root/lib/rubygems/util/licenses.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rubygems/util/licenses.rb')
-rw-r--r--lib/rubygems/util/licenses.rb15
1 files changed, 14 insertions, 1 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