Module: Licensee::ContentHelper

Included in:
License, Project::LicenseFile
Defined in:
lib/licensee/content_helper.rb

Constant Summary collapse

DIGEST =
Digest::SHA1

Instance Method Summary collapse

Instance Method Details

#content_normalizedObject



18
19
20
21
22
23
24
25
# File 'lib/licensee/content_helper.rb', line 18

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

#hashObject



14
15
16
# File 'lib/licensee/content_helper.rb', line 14

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

#wordsetObject



8
9
10
11
12
# File 'lib/licensee/content_helper.rb', line 8

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