-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into sim-scaled
- Loading branch information
Showing
18 changed files
with
463 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
module Licensee | ||
module Matchers | ||
class Spdx < Licensee::Matchers::Package | ||
# While we could parse the LICENSE.spdx file, prefer | ||
# a lenient regex for speed and security. Moar parsing moar problems. | ||
LICENSE_REGEX = /PackageLicenseDeclared:\s*([a-z\-0-9\. +()]+)\s*/i | ||
|
||
private | ||
|
||
def license_property | ||
match = @file.content.match LICENSE_REGEX | ||
match[1].downcase if match && match[1] | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
RSpec.describe Licensee::Matchers::Spdx do | ||
let(:content) { 'PackageLicenseDeclared: MIT' } | ||
let(:file) do | ||
Licensee::ProjectFiles::LicenseFile.new(content, 'LICENSE.spdx') | ||
end | ||
let(:mit) { Licensee::License.find('mit') } | ||
let(:other) { Licensee::License.find('other') } | ||
subject { described_class.new(file) } | ||
|
||
it 'matches' do | ||
expect(subject.match).to eql(mit) | ||
end | ||
|
||
it 'has a confidence' do | ||
expect(subject.confidence).to eql(90) | ||
end | ||
|
||
context 'no license field' do | ||
let(:content) { 'foo: bar' } | ||
|
||
it 'returns nil' do | ||
expect(subject.match).to be_nil | ||
end | ||
end | ||
|
||
context 'an unknown license' do | ||
let(:content) { 'PackageLicenseDeclared: xyz' } | ||
|
||
it 'returns other' do | ||
expect(subject.match).to eql(other) | ||
end | ||
end | ||
|
||
context 'a license expression' do | ||
let(:content) { 'PackageLicenseDeclared: (MIT OR Apache-2.0)' } | ||
|
||
it 'returns other' do | ||
expect(subject.match).to eql(other) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.