Commit 88aadbbf authored by Ole Voldsæter's avatar Ole Voldsæter
Browse files

Merge branch '21-diff-it' into 'develop'

Resolve "Create a variable list diff ('order' etc.)"

Closes #21

See merge request c2metadata/stata-sdtl-converter!12
parents 20a9e83c 6998826f
......@@ -10,6 +10,7 @@
[compojure "1.5.1"]
[instaparse "1.4.9"]
[cheshire "5.5.0"]
[clj-diff "1.0.0-SNAPSHOT"]
:uberjar-name "stata2sdtl-standalone.jar"
:profiles {:uberjar {:aot :all}}
......@@ -87,11 +87,13 @@
:software "stata"
:mod-other-vars (assoc *other-vars* filename *variables*)})
:quoted_use_arg (fn [& args] (first args))
:order_vars (fn [& [varlist method]]
{:command "order"
:variables (expand-varlist varlist *variables*)
:how (keys method)
:mod-varlist (reorder-variables (expand-varlist varlist *variables*) method)})
:order_vars (fn [& [varlist options]]
(let [newlist (reorder-variables (expand-varlist varlist *variables*) options)]
{:command "order"
:variables (expand-varlist varlist *variables*)
:how (keys options)
:result (diff-varlists *variables* newlist)
:mod-varlist newlist}))
:format_vars (fn [& args] {:command "setDisplayFormat"
:format (if (-> args first string?) (first args) (second args))
:variables (expand-varlist (if (-> args first string?) (second args) (first args)) *variables*)})
(ns ^{
:author "Ole Voldsæter"
:doc "Misc. functions and dynamic variables"
} stata2sdtl.utils)
} stata2sdtl.utils
[clj-diff.core :refer [diff]])
(def ^:dynamic *variables* [])
(def ^:dynamic *codelists* {})
......@@ -101,4 +104,10 @@
(defn diff-varlists [old-list new-list]
(let [result (diff old-list new-list)]
{:additions (map (fn [e] {:index (first e) :names (rest e)}) (:+ result))
:deletions (:- result)})
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment