Skip to content

Commit

Permalink
treat / as a word character
Browse files Browse the repository at this point in the history
  • Loading branch information
mlinksva committed Dec 25, 2019
1 parent cb166ac commit 5436184
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/licensee/content_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ module ContentHelper

# A set of each word in the license, without duplicates
def wordset
@wordset ||= content_normalized&.scan(/(?:\w(?:'s|(?<=s)')?)+/)&.to_set
@wordset ||= content_normalized&.scan(/(?:[\w\/](?:'s|(?<=s)')?)+/)&.to_set
end

# Number of characteres in the normalized content
Expand Down
30 changes: 30 additions & 0 deletions spec/fixtures/bsd-3-noendorseslash/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Copyright © 2019, Person Person and contributors

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 someorg/foo-bar-baz-quux 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.
4 changes: 4 additions & 0 deletions spec/fixtures/fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ bsd-3-lists:
key: bsd-3-clause
matcher:
hash:
bsd-3-noendorseslash:
key: bsd-3-clause
matcher: dice
hash: 11df3173c40b87a9da370f3420372a310259b273
bsd-plus-patents:
key: other
matcher:
Expand Down
9 changes: 9 additions & 0 deletions spec/integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,15 @@
end
end

context 'BSD-3-Clause no-endorsement name with slashes' do
let(:license) { Licensee::License.find('bsd-3-clause') }
let(:fixture) { 'bsd-3-noendorseslash' }

it 'determines the project is BSD-3-Clause' do
expect(subject.license).to eql(license)
end
end

context 'HTML license file' do
let(:license) { Licensee::License.find('epl-1.0') }
let(:fixture) { 'html' }
Expand Down
4 changes: 2 additions & 2 deletions spec/licensee/matchers/dice_matcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@

it 'sorts licenses by similarity' do
expect(subject.matches_by_similarity[0]).to eql([gpl, 100.0])
expect(subject.matches_by_similarity[1]).to eql([agpl, 95.67966280295047])
expect(subject.matches_by_similarity[1]).to eql([agpl, 95.6842105263158])
end

it 'returns a list of licenses above the confidence threshold' do
expect(subject.matches_by_similarity[0]).to eql([gpl, 100.0])
expect(subject.matches_by_similarity[1]).to eql([agpl, 95.67966280295047])
expect(subject.matches_by_similarity[1]).to eql([agpl, 95.6842105263158])
end

it 'returns the match confidence' do
Expand Down
2 changes: 1 addition & 1 deletion spec/licensee/project_files/license_file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
end

it 'creates the wordset' do
expect(subject.wordset.count).to be(91)
expect(subject.wordset.count).to be(92)
expect(subject.wordset.first).to eql('permission')
end

Expand Down

0 comments on commit 5436184

Please sign in to comment.