Module: Licensee::License::ContentMethods

Included in:
Licensee::License
Defined in:
lib/licensee/license/content_methods.rb

Overview

Instance methods for loading and working with license content.

Instance Method Summary collapse

Instance Method Details

#contentObject Also known as: to_s, text, body

The license body (e.g., contents - frontmatter)



13
14
15
# File 'lib/licensee/license/content_methods.rb', line 13

def content
  @content ||= parts[2] if parts && parts[2]
end

#content_for_mustacheObject

Returns a string with ‘[fields]` replaced by `{{fields}}` Does not mangle non-supported fields in the form of `[field]`



27
28
29
# File 'lib/licensee/license/content_methods.rb', line 27

def content_for_mustache
  @content_for_mustache ||= content.gsub(LicenseField::FIELD_REGEX, '{{{\1}}}')
end

#fieldsObject

Returns an array of strings of substitutable fields in the license body



21
22
23
# File 'lib/licensee/license/content_methods.rb', line 21

def fields
  @fields ||= LicenseField.from_content(content)
end

#pathObject

Path to vendored license file on disk



8
9
10
# File 'lib/licensee/license/content_methods.rb', line 8

def path
  @path ||= File.expand_path "#{@key}.txt", Licensee::License.license_dir
end