Sha256: 2a5a1afad3e96de923aec876652b697e35d43207a37cd079886bf2969b4a0e58

Contents?: true

Size: 1.49 KB

Versions: 6

Compression:

Stored size: 1.49 KB

Contents

# frozen_string_literal: true

module SpdxGrammar
  class LogicalBinary < Treetop::Runtime::SyntaxNode
    # Used internally

    def licenses
      (left.licenses + right.licenses).uniq
    end

    def left
      elements[0]
    end

    def right
      elements[1]
    end
  end

  class LogicalAnd < LogicalBinary
  end

  class LogicalOr < LogicalBinary
  end

  class With < Treetop::Runtime::SyntaxNode
    def licenses
      license.licenses
    end

    def license
      elements[0]
    end

    def exception
      elements[1]
    end
  end

  class None < Treetop::Runtime::SyntaxNode
    def licenses
      []
    end
  end

  class NoAssertion < Treetop::Runtime::SyntaxNode
    def licenses
      []
    end
  end

  class License < Treetop::Runtime::SyntaxNode
    def licenses
      [text_value]
    end
  end

  class LicensePlus < Treetop::Runtime::SyntaxNode
    def licenses
      child.licenses.map { |license| "#{license}+" }
    end

    def child
      elements[0]
    end
  end

  class LicenseRef < Treetop::Runtime::SyntaxNode
    def licenses
      [text_value]
    end
  end

  class DocumentRef < Treetop::Runtime::SyntaxNode
    def licenses
      [text_value]
    end
  end

  class LicenseException < Treetop::Runtime::SyntaxNode
    # TODO: actually do license exceptions
  end

  class GroupedExpression < Treetop::Runtime::SyntaxNode
    # Used internally
  end

  class Operand < Treetop::Runtime::SyntaxNode
    # Used internally
  end

  class SpdxParseError < StandardError
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
spdx-4.1.4 lib/spdx_grammar.rb
spdx-4.1.3 lib/spdx_grammar.rb
spdx-4.1.2 lib/spdx_grammar.rb
spdx-4.1.1 lib/spdx_grammar.rb
spdx-4.1.0 lib/spdx_grammar.rb
spdx-4.0.2 lib/spdx_grammar.rb