git.fiddlerwoaroof.com
Browse code

Extract feed index classes

fiddlerwoaroof authored on 06/04/2017 05:36:36
Showing 3 changed files
... ...
@@ -15,5 +15,6 @@
15 15
   :components ((:file "tools")
16 16
 	       (:file "yason-encoders")
17 17
 	       (:file "encoders")
18
+	       (:file "feed-index-utils")
18 19
 	       (:file "feed-archive")))
19 20
 
... ...
@@ -12,42 +12,6 @@
12 12
 (defparameter +dirname-format+
13 13
   '((:year 4) #\- (:month 2) #\- (:day 2) #\/ (:hour 2) #\- (:min 2) #\/))
14 14
 
15
-(defclass feed-index ()
16
-  ((%pull-time :initarg :pull-time :reader pull-time)
17
-   ;; Why this slot? Won't the references duplicate this?
18
-   (%feed-references :initarg :references :reader references)))
19
-
20
-(defclass feed-reference ()
21
-  ((%url :initarg :url :reader url)
22
-   (%title :initarg :title :reader title :initform nil)
23
-   (%path :initarg :path :reader path :initform nil)))
24
-
25
-(defun make-feed-index (pull-time references)
26
-  (make-instance 'feed-index
27
-		 :pull-time pull-time
28
-		 :references (copy-seq references)))
29
-
30
-(defun make-feed-reference (url &rest feed-data &key title path)
31
-  (declare (ignore title path))
32
-  (apply #'make-instance 'feed-reference
33
-	 :url url feed-data))
34
-
35
-(defmethod yason:encode-slots progn ((object feed-reference))
36
-  (let ((title (title object))
37
-	(path (path object)))
38
-    (yason:encode-object-element "url" (url object))
39
-    (when title
40
-      (yason:encode-object-element "title" title))
41
-    (when path
42
-      (yason:encode-object-element "path" path))))
43
-
44
-(defmethod yason:encode-slots progn ((object feed-index))
45
-  (with-accessors ((pull-time pull-time) (references references)) object
46
-    (yason:encode-object-element "pull-time" (local-time:format-timestring nil pull-time))
47
-    (yason:with-object-element ("feeds")
48
-      (yason:with-array ()
49
-	(mapcar 'yason:encode-object references)))))
50
-
51 15
 (defun get-store-directory-name (timestamp)
52 16
   (flet ((make-dirname (timestamp)
53 17
 	   (-> (local-time:format-timestring nil (local-time:timestamp-minimize-part timestamp :sec)
54 18
new file mode 100644
... ...
@@ -0,0 +1,37 @@
1
+(in-package :alimenta.feed-archive)
2
+
3
+(defclass feed-index ()
4
+  ((%pull-time :initarg :pull-time :reader pull-time)
5
+   ;; Why this slot? Won't the references duplicate this?
6
+   (%feed-references :initarg :references :reader references)))
7
+
8
+(defclass feed-reference ()
9
+  ((%url :initarg :url :reader url)
10
+   (%title :initarg :title :reader title :initform nil)
11
+   (%path :initarg :path :reader path :initform nil)))
12
+
13
+(defun make-feed-index (pull-time references)
14
+  (make-instance 'feed-index
15
+		 :pull-time pull-time
16
+		 :references (copy-seq references)))
17
+
18
+(defun make-feed-reference (url &rest feed-data &key title path)
19
+  (declare (ignore title path))
20
+  (apply #'make-instance 'feed-reference
21
+	 :url url feed-data))
22
+
23
+(defmethod yason:encode-slots progn ((object feed-reference))
24
+  (let ((title (title object))
25
+	(path (path object)))
26
+    (yason:encode-object-element "url" (url object))
27
+    (when title
28
+      (yason:encode-object-element "title" title))
29
+    (when path
30
+      (yason:encode-object-element "path" path))))
31
+
32
+(defmethod yason:encode-slots progn ((object feed-index))
33
+  (with-accessors ((pull-time pull-time) (references references)) object
34
+    (yason:encode-object-element "pull-time" (local-time:format-timestring nil pull-time))
35
+    (yason:with-object-element ("feeds")
36
+      (yason:with-array ()
37
+	(mapcar 'yason:encode-object references)))))