class Riffer::Rig::Stores::JSONL
Constants
- ENTRY_TYPES
- HEADER_VERSION
Public Class Methods
(?home: String) → void
Source
# File lib/riffer/rig/stores/jsonl.rb, line 22 def initialize(home: Dir.home) @home = home @paths = {} end
@rbs home: String @rbs return: void
Public Instance Methods
(String id, Riffer::Rig::Stores::entry entry) → void
Source
# File lib/riffer/rig/stores/jsonl.rb, line 30 def append(id, entry) File.write(path_for(id, entry), "#{JSON.generate(entry.to_h)}\n", mode: 'a') end
@rbs id: String @rbs entry: Riffer::Rig::Stores::entry @rbs return: void
(String id) → void
Source
# File lib/riffer/rig/stores/jsonl.rb, line 57 def delete(id) path = find(id) return unless path File.delete(path) @paths.delete(id) end
@rbs id: String @rbs return: void
(?cwd: String?) → Array[::Riffer::Rig::Stores::Header]
Source
# File lib/riffer/rig/stores/jsonl.rb, line 45 def list(cwd: nil) headers = Dir.glob(File.join(root, '*', '*.jsonl')).filter_map do |path| # Seeding the path cache here keeps picking the most recently updated # session one mtime per header instead of one glob. @paths[File.basename(path, '.jsonl')] = path header_of(path) end cwd ? headers.select { |header| header.cwd == cwd } : headers end
@rbs cwd: String? @rbs return: Array