diff --git a/lib/spdx/version.rb b/lib/spdx/version.rb index d5a9a44..7979a24 100644 --- a/lib/spdx/version.rb +++ b/lib/spdx/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Spdx - VERSION = "2.0.3" + VERSION = "2.0.4" end diff --git a/lib/spdx_grammar.rb b/lib/spdx_grammar.rb index 9a7c8d9..568bcde 100644 --- a/lib/spdx_grammar.rb +++ b/lib/spdx_grammar.rb @@ -17,9 +17,15 @@ class With < Treetop::Runtime::SyntaxNode end class None < Treetop::Runtime::SyntaxNode + def licenses + [] + end end class NoAssertion < Treetop::Runtime::SyntaxNode + def licenses + [] + end end class License < Treetop::Runtime::SyntaxNode diff --git a/spec/spdx_spec.rb b/spec/spdx_spec.rb index 5fb9bd7..92c8c44 100644 --- a/spec/spdx_spec.rb +++ b/spec/spdx_spec.rb @@ -208,4 +208,13 @@ expect(Spdx.alias_exists?("FAKEALIAS")).to be false end end + context "licenses" do + it "returns a list of possible licenses" do + expect(Spdx.parse_spdx("MIT OR MPL-2.0").licenses).to eq ["MIT", "MPL-2.0"] + end + it "returns empty array for NONE or NOASSERTION" do + expect(Spdx.parse_spdx("NONE").licenses).to eq [] + expect(Spdx.parse_spdx("NOASSERTION").licenses).to eq [] + end + end end