Module: Textus::Entry::Text

Defined in:
lib/textus/entry/text.rb

Overview

Plain-text entry storage. No frontmatter or structured content.

Class Method Summary collapse

Class Method Details

.extensionsObject



20
# File 'lib/textus/entry/text.rb', line 20

def self.extensions = [".txt"]

.parse(raw, path: nil) ⇒ Object

Raises:



5
6
7
8
9
10
# File 'lib/textus/entry/text.rb', line 5

def self.parse(raw, path: nil)
  raw = raw.dup.force_encoding(Encoding::UTF_8)
  raise BadFrontmatter.new(path, "entry is not valid UTF-8") unless raw.valid_encoding?

  { "_meta" => {}, "body" => raw, "content" => nil }
end

.serialize(meta:, body:, content: nil) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/textus/entry/text.rb', line 12

def self.serialize(meta:, body:, content: nil)
  _ = meta
  _ = content
  b = body.to_s
  b += "\n" unless b.empty? || b.end_with?("\n")
  b
end