Class: Licensee::Matchers::Package

Inherits:
Matcher
  • Object
show all
Defined in:
lib/licensee/matchers/package.rb

Overview

Base matcher for package manager metadata files declaring a license.

Direct Known Subclasses

Cabal, Cargo, Cran, DistZilla, Gemspec, NpmBower, NuGet, Spdx

Constant Summary collapse

SPDX_SUFFIX_REGEX =

Regex matching SPDX compatibility suffixes that have no matching license entry in the database (e.g. LGPL-3.0-or-later → lgpl-3.0).

/-or-later\z|-only\z/i

Constants inherited from Matcher

Matcher::HASH_METHODS

Instance Attribute Summary

Attributes inherited from Matcher

#file

Instance Method Summary collapse

Methods inherited from Matcher

#initialize, #name

Methods included from HashHelper

#serialize_hash_value, #to_h

Constructor Details

This class inherits a constructor from Licensee::Matchers::Matcher

Instance Method Details

#confidenceObject



23
24
25
# File 'lib/licensee/matchers/package.rb', line 23

def confidence
  90
end

#license_propertyObject

Raises:

  • (NotImplementedError)


27
28
29
# File 'lib/licensee/matchers/package.rb', line 27

def license_property
  raise NotImplementedError, "#{self.class}#license_property is not implemented"
end

#matchObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/licensee/matchers/package.rb', line 11

def match
  return @match if defined? @match

  prop = license_property
  return if prop.nil? || prop.to_s.empty?

  licenses = Licensee.licenses(hidden: true)
  @match = licenses.find { |l| l.key == prop }
  @match ||= match_by_spdx_base_key(prop, licenses)
  @match ||= License.find('other')
end