Coverage report: /home/ellis/comp/core/lib/dat/yaml.lisp

KindCoveredAll%
expression036 0.0
branch00nil
Key
Not instrumented
Conditionalized out
Executed
Not executed
 
Both branches taken
One branch taken
Neither branch taken
1
 ;;; yaml.lisp --- YAML serialization
2
 
3
 ;; YAML Ain't Markup Language
4
 
5
 ;;; Commentary:
6
 
7
 ;; My least favorite markup format, but common enough to warrant reserving
8
 ;; space for it.
9
 
10
 ;; The use-cases we have in mind are: 
11
 
12
 ;; - Kubernetes :: https://kubernetes.io/docs/concepts/overview/working-with-objects/
13
 
14
 ;; - git*-ci :: https://docs.gitlab.com/ci/yaml/
15
 
16
 ;; ref: https://github.com/dtolnay/serde-yaml
17
 
18
 ;; ref: https://yaml.org/spec/1.2.2/
19
 
20
 ;;; Code:
21
 (in-package :dat/yaml)
22
 
23
 (defun yaml-decode (string &key (start 0) end)
24
   "Convert a YAML string into a Lisp object."
25
   (with-input-from-string (stream string :start start :end end)
26
     (values (yaml-read stream)
27
             (file-position stream))))
28
 
29
 (defmethod deserialize ((obj string) (format (eql :yaml)) &key (start 0) end)
30
   (declare (ignore format))
31
   (yaml-decode obj :start start :end end))
32
 
33
 (defmethod deserialize ((obj pathname) (format (eql :yaml)) &key (start 0) end)
34
   (declare (ignore format))
35
   (with-open-file (f obj)
36
     (yaml-decode obj :start start :end end)))
37
 
38
 (defun yaml-read (stream &optional (eof-error-p t) eof-value)
39
   "Read a YAML object from a stream."
40
   (let ((c (peek-char t stream eof-error-p :eof)))
41
     (case c
42
       (:eof eof-value)
43
       ;; ...
44
       (t (std:nyi!)))))