From 0f9dddacee814fd583baf28dfebb54911f6fc73e Mon Sep 17 00:00:00 2001 From: John Wiseman Date: Wed, 18 Dec 2019 09:21:51 -0800 Subject: [PATCH] Working toward varref psths in generation. --- src/main/lemondronor/circlebot/generation.cljc | 8 ++++++++ src/main/lemondronor/circlebot/pelias.cljs | 2 +- src/test/lemondronor/circlebot/generation_test.cljs | 11 +++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main/lemondronor/circlebot/generation.cljc b/src/main/lemondronor/circlebot/generation.cljc index 300e813..5024cbe 100644 --- a/src/main/lemondronor/circlebot/generation.cljc +++ b/src/main/lemondronor/circlebot/generation.cljc @@ -47,6 +47,14 @@ (defmulti expand% (fn [template data] (first template))) +;; (defmethod expand% :varref [template data] +;; (let [var (keyword (second template)) +;; var-path (string/split var #"\.") +;; val (get-in data var-path)] +;; (if (or (nil? val) (= val "")) +;; '() +;; (list {:varrefs [var] :text (str (data var))})))) + (defmethod expand% :varref [template data] (let [var (keyword (second template)) val (data var)] diff --git a/src/main/lemondronor/circlebot/pelias.cljs b/src/main/lemondronor/circlebot/pelias.cljs index 3427503..b809c3c 100644 --- a/src/main/lemondronor/circlebot/pelias.cljs +++ b/src/main/lemondronor/circlebot/pelias.cljs @@ -11,7 +11,7 @@ (logging/deflog "pelias" logger) -(def base-pelias-url "http://raytheon.local:4000/v1") + (def base-pelias-url "http://lockheed.local:4000/v1") ;; Does an HTTP GET to a pelias API url. Returns a promise that diff --git a/src/test/lemondronor/circlebot/generation_test.cljs b/src/test/lemondronor/circlebot/generation_test.cljs index d9be395..afa0101 100644 --- a/src/test/lemondronor/circlebot/generation_test.cljs +++ b/src/test/lemondronor/circlebot/generation_test.cljs @@ -64,3 +64,14 @@ :country "Country"} {:neighborhood 5 :locality 2}))))) + + +(deftest var-paths + (is (= "Hello, John" + (generation/generate + [(generation/parse-template "Hello, {person.name}")] + {:person {:name "John"}}))) + (is (= 9 + (generation/generate + [(generation/parse-template "Hello, {person.name}")] + {:person {:age 49}}))))