From 530e15d771595ad821c7c4637b065fb11f58f979 Mon Sep 17 00:00:00 2001 From: Ben Balter Date: Sat, 7 Mar 2015 13:38:52 -0500 Subject: [PATCH] validate SPDX compliance --- _licenses/agpl-3.0.txt | 2 +- _licenses/bsd-2-clause.txt | 2 +- _licenses/bsd-3-clause.txt | 2 +- _licenses/{cc0.txt => cc0-1.0.txt} | 2 +- _licenses/epl-1.0.txt | 2 +- _licenses/gpl-2.0.txt | 2 +- _licenses/gpl-3.0.txt | 2 +- _licenses/isc.txt | 2 +- _licenses/lgpl-2.1.txt | 2 +- _licenses/lgpl-3.0.txt | 2 +- _licenses/unlicense.txt | 2 +- spec/license_spec.rb | 22 ++++++++++++++++++++++ spec/spec_helper.rb | 13 ++++++++++++- 13 files changed, 45 insertions(+), 12 deletions(-) rename _licenses/{cc0.txt => cc0-1.0.txt} (99%) diff --git a/_licenses/agpl-3.0.txt b/_licenses/agpl-3.0.txt index ec2bc6a..b22325a 100644 --- a/_licenses/agpl-3.0.txt +++ b/_licenses/agpl-3.0.txt @@ -1,5 +1,5 @@ --- -title: GNU Affero GPL v3.0 +title: GNU Affero General Public License v3.0 category: GPL tab-slug: agpl-v3 hide-from-license-list: true diff --git a/_licenses/bsd-2-clause.txt b/_licenses/bsd-2-clause.txt index 86fcb11..8610078 100644 --- a/_licenses/bsd-2-clause.txt +++ b/_licenses/bsd-2-clause.txt @@ -1,6 +1,6 @@ --- layout: license -title: Simplified BSD +title: BSD 2-clause "Simplified" License category: BSD tab-slug: bsd hide-from-license-list: true diff --git a/_licenses/bsd-3-clause.txt b/_licenses/bsd-3-clause.txt index 80d67e7..4033a72 100644 --- a/_licenses/bsd-3-clause.txt +++ b/_licenses/bsd-3-clause.txt @@ -1,6 +1,6 @@ --- layout: license -title: New BSD +title: BSD 3-clause "New" or "Revised" License category: BSD tab-slug: bsd-3 hide-from-license-list: true diff --git a/_licenses/cc0.txt b/_licenses/cc0-1.0.txt similarity index 99% rename from _licenses/cc0.txt rename to _licenses/cc0-1.0.txt index 3be061e..d24b663 100644 --- a/_licenses/cc0.txt +++ b/_licenses/cc0-1.0.txt @@ -1,6 +1,6 @@ --- layout: license -title: CC0 1.0 Universal +title: Creative Commons Zero v1.0 Universal category: Public Domain Dedication tab-slug: cc0 permalink: /licenses/cc0/ diff --git a/_licenses/epl-1.0.txt b/_licenses/epl-1.0.txt index 0aa38b1..62f0ab5 100644 --- a/_licenses/epl-1.0.txt +++ b/_licenses/epl-1.0.txt @@ -1,6 +1,6 @@ --- layout: license -title: Eclipse Public License v1.0 +title: Eclipse Public License 1.0 category: Eclipse redirect_from: /licenses/eclipse/ permalink: /licenses/epl-1.0/ diff --git a/_licenses/gpl-2.0.txt b/_licenses/gpl-2.0.txt index c526f9f..de06b39 100644 --- a/_licenses/gpl-2.0.txt +++ b/_licenses/gpl-2.0.txt @@ -1,5 +1,5 @@ --- -title: GNU GPL v2.0 +title: GNU General Public License v2.0 category: GPL tab-slug: gpl-v2 hide-from-license-list: false diff --git a/_licenses/gpl-3.0.txt b/_licenses/gpl-3.0.txt index 71c5853..ad4235f 100644 --- a/_licenses/gpl-3.0.txt +++ b/_licenses/gpl-3.0.txt @@ -1,5 +1,5 @@ --- -title: GNU GPL v3.0 +title: GNU General Public License v3.0 category: GPL tab-slug: gpl-v3 hide-from-license-list: true diff --git a/_licenses/isc.txt b/_licenses/isc.txt index 7801bae..8dd8e38 100644 --- a/_licenses/isc.txt +++ b/_licenses/isc.txt @@ -1,6 +1,6 @@ --- layout: license -title: ISC license +title: ISC License permalink: /licenses/isc/ source: http://opensource.org/licenses/isc-license category: BSD diff --git a/_licenses/lgpl-2.1.txt b/_licenses/lgpl-2.1.txt index ee43a3e..9eaaec5 100644 --- a/_licenses/lgpl-2.1.txt +++ b/_licenses/lgpl-2.1.txt @@ -1,6 +1,6 @@ --- layout: license -title: GNU LGPL v2.1 +title: GNU Lesser General Public License v2.1 category: LGPL tab-slug: lgpl-v2_1 redirect_from: /licenses/lgpl-v2.1/ diff --git a/_licenses/lgpl-3.0.txt b/_licenses/lgpl-3.0.txt index 3161fc2..6b7766f 100644 --- a/_licenses/lgpl-3.0.txt +++ b/_licenses/lgpl-3.0.txt @@ -1,6 +1,6 @@ --- layout: license -title: GNU LGPL v3.0 +title: GNU Lesser General Public License v3.0 category: LGPL tab-slug: lgpl-v3 hide-from-license-list: true diff --git a/_licenses/unlicense.txt b/_licenses/unlicense.txt index 020b0be..f0ecae3 100644 --- a/_licenses/unlicense.txt +++ b/_licenses/unlicense.txt @@ -1,6 +1,6 @@ --- layout: license -title: Public Domain (Unlicense) +title: The Unlicense category: Public Domain Dedication tab-slug: unlicense permalink: /licenses/unlicense/ diff --git a/spec/license_spec.rb b/spec/license_spec.rb index d77d26c..25efd5e 100644 --- a/spec/license_spec.rb +++ b/spec/license_spec.rb @@ -10,6 +10,28 @@ licenses.each do |license| expect(license["description"]).to_not be_nil end + describe "SPDX compliance" do + # "No license" isn't really a license, so no need to test + unless license["id"] == "no-license" + it "#{license["id"]} should be a valid SPDX ID" do + expect(find_spdx(license["id"])).to_not be_nil + end + + it "should be the proper SPDX name" do + spdx = find_spdx(license["id"]) + expect(spdx[1]["name"].gsub(/ only$/,"")).to eql(license["title"]) + end + + # CC0 and Unlicense are not OSI approved, but that's okay + unless license["id"] == "unlicense" || license["id"] == "cc0-1.0" + it "should be OSI approved" do + spdx = find_spdx(license["id"]) + expect(spdx[1]["osiApproved"]).to eql(true) + end + end + end + end + ["permitted", "required", "forbidden"].each do |group| describe "#{group} properties" do it "should list the properties" do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 95d8bdd..354ff08 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,4 +1,6 @@ require 'jekyll' +require 'open-uri' +require 'json' def config_file File.expand_path "./_config.yml", source @@ -15,7 +17,7 @@ def config end def licenses - site.collections["licenses"].docs.map { |l| l.data } + site.collections["licenses"].docs.map { |l| l.data.merge("id" => l.basename(".txt")) } end def site @@ -34,3 +36,12 @@ end def rule?(tag, group) rules[group].any? { |r| r["tag"] == tag } end + +def spdx_list + url = "https://raw.githubusercontent.com/sindresorhus/spdx-license-list/master/spdx.json" + $spdx ||= JSON.parse(open(url).read) +end + +def find_spdx(license) + spdx_list.find { |name, properties| name.downcase == license } +end