diff --git a/Gemfile b/Gemfile index 84fd12d..c92472d 100644 --- a/Gemfile +++ b/Gemfile @@ -16,6 +16,7 @@ end group :test do gem 'html-proofer', '~> 3.0' + gem 'licensee' gem 'nokogiri' gem 'rake' gem 'rspec' diff --git a/_licenses/ecl-2.0.txt b/_licenses/ecl-2.0.txt index ccc9267..2b0be47 100644 --- a/_licenses/ecl-2.0.txt +++ b/_licenses/ecl-2.0.txt @@ -12,7 +12,7 @@ note: The Apereo Foundation recommends taking the additional step of adding a bo using: - Sakai: https://github.com/sakaiproject/sakai/blob/master/LICENSE - OAE: https://github.com/oaeproject/Hilary/blob/master/LICENSE - - Opencast: https://bitbucket.org/opencast-community/opencast/src/905077ba5e6483f8c49869a1fc13bf9268790a79/LICENSE?at=develop + - Opencast: https://bitbucket.org/opencast-community/opencast/src/905077ba5e6483f8c49869a1fc13bf9268790a79/LICENSE permissions: - commercial-use diff --git a/_licenses/gpl-2.0.txt b/_licenses/gpl-2.0.txt index 506fcea..6f0d042 100644 --- a/_licenses/gpl-2.0.txt +++ b/_licenses/gpl-2.0.txt @@ -13,8 +13,9 @@ how: Create a text file (typically named LICENSE or LICENSE.txt) in the root of note: The Free Software Foundation recommends taking the additional step of adding a boilerplate notice to the top of each file. The boilerplate can be found at the end of the license. using: - - Linux: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/COPYING - - WordPress: https://github.com/WordPress/WordPress/blob/master/license.txt + - AliSQL: https://github.com/alibaba/AliSQL/blob/master/COPYING + - Discourse: https://github.com/discourse/discourse/blob/master/LICENSE.txt + - Joomla!: https://github.com/joomla/joomla-cms/blob/staging/LICENSE.txt permissions: - commercial-use diff --git a/_licenses/gpl-3.0.txt b/_licenses/gpl-3.0.txt index a533d7f..6011db0 100644 --- a/_licenses/gpl-3.0.txt +++ b/_licenses/gpl-3.0.txt @@ -14,9 +14,9 @@ how: Create a text file (typically named LICENSE or LICENSE.txt) in the root of note: The Free Software Foundation recommends taking the additional step of adding a boilerplate notice to the top of each file. The boilerplate can be found at the end of the license. using: + - Ansible: https://github.com/ansible/ansible/blob/devel/COPYING - Bash: https://git.savannah.gnu.org/cgit/bash.git/tree/COPYING - GIMP: https://git.gnome.org/browse/gimp/tree/COPYING - - Privacy Badger: https://github.com/EFForg/privacybadgerfirefox/blob/master/LICENSE permissions: - commercial-use diff --git a/_licenses/isc.txt b/_licenses/isc.txt index 2d8f0e1..8e34275 100644 --- a/_licenses/isc.txt +++ b/_licenses/isc.txt @@ -8,7 +8,7 @@ description: A permissive license lets people do anything with your code with pr how: Create a text file (typically named LICENSE or LICENSE.txt) in the root of your source code and copy the text of the license into the file. Replace [year] with the current year and [fullname] with the name (or names) of the copyright holders. using: - - documentation.js: https://github.com/documentationjs/documentation/blob/master/LICENSE + - Helix: https://github.com/tildeio/helix/blob/master/LICENSE - Node.js semver: https://github.com/npm/node-semver/blob/master/LICENSE - OpenStreetMap iD: https://github.com/openstreetmap/iD/blob/master/LICENSE.md diff --git a/_licenses/mit.txt b/_licenses/mit.txt index 68784c8..5104ab2 100644 --- a/_licenses/mit.txt +++ b/_licenses/mit.txt @@ -10,9 +10,9 @@ description: A short and simple permissive license with conditions only requirin how: Create a text file (typically named LICENSE or LICENSE.txt) in the root of your source code and copy the text of the license into the file. Replace [year] with the current year and [fullname] with the name (or names) of the copyright holders. using: - - jQuery: https://github.com/jquery/jquery/blob/master/LICENSE.txt + - Babel: https://github.com/babel/babel/blob/master/LICENSE - .NET Core: https://github.com/dotnet/corefx/blob/master/LICENSE.TXT - - Rails: https://github.com/rails/rails/blob/master/activerecord/MIT-LICENSE + - Rails: https://github.com/rails/rails/blob/master/MIT-LICENSE permissions: - commercial-use diff --git a/spec/license_meta_spec.rb b/spec/license_meta_spec.rb index b705913..37a123e 100644 --- a/spec/license_meta_spec.rb +++ b/spec/license_meta_spec.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true +require 'licensee' require 'spec_helper' describe 'license meta' do @@ -19,6 +20,8 @@ describe 'license meta' do expect(missing).to be_empty end + examples = raw_fields['using'] || [] + it 'using contains 3 examples' do legacy = [ 'afl-3.0', @@ -32,7 +35,6 @@ describe 'license meta' do 'cc-by-4.0', 'cc-by-sa-4.0', 'eupl-1.1', - 'gpl-2.0', 'lgpl-2.1', 'lgpl-3.0', 'lppl-1.3c', @@ -43,9 +45,45 @@ describe 'license meta' do 'zlib' ] skip 'added before 3 using examples required' if legacy.include?(license['slug']) - examples = raw_fields['using'] || [] expect(examples.length).to eq(3) end + + context 'licensee detects using examples' do + module Licensee + class License + class << self + def license_dir + dir = ::File.dirname(__FILE__) + ::File.expand_path '../_licenses', dir + end + end + end + end + + slug = license['slug'] + + examples.each do |example| + example_url = example.values[0] + + context "the #{example_url} URL" do + let(:content) { open(example_url).read } + let(:detected) { Licensee::ProjectFiles::LicenseFile.new(content, 'LICENSE').license } + + if example_url.start_with?('https://github.com/') + example_url.gsub!(%r{\Ahttps://github.com/([\w-]+/[\w-]+)/blob/([\w-]+/\S+)\z}, 'https://raw.githubusercontent.com/\1/\2') + elsif example_url.start_with?('https://git.savannah.gnu.org/', 'https://git.gnome.org/') + example_url.gsub!(%r{/tree/}, '/plain/') + elsif example_url.start_with?('https://bitbucket.org/') + example_url.gsub!(%r{/src/}, '/raw/') + end + + it "is a #{slug} license" do + skip 'NCSA and PostgreSQL licenses hard to detect' if %(ncsa postgresql).include?(slug) + expect(detected.key).to eq(slug) + end + end + end + end end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ab89492..4070ccf 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true require 'jekyll' -require 'open-uri' require 'json' require 'open-uri' require 'nokogiri'