Class: DocsKit::Snapshot::Entry
- Inherits:
-
Object
- Object
- DocsKit::Snapshot::Entry
- Defined in:
- lib/docs_kit/snapshot/entry.rb
Overview
One snapshot page — the duck type of DocsKit::Registry::Entry (#slug /
#title / #group / #icon / #href / #view_class / #renderable), so the
enumeration seam (LlmsText.pages) and its consumers treat a frozen
Markdown page exactly like a live Ruby one. #view_class is the truthy
DocsUI::ArchivedPage constant, so the select(&:view_class) authored-page
filter passes unchanged.
Instance Attribute Summary collapse
-
#digest ⇒ Object
readonly
Returns the value of attribute digest.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#group ⇒ Object
readonly
Returns the value of attribute group.
-
#href ⇒ Object
readonly
Returns the value of attribute href.
-
#icon ⇒ Object
readonly
Returns the value of attribute icon.
-
#slug ⇒ Object
readonly
Returns the value of attribute slug.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(attrs, version:, root:, registry_prefix:) ⇒ Entry
constructor
A new instance of Entry.
-
#markdown ⇒ Object
The raw Markdown body from the snapshot file.
-
#renderable ⇒ Object
The renderable the controllers hand to Phlex — an ArchivedPage carrying this entry, where a live Registry::Entry builds
view_class.new. -
#view_class ⇒ Object
The renderer for every archived page.
Constructor Details
#initialize(attrs, version:, root:, registry_prefix:) ⇒ Entry
Returns a new instance of Entry.
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/docs_kit/snapshot/entry.rb', line 14 def initialize(attrs, version:, root:, registry_prefix:) @slug = attrs["slug"] @title = attrs["title"] @group = attrs["group"] @icon = attrs["icon"] @file = attrs["file"] @digest = attrs["digest"] @root = root @href = "#{version.path_prefix}#{registry_prefix}/#{@slug}" end |
Instance Attribute Details
#digest ⇒ Object (readonly)
Returns the value of attribute digest.
12 13 14 |
# File 'lib/docs_kit/snapshot/entry.rb', line 12 def digest @digest end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
12 13 14 |
# File 'lib/docs_kit/snapshot/entry.rb', line 12 def file @file end |
#group ⇒ Object (readonly)
Returns the value of attribute group.
12 13 14 |
# File 'lib/docs_kit/snapshot/entry.rb', line 12 def group @group end |
#href ⇒ Object (readonly)
Returns the value of attribute href.
12 13 14 |
# File 'lib/docs_kit/snapshot/entry.rb', line 12 def href @href end |
#icon ⇒ Object (readonly)
Returns the value of attribute icon.
12 13 14 |
# File 'lib/docs_kit/snapshot/entry.rb', line 12 def icon @icon end |
#slug ⇒ Object (readonly)
Returns the value of attribute slug.
12 13 14 |
# File 'lib/docs_kit/snapshot/entry.rb', line 12 def slug @slug end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
12 13 14 |
# File 'lib/docs_kit/snapshot/entry.rb', line 12 def title @title end |
Instance Method Details
#markdown ⇒ Object
The raw Markdown body from the snapshot file. A missing/unreadable file degrades to "" — the page renders empty rather than 500ing.
39 40 41 42 43 44 45 |
# File 'lib/docs_kit/snapshot/entry.rb', line 39 def markdown return "" if @root.nil? || @file.nil? @root.join(@file).read rescue SystemCallError "" end |
#renderable ⇒ Object
The renderable the controllers hand to Phlex — an ArchivedPage carrying
this entry, where a live Registry::Entry builds view_class.new.
33 34 35 |
# File 'lib/docs_kit/snapshot/entry.rb', line 33 def renderable DocsUI::ArchivedPage.new(entry: self) end |
#view_class ⇒ Object
The renderer for every archived page. Truthy (never nil): a snapshot page is by definition authored — its content is the committed .md file.
27 28 29 |
# File 'lib/docs_kit/snapshot/entry.rb', line 27 def view_class DocsUI::ArchivedPage end |