Class: Senren::Rails::LlmsWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/senren/rails/llms_writer.rb

Overview

Generates public/llms.txt and public/llms-full.txt for AI discoverability. The entire content of both files is owned by this writer; do not edit by hand.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(registry: Registry.load!, paths: HostPaths.new) ⇒ LlmsWriter

Returns a new instance of LlmsWriter.



12
13
14
15
# File 'lib/senren/rails/llms_writer.rb', line 12

def initialize(registry: Registry.load!, paths: HostPaths.new)
  @registry = registry
  @paths    = paths
end

Instance Attribute Details

#pathsObject (readonly)

Returns the value of attribute paths.



10
11
12
# File 'lib/senren/rails/llms_writer.rb', line 10

def paths
  @paths
end

#registryObject (readonly)

Returns the value of attribute registry.



10
11
12
# File 'lib/senren/rails/llms_writer.rb', line 10

def registry
  @registry
end

Instance Method Details

#generate!Object



17
18
19
20
21
22
23
# File 'lib/senren/rails/llms_writer.rb', line 17

def generate!
  paths.llms_short.parent.mkpath
  paths.llms_full.parent.mkpath
  atomic_write(paths.llms_short, render_short)
  atomic_write(paths.llms_full,  render_full)
  [paths.llms_short, paths.llms_full]
end