Skip to content

Class HTM::Models::FileSource

Inherits Object
Defined in lib/htm/models/file_source.rb

FileSource model - tracks loaded source files

Represents a file that has been loaded into HTM with its metadata. Each file can have multiple associated nodes (chunks).

Constants

DELTA_TIME

Tolerance for mtime comparison to avoid false positives from precision differences between filesystem and database timestamps

Public Instance Methods

author()

Get author from frontmatter - @return [String, nil] Author from frontmatter

chunks()

Get ordered chunks from this file - @return [Array] Nodes ordered by chunk_position

chunks_dataset()

Alias for nodes_dataset - used for consistency with "chunks" terminology - @return [Sequel::Dataset] Dataset of nodes from this file

frontmatter_tags()

Extract tags from frontmatter - @return [Array] Tag names from frontmatter 'tags' field

needs_sync?(current_mtime = nil)

Check if file needs re-sync based on mtime - @param current_mtime [Time, nil] Current file modification time - @return [Boolean] true if file needs re-sync

soft_delete_chunks!()

Soft delete all chunks from this file, cascading to their robot_nodes and node_tags like Node#soft_delete! - @return [Integer] Number of chunks soft-deleted

title()

Get title from frontmatter - @return [String, nil] Title from frontmatter

unload!()

Soft delete all chunks and delete this source record in one transaction, so a failure leaves both in place - @return [Integer] Number of chunks soft-deleted

validate()

Validations