Class: Textus::Entry::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/textus/entry/base.rb

Overview

Abstract base for entry format strategies. Each concrete strategy owns parsing, serialization, file-extension claims, and schema validation for entries declared with its format.

Direct Known Subclasses

Json, Markdown, Text, Yaml

Class Method Summary collapse

Class Method Details

.enforce_name_match!(_path, _meta) ⇒ Object

Raises:

  • (NotImplementedError)


41
42
43
# File 'lib/textus/entry/base.rb', line 41

def self.enforce_name_match!(_path, _meta)
  raise NotImplementedError.new("#{name}.enforce_name_match! not implemented")
end

.extensionsObject

Raises:

  • (NotImplementedError)


19
20
21
# File 'lib/textus/entry/base.rb', line 19

def self.extensions
  raise NotImplementedError.new("#{name}.extensions not implemented")
end

.inject_uid(_meta, _content, _existing_uid) ⇒ Object

Raises:

  • (NotImplementedError)


37
38
39
# File 'lib/textus/entry/base.rb', line 37

def self.inject_uid(_meta, _content, _existing_uid)
  raise NotImplementedError.new("#{name}.inject_uid not implemented")
end

.nested_globObject

Raises:

  • (NotImplementedError)


29
30
31
# File 'lib/textus/entry/base.rb', line 29

def self.nested_glob
  raise NotImplementedError.new("#{name}.nested_glob not implemented")
end

.parse(_raw, path: nil) ⇒ Object

Raises:

  • (NotImplementedError)


7
8
9
10
# File 'lib/textus/entry/base.rb', line 7

def self.parse(_raw, path: nil)
  _ = path
  raise NotImplementedError.new("#{name}.parse not implemented")
end

.rewrite_name(_path, _basename) ⇒ Object

Raises:

  • (NotImplementedError)


53
54
55
# File 'lib/textus/entry/base.rb', line 53

def self.rewrite_name(_path, _basename)
  raise NotImplementedError.new("#{name}.rewrite_name not implemented")
end

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

Raises:

  • (NotImplementedError)


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

def self.serialize(meta: {}, body: "", content: nil)
  _ = meta
  _ = body
  _ = content
  raise NotImplementedError.new("#{name}.serialize not implemented")
end

.serialize_for_put(meta:, body:, content:, path:) ⇒ Object

Raises:

  • (NotImplementedError)


45
46
47
48
49
50
51
# File 'lib/textus/entry/base.rb', line 45

def self.serialize_for_put(meta:, body:, content:, path:)
  _ = meta
  _ = body
  _ = content
  _ = path
  raise NotImplementedError.new("#{name}.serialize_for_put not implemented")
end

.validate_against(schema, parsed) ⇒ Object

Default: validate the meta hash. Overridden by formats that put the validatable payload elsewhere (json/yaml put it under “content”).



25
26
27
# File 'lib/textus/entry/base.rb', line 25

def self.validate_against(schema, parsed)
  schema.validate!(parsed["_meta"] || {})
end

.validate_path_extension(_path, _nested) ⇒ Object

Raises:

  • (NotImplementedError)


33
34
35
# File 'lib/textus/entry/base.rb', line 33

def self.validate_path_extension(_path, _nested)
  raise NotImplementedError.new("#{name}.validate_path_extension not implemented")
end