Sha256: ea4c5b80c6cd55dff9d5012737db91be6899ced8d0f08dff03a163f25a0805df

Contents?: true

Size: 645 Bytes

Versions: 9

Compression:

Stored size: 645 Bytes

Contents

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 Encoding::CompatibilityError
        nil
      end

      def confidence
        100
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
licensee-9.9.0.beta.3 lib/licensee/matchers/copyright.rb
licensee-9.9.0.beta.2 lib/licensee/matchers/copyright.rb
licensee-9.8.0 lib/licensee/matchers/copyright.rb
licensee-9.7.0 lib/licensee/matchers/copyright.rb
licensee-9.6.0 lib/licensee/matchers/copyright.rb
licensee-9.5.0 lib/licensee/matchers/copyright.rb
licensee-9.4.0 lib/licensee/matchers/copyright.rb
licensee-9.3.1 lib/licensee/matchers/copyright.rb
licensee-9.3.0 lib/licensee/matchers/copyright.rb