Sha256: ef7e395e9ab7eb623038c7c52afc4bea87a79506eb46d060472b03ecc4b27684

Contents?: true

Size: 616 Bytes

Versions: 1

Compression:

Stored size: 616 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"])
      REGEX = /#{ContentHelper::START_REGEX}([_*\-\s]*#{COPYRIGHT_SYMBOLS}.*$)+$/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

1 entries across 1 versions & 1 rubygems

Version Path
licensee-9.15.2 lib/licensee/matchers/copyright.rb