Sha256: a565baa16142ceb79b39690b0b0cfd8b91d3083d3ec3c10dd2d6d37d06fd705c

Contents?: true

Size: 1.59 KB

Versions: 4

Compression:

Stored size: 1.59 KB

Contents

# frozen_string_literal: true

module Spandx
  module Spdx
    class License
      attr_reader :attributes

      def initialize(attributes = {})
        @attributes = attributes
      end

      def id
        attributes[:licenseId]
      end

      def id=(value)
        attributes[:licenseId] = value
      end

      def name
        attributes[:name]
      end

      def name=(value)
        attributes[:name] = value
      end

      def reference
        attributes[:reference]
      end

      def reference=(value)
        attributes[:reference] = value
      end

      def deprecated_license_id?
        attributes[:isDeprecatedLicenseId]
      end

      def url
        attributes[:detailsUrl]
      end

      def url=(value)
        attributes[:detailsUrl] = value
      end

      def osi_approved?
        attributes[:isOsiApproved]
      end

      def see_also
        attributes[:seeAlso]
      end

      def reference_number
        attributes[:referenceNumber]
      end

      def reference_number=(value)
        attributes[:referenceNumber] = value
      end

      def content
        @content ||= ::Spandx::Core::Content.new(raw_content)
      end

      def content=(value)
        @content = ::Spandx::Core::Content.new(value)
      end

      def <=>(other)
        id <=> other.id
      end

      def to_s
        id
      end

      def self.unknown(text)
        new(licenseId: 'Nonstandard', name: 'Unknown').tap { |x| x.content = text }
      end

      private

      def raw_content
        @raw_content ||= (Spandx.git[:spdx].read("text/#{id}.txt") || '')
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
spandx-0.12.3 lib/spandx/spdx/license.rb
spandx-0.12.2 lib/spandx/spdx/license.rb
spandx-0.12.1 lib/spandx/spdx/license.rb
spandx-0.12.0 lib/spandx/spdx/license.rb