Sha256: 06787b83a304cd80a962783ba8f2de1d26757e6785cb8b11be12d433e41b8eed

Contents?: true

Size: 595 Bytes

Versions: 7

Compression:

Stored size: 595 Bytes

Contents

require 'set'
require 'digest'

module Licensee
  module ContentHelper
    DIGEST = Digest::SHA1

    def wordset
      @wordset ||= if content_normalized
        content_normalized.scan(/[\w']+/).to_set
      end
    end

    def hash
      @hash ||= DIGEST.hexdigest content_normalized
    end

    def content_normalized
      return unless content
      @content_normalized ||= begin
        content_normalized = content.downcase.strip
        content_normalized.gsub!(/^#{Matchers::Copyright::REGEX}$/i, '')
        content_normalized.tr("\n", ' ').squeeze(' ')
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
licensee-8.3.1 lib/licensee/content_helper.rb
licensee-8.3.0 lib/licensee/content_helper.rb
licensee-8.2.0 lib/licensee/content_helper.rb
licensee-8.1.0 lib/licensee/content_helper.rb
licensee-8.0.0 lib/licensee/content_helper.rb
licensee-7.0.1 lib/licensee/content_helper.rb
licensee-7.0.0 lib/licensee/content_helper.rb