Sha256: d55b5205fedb4274044d99f23e49b686449052165d87d9949a2044bbba47d022

Contents?: true

Size: 766 Bytes

Versions: 2

Compression:

Stored size: 766 Bytes

Contents

# frozen_string_literal: true

module Licensee
  module Matchers
    class Copyright < Licensee::Matchers::Matcher
      attr_reader :file

      COPYRIGHT_SYMBOLS = Regexp.union([/copyright/i, /\(c\)/i, "\u00A9", "\xC2\xA9"])
      MAIN_LINE_REGEX = /[_*\-\s]*#{COPYRIGHT_SYMBOLS}.*$/i.freeze
      OPTIONAL_LINE_REGEX = /[_*\-\s]*with Reserved Font Name.*$/i.freeze
      REGEX = /#{ContentHelper::START_REGEX}(#{MAIN_LINE_REGEX}#{OPTIONAL_LINE_REGEX}*)+$/i.freeze
      def match
        # NOTE: must use content, and not content_normalized here
        Licensee::License.find('no-license') if /#{REGEX}+\z/io.match?(file.content.strip)
      rescue Encoding::CompatibilityError
        nil
      end

      def confidence
        100
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
licensee-9.16.0 lib/licensee/matchers/copyright.rb
licensee-9.15.3 lib/licensee/matchers/copyright.rb