Sha256: 5140d844cc32c9b60dbde32f46e6a91642512a15d90c14526b3f0fc8ca3de338

Contents?: true

Size: 936 Bytes

Versions: 2

Compression:

Stored size: 936 Bytes

Contents

module Licensee
  class Project
    class LicenseFile < Licensee::Project::File
      include Licensee::ContentHelper

      def possible_matchers
        [Matchers::Copyright, Matchers::Exact, Matchers::Dice]
      end

      def attribution
        matches = /^#{Matchers::Copyright::REGEX}$/i.match(content)
        matches[0].strip if matches
      end

      def self.name_score(filename)
        return 1.0 if filename =~ /\A(un)?licen[sc]e\z/i
        return 0.9 if filename =~ /\A(un)?licen[sc]e\.(md|markdown|txt)\z/i
        return 0.8 if filename =~ /\Acopy(ing|right)(\.[^.]+)?\z/i
        return 0.7 if filename =~ /\A(un)?licen[sc]e\.[^.]+\z/i
        return 0.5 if filename =~ /licen[sc]e/i
        0.0
      end

      # case-insensitive block to determine if the given file is LICENSE.lesser
      def self.lesser_gpl_score(filename)
        filename.casecmp('copying.lesser').zero? ? 1 : 0
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
licensee-8.5.0 lib/licensee/project_files/license_file.rb
licensee-8.4.0 lib/licensee/project_files/license_file.rb