Browse code
Add bindings for the new pattern-matcher in fwoar.lisputils
fiddlerwoaroof authored on 20/08/2017 08:03:42
Showing 3 changed files
Showing 3 changed files
... | ... |
@@ -1,6 +1,7 @@ |
1 | 1 |
;;;; alimenta.asd |
2 |
+(in-package :asdf-user) |
|
2 | 3 |
|
3 |
-(asdf:defsystem #:alimenta |
|
4 |
+(defsystem #:alimenta |
|
4 | 5 |
:description "A little library to discover, fetch, parse and generate RSS feeds" |
5 | 6 |
:author "Fiddlerwoaroof <fiddlerwoaroof@howit.is>" |
6 | 7 |
:license "MIT" |
... | ... |
@@ -10,7 +11,7 @@ |
10 | 11 |
#:drakma |
11 | 12 |
#:for |
12 | 13 |
#:fwoar.lisputils |
13 |
- #:collection-class |
|
14 |
+ #:collection-class |
|
14 | 15 |
#:lquery |
15 | 16 |
#:plump |
16 | 17 |
#:serapeum |
... | ... |
@@ -19,10 +20,6 @@ |
19 | 20 |
#:split-sequence) |
20 | 21 |
:serial t |
21 | 22 |
:components ((:file "package") |
22 |
- ;; (:file "collections") |
|
23 |
- ;; (:file "collections-for") |
|
24 |
- ;; #+sbcl (:file "collections-sbcl-iterators") |
|
25 |
- |
|
26 | 23 |
(:file "alimenta") |
27 | 24 |
(:file "data-class") |
28 | 25 |
(:file "date-handling") |
... | ... |
@@ -31,5 +28,17 @@ |
31 | 28 |
(:file "fetching") |
32 | 29 |
(:file "discovery"))) |
33 | 30 |
|
31 |
+(defsystem :alimenta+patmatch |
|
32 |
+ :description "" |
|
33 |
+ :author "Ed L <edward@elangley.org>" |
|
34 |
+ :license "MIT" |
|
35 |
+ :depends-on (#:alexandria |
|
36 |
+ #:uiop |
|
37 |
+ #:serapeum |
|
38 |
+ #:alimenta |
|
39 |
+ #:fwoar.lisputils) |
|
40 |
+ :serial t |
|
41 |
+ :components ((:file "pattern-matcher"))) |
|
42 |
+ |
|
34 | 43 |
|
35 | 44 |
;; vim: set ft=lisp: |
5 | 5 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,32 @@ |
1 |
+(defpackage :alimenta%pattern-matcher |
|
2 |
+ (:use :cl :patmatch :alimenta) |
|
3 |
+ (:export )) |
|
4 |
+(in-package :alimenta%pattern-matcher) |
|
5 |
+ |
|
6 |
+ |
|
7 |
+(defmethod handle-pattern append ((pattern feed-entity) form &rest args) |
|
8 |
+ (let ((key->reader '((:title . title) |
|
9 |
+ (:link . link) |
|
10 |
+ (:doc . doc)))) |
|
11 |
+ (let* ((val-sym (gensym "VAL")) |
|
12 |
+ (binders (loop for (key binding) on args by #'cddr |
|
13 |
+ for accessor = (cdr (assoc key key->reader)) |
|
14 |
+ when accessor append |
|
15 |
+ `((,binding (,accessor ,val-sym)))))) |
|
16 |
+ `((,val-sym ,form) |
|
17 |
+ ,@binders)))) |
|
18 |
+ |
|
19 |
+(defmethod handle-pattern append ((pattern feed) form &rest args) |
|
20 |
+ (let ((key->reader '((:author . author) |
|
21 |
+ (:items . collection-class:items) |
|
22 |
+ (:description . description) |
|
23 |
+ (:source-type . source-type) |
|
24 |
+ (:feed-link . feed-link)))) |
|
25 |
+ (let* ((val-sym (gensym "VAL")) |
|
26 |
+ (binders (loop for (key binding) on args by #'cddr |
|
27 |
+ for accessor = (cdr (assoc key key->reader)) |
|
28 |
+ when accessor append |
|
29 |
+ `((,binding (,accessor ,val-sym)))))) |
|
30 |
+ `((,val-sym ,form) |
|
31 |
+ ,@binders)))) |
|
32 |
+ |