class Licensee::ProjectFiles::LicenseFile
Constants
- CC_FALSE_POSITIVE_REGEX
CC-NC and CC-ND are not open source licenses and should not be detected as CC-BY or CC-BY-SA which are 98%+ similar
- COPYING_REGEX
Regex to match COPYING, COPYRIGHT, etc.
- FILENAME_REGEXES
Hash of Regex => score with which to score potential license files
- LICENSE_REGEX
Regex to match, LICENSE, LICENCE, unlicense, etc.
- OFL_REGEX
Regex to match OFL.
- OTHER_EXT_REGEX
Regex to match any extension except .spdx or .header
- PATENTS_REGEX
BSD + PATENTS patent file
- PREFERRED_EXT
List of extensions to give preference to
- PREFERRED_EXT_REGEX
Public Class Methods
lesser_gpl_score(filename)
click to toggle source
case-insensitive block to determine if the given file is LICENSE.lesser
# File lib/licensee/project_files/license_file.rb, line 93 def self.lesser_gpl_score(filename) filename.casecmp('copying.lesser').zero? ? 1 : 0 end
name_score(filename)
click to toggle source
# File lib/licensee/project_files/license_file.rb, line 88 def self.name_score(filename) FILENAME_REGEXES.find { |regex, _| filename =~ regex }[1] end
Public Instance Methods
attribution()
click to toggle source
# File lib/licensee/project_files/license_file.rb, line 57 def attribution @attribution ||= begin return unless copyright? || license.content =~ /\[fullname\]/ matches = Matchers::Copyright::REGEX .match(content_without_title_and_version) matches[0] if matches end end
gpl?()
click to toggle source
# File lib/licensee/project_files/license_file.rb, line 76 def gpl? license&.gpl? end
lgpl?()
click to toggle source
# File lib/licensee/project_files/license_file.rb, line 72 def lgpl? LicenseFile.lesser_gpl_score(filename) == 1 && license && license.lgpl? end
license()
click to toggle source
# File lib/licensee/project_files/license_file.rb, line 80 def license if matcher&.match matcher.match else License.find('other') end end
possible_matchers()
click to toggle source
# File lib/licensee/project_files/license_file.rb, line 53 def possible_matchers [Matchers::Copyright, Matchers::Exact, Matchers::Dice] end
potential_false_positive?()
click to toggle source
Is this file likely to result in a creative commons false positive?
# File lib/licensee/project_files/license_file.rb, line 68 def potential_false_positive? content.strip =~ CC_FALSE_POSITIVE_REGEX end