-
-
Save victorb/e7622a90db51abc19fe7f602ac6d4d4a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def first-func (fn [log] (log "Hello"))) | |
(def second-func (fn [log] (log "World"))) | |
;; current implementation | |
(defn format-steps [forms] | |
(loop [items forms | |
result []] | |
(if (empty? items) | |
result | |
(let [[n f] items | |
item {:name n :func f}] | |
(recur (drop 2 items) (conj result item)))))) | |
(defmacro defpipeline [n & forms] | |
`(def ~n {:name (name '~n) | |
:steps (format-steps '~forms)})) | |
;;;;; Tests | |
;; creating a pipeline | |
(pipeline/defpipeline simple-pipeline | |
"log1" first-func | |
"log2" second-func) | |
;; expected output | |
(def simple-pipeline-output | |
{:name "simple-pipeline" | |
:steps [{:name "log1" | |
:func first-func} | |
{:name "log2" | |
:func second-func}]}) | |
(deftest creating-pipelines | |
(testing "Simple Pipeline" | |
(is (= simple-pipeline-output simple-pipeline)))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment