Sha256: 594ee947508e11efed6994ea605f848964c068c6a4de275c1612f884d03109e3

Contents?: true

Size: 635 Bytes

Versions: 5

Compression:

Stored size: 635 Bytes

Contents

# encoding: UTF-8

module Licensee
  module Matchers
    class Copyright < Licensee::Matchers::Matcher
      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 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

5 entries across 5 versions & 1 rubygems

Version Path
licensee-9.2.1 lib/licensee/matchers/copyright.rb
licensee-9.2.0 lib/licensee/matchers/copyright.rb
licensee-9.1.0 lib/licensee/matchers/copyright.rb
licensee-9.0.0 lib/licensee/matchers/copyright.rb
licensee-9.0.0.beta.1 lib/licensee/matchers/copyright.rb