From e505eb8fb97ebb6cbd81ebb461711f7075238eef Mon Sep 17 00:00:00 2001 From: Ben Balter Date: Mon, 18 Jan 2016 17:05:02 -0500 Subject: [PATCH] check if license is aleady a license --- script/check-approval | 7 +++++-- spec/spec_helper.rb | 9 ++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/script/check-approval b/script/check-approval index d34a950..b3fe7a2 100755 --- a/script/check-approval +++ b/script/check-approval @@ -50,8 +50,11 @@ approvals.each do |name, licenses| rows << ["#{name} approved", licenses.include?(license)] end +current = license_ids.include?(license) +rows << ["Current license", current] + rows << :separator -eligible = !!(spdx && approved_licenses.include?(license)) +eligible = !!(!current && spdx && approved_licenses.include?(license)) rows << ["Eligible", eligible] puts Terminal::Table.new title: "License: #{license}", rows: rows @@ -62,7 +65,7 @@ if spdx.nil? puts puts "SPDX ID not found. Some possible matches:" puts - + fm = FuzzyMatch.new(spdx_ids) matches = fm.find_all_with_score(license) matches = matches[0...5].map { |record, _dice, _levin| record } diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 4834964..55e7673 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -19,7 +19,14 @@ def config end def licenses - site.collections["licenses"].docs.map { |l| l.to_liquid.merge("id" => l.basename(".txt")) } + site.collections["licenses"].docs.map do |license| + id = File.basename(license.basename, ".txt") + license.to_liquid.merge("id" => id) + end +end + +def license_ids + licenses.map { |l| l["id"] } end def families