summaryrefslogtreecommitdiff
path: root/lib/gitlab/git/declared_license.rb
blob: bc12b1918ea8e4dac93091e3997f99bb1c6cc6a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# frozen_string_literal: true

module Gitlab
  module Git
    # DeclaredLicense is the software license declared in a LICENSE or COPYING
    # file in the git repository.
    class DeclaredLicense
      # SPDX Identifier for the license
      attr_reader :key

      # Full name of the license
      attr_reader :name

      # Nickname of the license (optional, a shorter user-friendly name)
      attr_reader :nickname

      # Filename of the file containing license
      attr_accessor :path

      # URL that points to the LICENSE
      attr_reader :url

      def initialize(key: nil, name: nil, nickname: nil, url: nil, path: nil)
        @key = key
        @name = name
        @nickname = nickname
        @url = url
        @path = path
      end

      def ==(other)
        return unless other.is_a?(self.class)

        key == other.key
      end
    end
  end
end