Module: Licensee::ContentHelper::NormalizationMethods

Included in:
Licensee::ContentHelper
Defined in:
lib/licensee/content_helper/normalization_methods.rb

Overview

Mixin providing content normalization and stripping routines.

Instance Method Summary collapse

Instance Method Details

#content_normalized(wrap: nil) ⇒ Object



20
21
22
23
# File 'lib/licensee/content_helper/normalization_methods.rb', line 20

def content_normalized(wrap: nil)
  @content_normalized ||= normalize_content
  wrap ? Licensee::ContentHelper.wrap(@content_normalized, wrap) : @content_normalized
end

#content_without_title_and_versionObject

Content with the title and version removed The first time should normally be the attribution line Used to dry up ‘content_normalized` but we need the case sensitive content with attribution first to detect attribuion in LicenseFile



11
12
13
14
15
16
17
18
# File 'lib/licensee/content_helper/normalization_methods.rb', line 11

def content_without_title_and_version
  @content_without_title_and_version ||= begin
    @_content = nil
    ops = %i[html html_comment hrs comments markdown_headings link_markup title version]
    ops.each { |op| strip(op) }
    _content
  end
end

#normalize_contentObject



25
26
27
28
29
30
# File 'lib/licensee/content_helper/normalization_methods.rb', line 25

def normalize_content
  @_content = content_without_title_and_version.downcase
  (ContentHelper::NORMALIZATIONS.keys + %i[spelling span_markup bullets]).each { |op| normalize(op) }
  ContentHelper::STRIP_METHODS.each { |op| strip(op) }
  _content
end