1
0
mirror of https://github.com/github/choosealicense.com synced 2024-12-22 04:40:09 +01:00

Merge pull request #555 from github/test-using-examples

Test examples provided in 'using:' would be detected by licensee
This commit is contained in:
Mike Linksvayer 2017-11-27 13:19:35 -08:00 committed by GitHub
commit 7213ccf8ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 49 additions and 10 deletions

View File

@ -16,6 +16,7 @@ end
group :test do
gem 'html-proofer', '~> 3.0'
gem 'licensee'
gem 'nokogiri'
gem 'rake'
gem 'rspec'

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1,7 +1,6 @@
# frozen_string_literal: true
require 'jekyll'
require 'open-uri'
require 'json'
require 'open-uri'
require 'nokogiri'