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
-
#content ⇒ Object
(also: #to_s, #text, #body)
The license body (e.g., contents - frontmatter).
-
#content_for_mustache ⇒ Object
Returns a string with ‘[fields]` replaced by `{{fields}}` Does not mangle non-supported fields in the form of `[field]`.
-
#fields ⇒ Object
Returns an array of strings of substitutable fields in the license body.
-
#path ⇒ Object
Path to vendored license file on disk.
Instance Method Details
#content ⇒ Object 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_mustache ⇒ Object
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 |
#fields ⇒ Object
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 |
#path ⇒ Object
Path to vendored license file on disk
8 9 10 |
# File 'lib/licensee/license/content_methods.rb', line 8 def path @path ||= File. "#{@key}.txt", Licensee::License.license_dir end |