Sha256: 4a1f09aeabcd42910a7fcded12e4fdb23d7b48dd206b2b2c0996e85fc3650c5f

Contents?: true

Size: 662 Bytes

Versions: 2

Compression:

Stored size: 662 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 = /^\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.8.1 lib/licensee/matchers/copyright_matcher.rb
licensee-8.8.0 lib/licensee/matchers/copyright_matcher.rb