From 1ac8eb6482192255c990ec4913bd1ded80e71385 Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Tue, 30 Jul 2024 17:29:06 +0200 Subject: [PATCH] rename package msglog to msgstore --- scopes.asd | 2 +- storage/{msglog.lisp => msgstore.lisp} | 6 +++--- test/test-core.lisp | 1 + test/test-storage.lisp | 10 +++++----- util.lisp | 16 +++++++++++----- 5 files changed, 21 insertions(+), 14 deletions(-) rename storage/{msglog.lisp => msgstore.lisp} (84%) diff --git a/scopes.asd b/scopes.asd index 22d9ff7..e330fff 100644 --- a/scopes.asd +++ b/scopes.asd @@ -8,7 +8,7 @@ :description "Generic data processing." :depends-on (:scopes-core :scopes-web :dbi :sxql) - :components ((:file "storage/msglog" :depends-on ("storage/tracking")) + :components ((:file "storage/msgstore" :depends-on ("storage/tracking")) (:file "storage/storage") (:file "storage/tracking" :depends-on ("storage/storage"))) :long-description "scopes: generic data processing facilities." diff --git a/storage/msglog.lisp b/storage/msgstore.lisp similarity index 84% rename from storage/msglog.lisp rename to storage/msgstore.lisp index 3fd77fc..6432e39 100644 --- a/storage/msglog.lisp +++ b/storage/msgstore.lisp @@ -1,6 +1,6 @@ -;;;; cl-scopes/storage/msglog - storing message data in a SQL database +;;;; cl-scopes/storage/msgstore - storing message data in a SQL database -(defpackage :scopes/storage/msglog +(defpackage :scopes/storage/msgstore (:use :common-lisp) (:local-nicknames (:message :scopes/core/message) (:shape :scopes/shape) @@ -8,7 +8,7 @@ (:tracking :scopes/storage/tracking)) (:export #:make-container #:save)) -(in-package :scopes/storage/msglog) +(in-package :scopes/storage/msgstore) (defclass pmsg (message:message tracking:track) ()) diff --git a/test/test-core.lisp b/test/test-core.lisp index f5caeef..b6eabc0 100644 --- a/test/test-core.lisp +++ b/test/test-core.lisp @@ -62,6 +62,7 @@ (t:show-result)))) (deftest test-util () + (== (util:rtrim '(1 2 nil 3 nil)) '(1 2)) (== (util:to-keyword "hello-kitty") :hello-kitty) (== (util:loop-plist '(:a "a" :b "b") k v collect (string-upcase k)) '("A" "B"))) diff --git a/test/test-storage.lisp b/test/test-storage.lisp index c83845c..778280e 100644 --- a/test/test-storage.lisp +++ b/test/test-storage.lisp @@ -8,7 +8,7 @@ (:core :scopes/core) (:logging :scopes/logging) (:message :scopes/core/message) - (:msglog :scopes/storage/msglog) + (:msgstore :scopes/storage/msgstore) (:shape :scopes/shape) (:storage :scopes/storage) (:tracking :scopes/storage/tracking) @@ -37,7 +37,7 @@ (core:setup-services) (let ((ctx (core:find-service :storage))) (test-track ctx) - (test-msglog ctx) + (test-msgstore ctx) (t:show-result))) (deftest test-track (ctx) @@ -58,15 +58,15 @@ (== (getf (shape:data tr2) :desc) "scopes/storage: queries") )) -(deftest test-msglog (ctx) +(deftest test-msgstore (ctx) (let ((st (storage:storage ctx)) (data (make-hash-table)) cont msg pm pm2) - (setf cont (msglog:make-container st)) + (setf cont (msgstore:make-container st)) (storage:drop-table st :messages) (tracking:create-table cont) (setf msg (message:create '(:test :data :field) :data '(:info "test data"))) - (setf pm (msglog:save msg cont)) + (setf pm (msgstore:save msg cont)) (== (tracking:trackid pm) 1) (setf pm2 (tracking:get-track cont 1)) ;(log:info "pm2: ~s" pm2) diff --git a/util.lisp b/util.lisp index e8c9962..5ff5085 100644 --- a/util.lisp +++ b/util.lisp @@ -2,13 +2,22 @@ (defpackage :scopes/util (:use :common-lisp) - (:export #:flatten-str #:to-keyword #:keyword-to-string #:to-string - #:loop-plist + (:export #:rtrim #:loop-plist + #:flatten-str #:to-keyword #:keyword-to-string #:to-string #:absolute-dir #:check-dir #:ensure-dir #:home-path #:path-from-string #:relative-path #:runtime-path #:system-path)) (in-package :scopes/util) +;;;; lists and loops + +(defun rtrim (lst) + (if (car lst) + (cons (car lst) (rtrim (cdr lst))))) + +(defmacro loop-plist (plist kvar vvar &body body) + `(loop for (,kvar ,vvar . nil) on ,plist by #'cddr ,@body)) + ;;;; strings, symbols, keywords, ... (defun flatten-str (s &key (sep " ")) @@ -30,9 +39,6 @@ nil (intern (string-upcase s) :keyword))) -(defmacro loop-plist (plist kvar vvar &body body) - `(loop for (,kvar ,vvar . nil) on ,plist by #'cddr ,@body)) - ;;;; directory and pathname utilities (defun split-filename (name)