Sha256: a1c7c4a7050b09e31d4b13b3a7103b90483ff2cce85c73ce5162dd2e96a3f735

Contents?: true

Size: 579 Bytes

Versions: 2

Compression:

Stored size: 579 Bytes

Contents

require 'set'
require 'digest'

class Licensee
  module ContentHelper

    DIGEST = Digest::SHA1

    def wordset
      @wordset ||= content_normalized.scan(/[\w']+/).to_set if content_normalized
    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.gsub("\n", " ").squeeze(" ")
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
licensee-6.1.1 lib/licensee/content_helper.rb
licensee-6.1.0 lib/licensee/content_helper.rb