formula: convert license array to hash
This commit is contained in:
parent
6cde37247d
commit
6eb07d70f0
@ -2232,7 +2232,14 @@ class Formula
|
||||
# <pre>license all_of: ["MIT", "GPL-2.0-only"]</pre>
|
||||
# <pre>license "GPL-2.0-only" => { with: "LLVM-exception" }</pre>
|
||||
# <pre>license :public_domain</pre>
|
||||
attr_rw :license
|
||||
def license(args = nil)
|
||||
if args.nil?
|
||||
@licenses
|
||||
else
|
||||
args = { any_of: args } if args.is_a? Array
|
||||
@licenses = args
|
||||
end
|
||||
end
|
||||
|
||||
# @!attribute [w] homepage
|
||||
# The homepage for the software. Used by users to get more information
|
||||
|
||||
@ -167,10 +167,6 @@ describe SPDX do
|
||||
expect(described_class.license_expression_to_string(any_of: ["MIT", "EPL-1.0+"])).to eq "MIT or EPL-1.0+"
|
||||
end
|
||||
|
||||
it "treats array as any_of:" do
|
||||
expect(described_class.license_expression_to_string(["MIT", "EPL-1.0+"])).to eq "MIT or EPL-1.0+"
|
||||
end
|
||||
|
||||
it "returns license and exception" do
|
||||
license_expression = { "MIT" => { with: "LLVM-exception" } }
|
||||
expect(described_class.license_expression_to_string(license_expression)).to eq "MIT with LLVM-exception"
|
||||
@ -237,7 +233,6 @@ describe SPDX do
|
||||
}
|
||||
}
|
||||
let(:any_of_license) { { any_of: ["MIT", "0BSD"] } }
|
||||
let(:license_array) { ["MIT", "0BSD"] }
|
||||
let(:all_of_license) { { all_of: ["MIT", "0BSD"] } }
|
||||
let(:nested_licenses) {
|
||||
{
|
||||
@ -278,14 +273,6 @@ describe SPDX do
|
||||
expect(described_class.licenses_forbid_installation?(any_of_license, multiple_forbidden)).to eq true
|
||||
end
|
||||
|
||||
it "allows installation when one of the array licenses is allowed" do
|
||||
expect(described_class.licenses_forbid_installation?(license_array, mit_forbidden)).to eq false
|
||||
end
|
||||
|
||||
it "forbids installation when none of the array licenses are allowed" do
|
||||
expect(described_class.licenses_forbid_installation?(license_array, multiple_forbidden)).to eq true
|
||||
end
|
||||
|
||||
it "forbids installation when one of the all_of licenses is allowed" do
|
||||
expect(described_class.licenses_forbid_installation?(all_of_license, mit_forbidden)).to eq true
|
||||
end
|
||||
|
||||
@ -83,8 +83,7 @@ module SPDX
|
||||
license_expression
|
||||
when :public_domain
|
||||
"Public Domain"
|
||||
when Hash, Array
|
||||
license_expression = { any_of: license_expression } if license_expression.is_a? Array
|
||||
when Hash
|
||||
expressions = []
|
||||
|
||||
if license_expression.keys.length == 1
|
||||
@ -135,8 +134,7 @@ module SPDX
|
||||
case license_expression
|
||||
when String, Symbol
|
||||
forbidden_licenses_include? license_expression.to_s, forbidden_licenses
|
||||
when Hash, Array
|
||||
license_expression = { any_of: license_expression } if license_expression.is_a? Array
|
||||
when Hash
|
||||
key = license_expression.keys.first
|
||||
case key
|
||||
when :any_of
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user