Merge pull request #261 from wking/cargo-spdx-expressions

matchers/cargo: Allow SPDX expressions
This commit is contained in:
Ben Balter 2018-01-09 09:44:39 -05:00 committed by GitHub
commit 45a8108634
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 9 deletions

View File

@ -2,7 +2,7 @@ module Licensee
module Matchers
class Cargo < Licensee::Matchers::Package
LICENSE_REGEX = %r{
^\s*[\'\"]?license[\'\"]?\s*=\s*[\'\"]([a-z\-0-9\.+\/]+)[\'\"]\s*
^\s*[\'\"]?license[\'\"]?\s*=\s*[\'\"]([a-z\-0-9\. +()\/]+)[\'\"]\s*
}ix
private

View File

@ -17,14 +17,16 @@ RSpec.describe Licensee::Matchers::Cargo do
end
{
'spdx name' => ['license = "MIT"', 'mit'],
'single quotes' => ["license = 'mit'", 'mit'],
'quoted key' => ["'license' = 'mit'", 'mit'],
'double quoted key' => ['"license"="mit"', 'mit'],
'no whitespace' => ["license='mit'", 'mit'],
'leading whitespace' => [" license = 'mit'", 'mit'],
'other license' => ['license = "Foo"', 'other'],
'multiple licenses' => ['license = "Apache-2.0/MIT"', 'other']
'spdx name' => ['license = "MIT"', 'mit'],
'single quotes' => ["license = 'mit'", 'mit'],
'quoted key' => ["'license' = 'mit'", 'mit'],
'double quoted key' => ['"license"="mit"', 'mit'],
'no whitespace' => ["license='mit'", 'mit'],
'leading whitespace' => [" license = 'mit'", 'mit'],
'other license' => ['license = "Foo"', 'other'],
'multiple licenses /' => ['license = "Apache-2.0/MIT"', 'other'],
'multiple licenses OR' => ['license = "Apache-2.0 OR MIT"', 'other'],
'multiple licenses parens' => ['license = "(Apache-2.0 OR MIT)"', 'other']
}.each do |description, license_declaration_and_key|
context "with a #{description}" do
let(:content) { license_declaration_and_key[0] }