Browse code
chore: cleanup vestigial code
Edward Langley authored on 24/10/2022 03:47:55
Showing 6 changed files
Showing 6 changed files
- alimenta.asd
- collections-for.lisp
- collections-sbcl-iterators.lisp
- collections.lisp
- date-handling.lisp
- package.lisp
... | ... |
@@ -20,16 +20,15 @@ |
20 | 20 |
#:split-sequence) |
21 | 21 |
:serial t |
22 | 22 |
:components ((:file "package") |
23 |
- (:file "alimenta") |
|
23 |
+ (:file "alimenta") |
|
24 | 24 |
(:file "data-class") |
25 |
- (:file "date-handling") |
|
26 | 25 |
(:file "render-protocol") |
27 |
- (:file "atom") |
|
28 |
- (:file "rss") |
|
26 |
+ (:file "atom") |
|
27 |
+ (:file "rss") |
|
29 | 28 |
(:file "fetching") |
30 | 29 |
(:file "discovery"))) |
31 | 30 |
|
32 |
-(defsystem :alimenta/patmatch |
|
31 |
+(defsystem :alimenta/patmatch |
|
33 | 32 |
:description "" |
34 | 33 |
:author "Ed L <edward@elangley.org>" |
35 | 34 |
:license "MIT" |
36 | 35 |
deleted file mode 100644 |
... | ... |
@@ -1,15 +0,0 @@ |
1 |
-(in-package :collection-class) |
|
2 |
- |
|
3 |
-(defmethod for:has-more ((iterator collection-iterator)) |
|
4 |
- (not (null (for:object iterator)))) |
|
5 |
- |
|
6 |
-(defmethod for:next ((iterator collection-iterator)) |
|
7 |
- (let ((collection-items (for:object iterator))) |
|
8 |
- (prog1 (car collection-items) |
|
9 |
- (setf (for:object iterator) |
|
10 |
- (cdr collection-items))))) |
|
11 |
- |
|
12 |
-(defmethod for:make-iterator ((collection collection) &key) |
|
13 |
- (make-instance 'collection-iterator :object collection)) |
|
14 |
- |
|
15 |
- |
16 | 0 |
deleted file mode 100644 |
... | ... |
@@ -1,64 +0,0 @@ |
1 |
-(in-package :collection-class) |
|
2 |
- |
|
3 |
-#+nil |
|
4 |
-(defmethod sequence:length ((sequence collection)) |
|
5 |
- (length (items sequence))) |
|
6 |
- |
|
7 |
-#+sbcl |
|
8 |
-(defmethod sb-sequence:length ((sequence collection)) |
|
9 |
- (length (items sequence))) |
|
10 |
- |
|
11 |
-#+nil |
|
12 |
-(defmethod sequence:elt ((sequence collection) index) |
|
13 |
- (elt (items sequence) index)) |
|
14 |
- |
|
15 |
-#+sbcl |
|
16 |
-(defmethod sb-sequence:elt ((sequence collection) index) |
|
17 |
- (elt (items sequence) index)) |
|
18 |
- |
|
19 |
-#+nil |
|
20 |
-(defmethod (setf sequence:elt) (new-value (sequence collection) index) |
|
21 |
- (setf (elt (items sequence) index) new-value)) |
|
22 |
- |
|
23 |
-#+sbcl |
|
24 |
-(defmethod (setf sb-sequence:elt) (new-value (sequence collection) index) |
|
25 |
- (setf (elt (items sequence) index) new-value)) |
|
26 |
- |
|
27 |
-#+nil |
|
28 |
-(defmethod sequence:adjust-sequence ((sequence collection) length &key initial-element initial-contents) |
|
29 |
- (let ((result (duplicate-collection sequence))) |
|
30 |
- (when (or initial-element initial-contents) |
|
31 |
- (setf (items result) |
|
32 |
- (sequence:adjust-sequence (items result) length |
|
33 |
- :initial-element initial-element |
|
34 |
- :initial-contents initial-contents))) |
|
35 |
- result)) |
|
36 |
- |
|
37 |
-#+sbcl |
|
38 |
-(defmethod sb-sequence:adjust-sequence ((sequence collection) length &key initial-element initial-contents) |
|
39 |
- (let ((result (duplicate-collection sequence))) |
|
40 |
- (when (or initial-element initial-contents) |
|
41 |
- (setf (items result) |
|
42 |
- (sb-sequence:adjust-sequence (items result) length |
|
43 |
- :initial-element initial-element |
|
44 |
- :initial-contents initial-contents))) |
|
45 |
- result)) |
|
46 |
- |
|
47 |
-#+nil |
|
48 |
-(defmethod sequence:make-sequence-like ((sequence collection) length &key initial-element initial-contents) |
|
49 |
- (let ((result (duplicate-collection sequence))) |
|
50 |
- (setf (items result) |
|
51 |
- (sequence:make-sequence-like (items result) length |
|
52 |
- :initial-element initial-element |
|
53 |
- :initial-contents initial-contents)) |
|
54 |
- result)) |
|
55 |
- |
|
56 |
-#+sbcl |
|
57 |
-(defmethod sb-sequence:make-sequence-like ((sequence collection) length &key initial-element initial-contents) |
|
58 |
- (let ((result (duplicate-collection sequence))) |
|
59 |
- (setf (items result) |
|
60 |
- (sb-sequence:make-sequence-like (items result) length |
|
61 |
- :initial-element initial-element |
|
62 |
- :initial-contents initial-contents)) |
|
63 |
- result)) |
|
64 |
- |
65 | 0 |
deleted file mode 100644 |
... | ... |
@@ -1,68 +0,0 @@ |
1 |
-(in-package :collection-class) |
|
2 |
- |
|
3 |
-(defclass collection (standard-object #+sbcl sequence) |
|
4 |
- ()) |
|
5 |
- |
|
6 |
-(define-condition value-error () |
|
7 |
- ((value :initarg :value :accessor value))) |
|
8 |
- |
|
9 |
-(defgeneric push-item (collection item) |
|
10 |
- (:documentation "Push item onto the beginning of the collection")) |
|
11 |
- |
|
12 |
-(defgeneric items (collection) |
|
13 |
- (:documentation "Get the items from a collection")) |
|
14 |
- |
|
15 |
-(defgeneric duplicate-collection (collection)) |
|
16 |
- |
|
17 |
-(defgeneric copy-instance (object &rest initargs &key &allow-other-keys) |
|
18 |
- (:documentation "Makes and returns a shallow copy of OBJECT. |
|
19 |
- |
|
20 |
- An uninitialized object of the same class as OBJECT is allocated by |
|
21 |
- calling ALLOCATE-INSTANCE. For all slots returned by |
|
22 |
- CLASS-SLOTS, the returned object has the |
|
23 |
- same slot values and slot-unbound status as OBJECT. |
|
24 |
- |
|
25 |
- REINITIALIZE-INSTANCE is called to update the copy with INITARGS.") |
|
26 |
- (:method ((object standard-object) &rest initargs &key &allow-other-keys) |
|
27 |
- (let* ((class (class-of object)) |
|
28 |
- (copy (allocate-instance class))) |
|
29 |
- (dolist (slot-name (mapcar #'closer-mop:slot-definition-name (closer-mop:class-slots class))) |
|
30 |
- (when (slot-boundp object slot-name) |
|
31 |
- (setf (slot-value copy slot-name) |
|
32 |
- (slot-value object slot-name)))) |
|
33 |
- (apply #'reinitialize-instance copy initargs)))) |
|
34 |
- |
|
35 |
- |
|
36 |
-; TODO: actually use item-class... |
|
37 |
-; TODO: finish initform handling. Have to figure out how to make initform work with push-item |
|
38 |
-(defmacro define-collection ((name item-class &key (initform '(list))) (&rest supers) &body ((&rest slots) &rest other-stuff)) |
|
39 |
- (with-gensyms (item-slot-sym) |
|
40 |
- `(progn (defclass ,name (,@supers collection) |
|
41 |
- ((,item-slot-sym :initform ,initform :accessor items) |
|
42 |
- ,@slots) |
|
43 |
- ,@other-stuff) |
|
44 |
- (defmethod duplicate-collection ((collection ,name)) |
|
45 |
- (let ((result (copy-instance collection))) |
|
46 |
- (setf (items result) |
|
47 |
- (copy-seq (items result))) |
|
48 |
- result)) |
|
49 |
- (defmethod push-item ((collection ,name) (item ,item-class)) |
|
50 |
- (push item (items collection)))))) |
|
51 |
- |
|
52 |
-(defclass collection-iterator (for:iterator) |
|
53 |
- ()) |
|
54 |
- |
|
55 |
-(defmethod initialize-instance :after ((iterator collection-iterator) &key object) |
|
56 |
- (setf (for:object iterator) |
|
57 |
- (items object))) |
|
58 |
- |
|
59 |
-(defmethod random-item ((collection collection) &optional (random-state *random-state*)) |
|
60 |
- (let* ((length (length (items collection))) |
|
61 |
- (selected-index (random length random-state))) |
|
62 |
- (elt (items collection) |
|
63 |
- selected-index))) |
|
64 |
- |
|
65 |
-(defmethod nth-item ((collection collection) (index integer)) |
|
66 |
- (if (>= index 0) |
|
67 |
- (elt (items collection) index) |
|
68 |
- (error 'value-error :value index))) |
... | ... |
@@ -1,9 +1,5 @@ |
1 | 1 |
;;;; package.lisp |
2 | 2 |
|
3 |
-(defpackage #:collection-class |
|
4 |
- (:use #:cl #:alexandria #:serapeum) |
|
5 |
- (:export collection value-error push-item define-collection random-item nth-item items)) |
|
6 |
- |
|
7 | 3 |
(defpackage :alimenta.render |
8 | 4 |
(:use :cl ) |
9 | 5 |
(:export #:render-feed #:render-item #:add-rendered-item)) |
... | ... |
@@ -46,12 +42,7 @@ |
46 | 42 |
(:use #:cl #:alimenta #:alexandria #:anaphora #:lquery) |
47 | 43 |
(:export #:pull-feed #:fetch-doc-from-url #:fetch-feed-from-url |
48 | 44 |
#:fetch-error #:feed-ambiguous #:no-feed #:with-user-agent |
49 |
- #:skip-feed)) |
|
50 |
- |
|
51 |
-(defmethod asdf:perform ((o asdf:test-op) (s (eql (asdf:find-system :alimenta)))) |
|
52 |
- (asdf:load-system :alimenta) |
|
53 |
- (st:test :package :alimenta) |
|
54 |
- t) |
|
45 |
+ #:skip-feed)) |
|
55 | 46 |
|
56 | 47 |
(defpackage #:alimenta.test-runner |
57 | 48 |
(:use #:cl #:alimenta #:alimenta.atom #:alimenta.discover #:alimenta.pull-feed)) |