start making file source configurable
This commit is contained in:
13
utils.lisp
13
utils.lisp
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user