start making file source configurable

This commit is contained in:
2026-01-05 14:11:56 -05:00
parent 6a2ab4b673
commit 59d50a694b
4 changed files with 40 additions and 13 deletions

View File

@@ -27,10 +27,19 @@
(defun string->bool (s)
(if (string-equal (string-downcase s) "true") t nil))
(defun find-string (str seq)
(sequence:find str seq :test #'string-equal))
(defclass data-source ()
((cache :initform nil :accessor cache)
(file-path :initarg :file-path :accessor file-path)))
(defun maybe-pass (func arg)
"Pass ARG to FUNC if arg is not nil."
(if (fnil)arg
(funcall func arg)
(funcall func)))
(defmacro define-data-source (singular-name)
(let* ((class-name (symbolicate singular-name '-data-source))
(constructor-name (symbolicate 'make- singular-name '-data-source))
@@ -39,8 +48,8 @@
`(progn
(defclass ,class-name (data-source) ())
(defun ,constructor-name ()
(make-instance ',class-name :file-path ,file-name)))))
(defun ,constructor-name (&optional (file-path ,file-name))
(make-instance ',class-name :file-path file-path)))))
(defgeneric data (data-source))
(defmethod data ((ds data-source))