Sha256: af59f2c2288376be32cc999cad360653eeb9b50a37cfe78504589fef41cc70f2

Contents?: true

Size: 664 Bytes

Versions: 2

Compression:

Stored size: 664 Bytes

Contents

# encoding: UTF-8

module Licensee
  module Matchers
    class Copyright
      attr_reader :file

      # rubocop:disable Metrics/LineLength
      COPYRIGHT_SYMBOLS = Regexp.union([/copyright/i, /\(c\)/i, "\u00A9", "\xC2\xA9"])
      REGEX = /\A\s*#{COPYRIGHT_SYMBOLS}.*$/i
      # rubocop:enable Metrics/LineLength

      def initialize(file)
        @file = file
      end

      def match
        # Note: must use content, and not content_normalized here
        if @file.content.strip =~ /\A#{REGEX}\z/i
          Licensee::License.find('no-license')
        end
      rescue
        nil
      end

      def confidence
        100
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
licensee-8.9.2 lib/licensee/matchers/copyright_matcher.rb
licensee-8.9.0 lib/licensee/matchers/copyright_matcher.rb