Merge branch 'master' into manufacture-source

This commit is contained in:
Mike Linksvayer 2018-08-20 17:55:08 +00:00 committed by GitHub
commit 4733b64549
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 78 additions and 7 deletions

View File

@ -13,6 +13,8 @@ module Licensee
VERSION_REGEX = /\Aversion.*$/i
MARKUP_REGEX = /[#_*=~\[\]()`|>]+/
DEVELOPED_BY_REGEX = /\Adeveloped by:.*?\n\n/im
QUOTE_BEGIN_REGEX = /[`'"‘“]/
QUOTE_END_REGEX = /['"’”]/
# A set of each word in the license, without duplicates
def wordset
@ -80,9 +82,10 @@ module Licensee
string = strip_all_rights_reserved(string)
string = strip_developed_by(string)
string, _partition, _instructions = string.partition(END_OF_TERMS_REGEX)
string = strip_markup(string)
string = normalize_lists(string)
string = normalize_quotes(string)
string = normalize_https(string)
string = strip_markup(string)
strip_whitespace(string)
end
@ -173,15 +176,20 @@ module Licensee
string.gsub(regex, ' ').squeeze(' ').strip
end
# Replace all single quotes with double quotes
# Replace all enclosing quotes with double quotes
# Single versus double quotes don't alter the meaning, and it's easier to
# strip double quotes if we still want to allow possessives
def normalize_quotes(string)
string.gsub(/\s'([\w -]*?\w)'/, ' "\1"')
string.gsub(/#{QUOTE_BEGIN_REGEX}+([\w -]*?\w)#{QUOTE_END_REGEX}+/,
'"\1"')
end
def normalize_https(string)
string.gsub(/http:/, 'https:')
end
def normalize_lists(string)
string.gsub(/^\s*(\d\.|\*)/, '-')
end
end
end

View File

@ -1,3 +1,3 @@
module Licensee
VERSION = '9.9.1'.freeze
VERSION = '9.9.2'.freeze
end

View File

@ -0,0 +1,27 @@
Copyright (c) 2018, Ben Balter
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -0,0 +1,27 @@
Copyright (c) 2018, Ben Balter
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -186,6 +186,15 @@ RSpec.describe 'integration test' do
expect(subject.license).to eql(license)
end
end
context 'BSD-3-Clause numbered and bulleted' do
let(:license) { Licensee::License.find('bsd-3-clause') }
let(:fixture) { 'bsd-3-lists' }
it 'determines the project is BSD-3-Clause' do
expect(subject.license).to eql(license)
end
end
end
context 'with the license file stubbed' do

View File

@ -22,12 +22,12 @@ RSpec.describe Licensee::Matchers::Dice do
it 'sorts licenses by similarity' do
expect(subject.licenses_by_similiarity[0]).to eql([gpl, 100.0])
expect(subject.licenses_by_similiarity[1]).to eql([agpl, 95.73361082206036])
expect(subject.licenses_by_similiarity[1]).to eql([agpl, 95.76581285938317])
end
it 'returns a list of licenses above the confidence threshold' do
expect(subject.licenses_by_similiarity[0]).to eql([gpl, 100.0])
expect(subject.licenses_by_similiarity[1]).to eql([agpl, 95.73361082206036])
expect(subject.licenses_by_similiarity[1]).to eql([agpl, 95.76581285938317])
end
it 'returns the match confidence' do

View File

@ -8,7 +8,7 @@ description: This commercially-friendly copyleft license provides the ability to
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.
using:
- Eclipse Che: https://github.com/eclipse/che/blob/master/LICENSE
- Eclipse hawkBit: https://github.com/eclipse/hawkbit/blob/master/LICENSE
- JUnit: https://github.com/junit-team/junit4/blob/master/LICENSE-junit.txt
- openHAB: https://github.com/openhab/openhab-distro/blob/master/LICENSE