Sha256: c3a44007ba18cc55f2fb5ba73d9fd4024ef2482be10126666dc310a773deef79

Contents?: true

Size: 663 Bytes

Versions: 4

Compression:

Stored size: 663 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

4 entries across 4 versions & 1 rubygems

Version Path
licensee-8.8.5 lib/licensee/matchers/copyright_matcher.rb
licensee-8.8.4 lib/licensee/matchers/copyright_matcher.rb
licensee-8.8.3 lib/licensee/matchers/copyright_matcher.rb
licensee-8.8.2 lib/licensee/matchers/copyright_matcher.rb