1
0
mirror of https://github.com/github/choosealicense.com synced 2024-12-22 12:50:24 +01:00
This commit is contained in:
Ben Balter 2016-01-15 18:01:07 -05:00
parent 853f4c97b2
commit 415ac8a174
3 changed files with 34 additions and 18 deletions

View File

@ -12,3 +12,16 @@ task :test do
HTML::Proofer.new("./_site", :check_html => true).run HTML::Proofer.new("./_site", :check_html => true).run
Rake::Task["spec"].invoke Rake::Task["spec"].invoke
end end
task :approved_licenses do
require './spec/spec_helper'
approved = approved_licenses
approved.select! { |l| spdx_ids.include?(l) }
puts "#{approved.count} approved licenses:"
puts approved.join(", ")
puts "\n"
potential = approved - licenses.map { |l| l["id"] }
puts "#{potential.count} potential additions:"
puts potential.join(", ")
end

View File

@ -7,7 +7,7 @@ licenses.each do |license|
describe "The #{license["title"]} license" do describe "The #{license["title"]} license" do
let(:id) { license["id"] } let(:id) { license["id"] }
it "has an SPDX ID" do it "has an SPDX ID" do
expect(spdx_ids).to include(id) expect(spdx_ids).to include(id)
@ -18,14 +18,16 @@ licenses.each do |license|
expect(spdx[1]["name"].gsub(/ only$/,"")).to eql(license["title"]) expect(spdx[1]["name"].gsub(/ only$/,"")).to eql(license["title"])
end end
it "should be approved by OSI or FSF or OD" do context "industry approval" do
osi = osi_approved?(id)
fsf = fsf_approved?(id)
od = od_approved?(id)
approved = osi || fsf || od # FSF approved the clear BSD, but doesn't use it's SPDX ID or Name
msg = "The license must be approved by OSI, FSF, or OD. See https://git.io/vzCTV." if license["id"] == "bsd-3-clause-clear"
expect(approved).to eql(true), msg let(:id) { "clearbsd" }
end
it "should be approved by OSI or FSF or OD" do
expect(approved_licenses).to include(id), "See https://git.io/vzCTV."
end
end end
end end
end end

View File

@ -64,10 +64,15 @@ def find_spdx(license)
spdx_list.find { |name, properties| name.downcase == license } spdx_list.find { |name, properties| name.downcase == license }
end end
def osi_approved?(id) def osi_approved_licenses
spdx = find_spdx(id) $osi_approved_licenses ||= begin
return false unless spdx licenses = {}
spdx[1]["osiApproved"] list = spdx_list.select { |id, meta| meta["osiApproved"] }
list.each do |id, meta|
licenses[id.downcase] = meta["name"]
end
licenses
end
end end
def fsf_approved_licenses def fsf_approved_licenses
@ -87,10 +92,6 @@ def fsf_approved_licenses
end end
end end
def fsf_approved?(id)
fsf_approved_licenses.keys.include?(id)
end
def od_approved_licenses def od_approved_licenses
$od_approved_licenses ||= begin $od_approved_licenses ||= begin
url = "http://licenses.opendefinition.org/licenses/groups/od.json" url = "http://licenses.opendefinition.org/licenses/groups/od.json"
@ -104,6 +105,6 @@ def od_approved_licenses
end end
end end
def od_approved?(id) def approved_licenses
od_approved_licenses.keys.include?(id) (osi_approved_licenses.keys + fsf_approved_licenses.keys + od_approved_licenses.keys).flatten.uniq.sort
end end