Skip to content
Snippets Groups Projects
Commit 64b8c854 authored by Wact B. Prot's avatar Wact B. Prot
Browse files

resolves issue #1

parent 7200ad7f
No related branches found
No related tags found
No related merge requests found
<!DOCTYPE html PUBLIC ""
"">
<html><head><meta charset="UTF-8" /><title>Vl-data-insert 0.2.0</title><link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="css/highlight.css" /><script type="text/javascript" src="js/highlight.min.js"></script><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/page_effects.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html"><span class="project-title"><span class="project-name">Vl-data-insert</span> <span class="project-version">0.2.0</span></span></a></h1></div><div class="sidebar primary"><h3 class="no-link"><span class="inner">Project</span></h3><ul class="index-link"><li class="depth-1 current"><a href="index.html"><div class="inner">Index</div></a></li></ul><h3 class="no-link"><span class="inner">Namespaces</span></h3><ul><li class="depth-1"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>vl-data-insert</span></div></div></li><li class="depth-2 branch"><a href="vl-data-insert.core.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>core</span></div></a></li><li class="depth-2"><a href="vl-data-insert.utils.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>utils</span></div></a></li></ul></div><div class="namespace-index" id="content"><h1><span class="project-title"><span class="project-name">Vl-data-insert</span> <span class="project-version">0.2.0</span></span></h1><div class="doc"><p>Functions to insert vaclab style data in vaclab style database documents.</p></div><h2>Installation</h2><p>To install, add the following dependency to your project or build file:</p><pre class="deps">[org.clojars.wactbprot/vl-data-insert "0.2.0"]</pre><h2>Namespaces</h2><div class="namespace"><h3><a href="vl-data-insert.core.html">vl-data-insert.core</a></h3><div class="doc"><pre class="plaintext"></pre></div><div class="index"><p>Public variables and functions:</p><ul><li> <a href="vl-data-insert.core.html#var-append-and-replace">append-and-replace</a> </li><li> <a href="vl-data-insert.core.html#var-fit-in-struct">fit-in-struct</a> </li><li> <a href="vl-data-insert.core.html#var-store-result">store-result</a> </li><li> <a href="vl-data-insert.core.html#var-store-results">store-results</a> </li><li> <a href="vl-data-insert.core.html#var-vector-vals">vector-vals</a> </li></ul></div></div><div class="namespace"><h3><a href="vl-data-insert.utils.html">vl-data-insert.utils</a></h3><div class="doc"><pre class="plaintext"></pre></div><div class="index"><p>Public variables and functions:</p><ul><li> <a href="vl-data-insert.utils.html#var-append-if">append-if</a> </li><li> <a href="vl-data-insert.utils.html#var-ensure-map">ensure-map</a> </li><li> <a href="vl-data-insert.utils.html#var-ensure-vec">ensure-vec</a> </li><li> <a href="vl-data-insert.utils.html#var-path-.3Ekw-vec">path-&gt;kw-vec</a> </li><li> <a href="vl-data-insert.utils.html#var-replace-if">replace-if</a> </li><li> <a href="vl-data-insert.utils.html#var-vector-if">vector-if</a> </li></ul></div></div></div></body></html>
\ No newline at end of file
<html><head><meta charset="UTF-8" /><title>Vl-data-insert 0.2.0</title><link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="css/highlight.css" /><script type="text/javascript" src="js/highlight.min.js"></script><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/page_effects.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html"><span class="project-title"><span class="project-name">Vl-data-insert</span> <span class="project-version">0.2.0</span></span></a></h1></div><div class="sidebar primary"><h3 class="no-link"><span class="inner">Project</span></h3><ul class="index-link"><li class="depth-1 current"><a href="index.html"><div class="inner">Index</div></a></li></ul><h3 class="no-link"><span class="inner">Namespaces</span></h3><ul><li class="depth-1"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>vl-data-insert</span></div></div></li><li class="depth-2 branch"><a href="vl-data-insert.core.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>core</span></div></a></li><li class="depth-2"><a href="vl-data-insert.utils.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>utils</span></div></a></li></ul></div><div class="namespace-index" id="content"><h1><span class="project-title"><span class="project-name">Vl-data-insert</span> <span class="project-version">0.2.0</span></span></h1><div class="doc"><p>Functions to insert vaclab style data in vaclab style database documents.</p></div><h2>Installation</h2><p>To install, add the following dependency to your project or build file:</p><pre class="deps">[org.clojars.wactbprot/vl-data-insert "0.2.0"]</pre><h2>Namespaces</h2><div class="namespace"><h3><a href="vl-data-insert.core.html">vl-data-insert.core</a></h3><div class="doc"><pre class="plaintext"></pre></div><div class="index"><p>Public variables and functions:</p><ul><li> <a href="vl-data-insert.core.html#var-append-and-replace">append-and-replace</a> </li><li> <a href="vl-data-insert.core.html#var-fit-in-struct">fit-in-struct</a> </li><li> <a href="vl-data-insert.core.html#var-store-result">store-result</a> </li><li> <a href="vl-data-insert.core.html#var-store-results">store-results</a> </li><li> <a href="vl-data-insert.core.html#var-vector-vals">vector-vals</a> </li></ul></div></div><div class="namespace"><h3><a href="vl-data-insert.utils.html">vl-data-insert.utils</a></h3><div class="doc"><pre class="plaintext"></pre></div><div class="index"><p>Public variables and functions:</p><ul><li> <a href="vl-data-insert.utils.html#var-append-if">append-if</a> </li><li> <a href="vl-data-insert.utils.html#var-check-kw">check-kw</a> </li><li> <a href="vl-data-insert.utils.html#var-ensure-map">ensure-map</a> </li><li> <a href="vl-data-insert.utils.html#var-ensure-vec">ensure-vec</a> </li><li> <a href="vl-data-insert.utils.html#var-path-.3Ekw-vec">path-&gt;kw-vec</a> </li><li> <a href="vl-data-insert.utils.html#var-replace-if">replace-if</a> </li><li> <a href="vl-data-insert.utils.html#var-vector-if">vector-if</a> </li></ul></div></div></div></body></html>
\ No newline at end of file
<!DOCTYPE html PUBLIC ""
"">
<html><head><meta charset="UTF-8" /><title>vl-data-insert.core documentation</title><link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="css/highlight.css" /><script type="text/javascript" src="js/highlight.min.js"></script><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/page_effects.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html"><span class="project-title"><span class="project-name">Vl-data-insert</span> <span class="project-version">0.2.0</span></span></a></h1></div><div class="sidebar primary"><h3 class="no-link"><span class="inner">Project</span></h3><ul class="index-link"><li class="depth-1 "><a href="index.html"><div class="inner">Index</div></a></li></ul><h3 class="no-link"><span class="inner">Namespaces</span></h3><ul><li class="depth-1"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>vl-data-insert</span></div></div></li><li class="depth-2 branch current"><a href="vl-data-insert.core.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>core</span></div></a></li><li class="depth-2"><a href="vl-data-insert.utils.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>utils</span></div></a></li></ul></div><div class="sidebar secondary"><h3><a href="#top"><span class="inner">Public Vars</span></a></h3><ul><li class="depth-1"><a href="vl-data-insert.core.html#var-append-and-replace"><div class="inner"><span>append-and-replace</span></div></a></li><li class="depth-1"><a href="vl-data-insert.core.html#var-fit-in-struct"><div class="inner"><span>fit-in-struct</span></div></a></li><li class="depth-1"><a href="vl-data-insert.core.html#var-store-result"><div class="inner"><span>store-result</span></div></a></li><li class="depth-1"><a href="vl-data-insert.core.html#var-store-results"><div class="inner"><span>store-results</span></div></a></li><li class="depth-1"><a href="vl-data-insert.core.html#var-vector-vals"><div class="inner"><span>vector-vals</span></div></a></li></ul></div><div class="namespace-docs" id="content"><h1 class="anchor" id="top">vl-data-insert.core</h1><div class="doc"><pre class="plaintext"></pre></div><div class="public anchor" id="var-append-and-replace"><h3>append-and-replace</h3><div class="usage"><code>(append-and-replace struct {t :Type, v :Value, u :Unit, n :N, s :SdValue})</code></div><div class="doc"><pre class="plaintext">Append `:Value`, `:SdValue` and `:N` if present. Relaces `:Type` and
<html><head><meta charset="UTF-8" /><title>vl-data-insert.core documentation</title><link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="css/highlight.css" /><script type="text/javascript" src="js/highlight.min.js"></script><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/page_effects.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html"><span class="project-title"><span class="project-name">Vl-data-insert</span> <span class="project-version">0.2.0</span></span></a></h1></div><div class="sidebar primary"><h3 class="no-link"><span class="inner">Project</span></h3><ul class="index-link"><li class="depth-1 "><a href="index.html"><div class="inner">Index</div></a></li></ul><h3 class="no-link"><span class="inner">Namespaces</span></h3><ul><li class="depth-1"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>vl-data-insert</span></div></div></li><li class="depth-2 branch current"><a href="vl-data-insert.core.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>core</span></div></a></li><li class="depth-2"><a href="vl-data-insert.utils.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>utils</span></div></a></li></ul></div><div class="sidebar secondary"><h3><a href="#top"><span class="inner">Public Vars</span></a></h3><ul><li class="depth-1"><a href="vl-data-insert.core.html#var-append-and-replace"><div class="inner"><span>append-and-replace</span></div></a></li><li class="depth-1"><a href="vl-data-insert.core.html#var-fit-in-struct"><div class="inner"><span>fit-in-struct</span></div></a></li><li class="depth-1"><a href="vl-data-insert.core.html#var-store-result"><div class="inner"><span>store-result</span></div></a></li><li class="depth-1"><a href="vl-data-insert.core.html#var-store-results"><div class="inner"><span>store-results</span></div></a></li><li class="depth-1"><a href="vl-data-insert.core.html#var-vector-vals"><div class="inner"><span>vector-vals</span></div></a></li></ul></div><div class="namespace-docs" id="content"><h1 class="anchor" id="top">vl-data-insert.core</h1><div class="doc"><pre class="plaintext"></pre></div><div class="public anchor" id="var-append-and-replace"><h3>append-and-replace</h3><div class="usage"><code>(append-and-replace struct m)</code></div><div class="doc"><pre class="plaintext">Append `:Value`, `:SdValue` and `:N` if present. Relaces `:Type` and
`:Unit`.</pre></div></div><div class="public anchor" id="var-fit-in-struct"><h3>fit-in-struct</h3><div class="usage"><code>(fit-in-struct s m)</code></div><div class="doc"><pre class="plaintext">Fits `m` into the given structure `s`. Function looks up the
`:Type` of `m`. If a structure with the same `:Type` exist
[[append-and-replace]] is called.</pre></div></div><div class="public anchor" id="var-store-result"><h3>store-result</h3><div class="usage"><code>(store-result d x p)</code></div><div class="doc"><pre class="plaintext">Stores the result `x`(ensured to be a map `m`) in the given
......@@ -40,7 +40,5 @@ Example:
;; :Value [0 0 0 0 0],
;; :SdValue [0 0 0 0 0],
;; :N [1 1 1 1 1]}]}}}}
```
</pre></div></div><div class="public anchor" id="var-vector-vals"><h3>vector-vals</h3><div class="usage"><code>(vector-vals m)</code></div><div class="doc"><pre class="plaintext">Ensures that the values of `:Value`,`:SdValue` and `:N` are
```</pre></div></div><div class="public anchor" id="var-vector-vals"><h3>vector-vals</h3><div class="usage"><code>(vector-vals m)</code></div><div class="doc"><pre class="plaintext">Ensures that the values of `:Value`,`:SdValue` and `:N` are
vectors.</pre></div></div></div></body></html>
\ No newline at end of file
<!DOCTYPE html PUBLIC ""
"">
<html><head><meta charset="UTF-8" /><title>vl-data-insert.utils documentation</title><link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="css/highlight.css" /><script type="text/javascript" src="js/highlight.min.js"></script><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/page_effects.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html"><span class="project-title"><span class="project-name">Vl-data-insert</span> <span class="project-version">0.2.0</span></span></a></h1></div><div class="sidebar primary"><h3 class="no-link"><span class="inner">Project</span></h3><ul class="index-link"><li class="depth-1 "><a href="index.html"><div class="inner">Index</div></a></li></ul><h3 class="no-link"><span class="inner">Namespaces</span></h3><ul><li class="depth-1"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>vl-data-insert</span></div></div></li><li class="depth-2 branch"><a href="vl-data-insert.core.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>core</span></div></a></li><li class="depth-2 current"><a href="vl-data-insert.utils.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>utils</span></div></a></li></ul></div><div class="sidebar secondary"><h3><a href="#top"><span class="inner">Public Vars</span></a></h3><ul><li class="depth-1"><a href="vl-data-insert.utils.html#var-append-if"><div class="inner"><span>append-if</span></div></a></li><li class="depth-1"><a href="vl-data-insert.utils.html#var-ensure-map"><div class="inner"><span>ensure-map</span></div></a></li><li class="depth-1"><a href="vl-data-insert.utils.html#var-ensure-vec"><div class="inner"><span>ensure-vec</span></div></a></li><li class="depth-1"><a href="vl-data-insert.utils.html#var-path-.3Ekw-vec"><div class="inner"><span>path-&gt;kw-vec</span></div></a></li><li class="depth-1"><a href="vl-data-insert.utils.html#var-replace-if"><div class="inner"><span>replace-if</span></div></a></li><li class="depth-1"><a href="vl-data-insert.utils.html#var-vector-if"><div class="inner"><span>vector-if</span></div></a></li></ul></div><div class="namespace-docs" id="content"><h1 class="anchor" id="top">vl-data-insert.utils</h1><div class="doc"><pre class="plaintext"></pre></div><div class="public anchor" id="var-append-if"><h3>append-if</h3><div class="usage"><code>(append-if m k v)</code></div><div class="doc"><pre class="plaintext">Appends `v` to the value of `k`. If `k` does not exist in `m`,
<html><head><meta charset="UTF-8" /><title>vl-data-insert.utils documentation</title><link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="css/highlight.css" /><script type="text/javascript" src="js/highlight.min.js"></script><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/page_effects.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html"><span class="project-title"><span class="project-name">Vl-data-insert</span> <span class="project-version">0.2.0</span></span></a></h1></div><div class="sidebar primary"><h3 class="no-link"><span class="inner">Project</span></h3><ul class="index-link"><li class="depth-1 "><a href="index.html"><div class="inner">Index</div></a></li></ul><h3 class="no-link"><span class="inner">Namespaces</span></h3><ul><li class="depth-1"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>vl-data-insert</span></div></div></li><li class="depth-2 branch"><a href="vl-data-insert.core.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>core</span></div></a></li><li class="depth-2 current"><a href="vl-data-insert.utils.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>utils</span></div></a></li></ul></div><div class="sidebar secondary"><h3><a href="#top"><span class="inner">Public Vars</span></a></h3><ul><li class="depth-1"><a href="vl-data-insert.utils.html#var-append-if"><div class="inner"><span>append-if</span></div></a></li><li class="depth-1"><a href="vl-data-insert.utils.html#var-check-kw"><div class="inner"><span>check-kw</span></div></a></li><li class="depth-1"><a href="vl-data-insert.utils.html#var-ensure-map"><div class="inner"><span>ensure-map</span></div></a></li><li class="depth-1"><a href="vl-data-insert.utils.html#var-ensure-vec"><div class="inner"><span>ensure-vec</span></div></a></li><li class="depth-1"><a href="vl-data-insert.utils.html#var-path-.3Ekw-vec"><div class="inner"><span>path-&gt;kw-vec</span></div></a></li><li class="depth-1"><a href="vl-data-insert.utils.html#var-replace-if"><div class="inner"><span>replace-if</span></div></a></li><li class="depth-1"><a href="vl-data-insert.utils.html#var-vector-if"><div class="inner"><span>vector-if</span></div></a></li></ul></div><div class="namespace-docs" id="content"><h1 class="anchor" id="top">vl-data-insert.utils</h1><div class="doc"><pre class="plaintext"></pre></div><div class="public anchor" id="var-append-if"><h3>append-if</h3><div class="usage"><code>(append-if m k v)</code></div><div class="doc"><pre class="plaintext">Appends `v` to the value of `k`. If `k` does not exist in `m`,
`k [v]` is assoced. If `k` does exist in `m`, `v` is conjed.
Example:
```clojure
(append-if {:Value [1 2 3]} :Value 4)
;; {:Value [1 2 3 4]}
```</pre></div></div><div class="public anchor" id="var-ensure-map"><h3>ensure-map</h3><div class="usage"><code>(ensure-map x v)</code></div><div class="doc"><pre class="plaintext">Ensures `x`to be a map. If `x` is a value a map is constucted from
```</pre></div></div><div class="public anchor" id="var-check-kw"><h3>check-kw</h3><div class="usage"><code>(check-kw m kw)</code></div><div class="doc"><pre class="plaintext"></pre></div></div><div class="public anchor" id="var-ensure-map"><h3>ensure-map</h3><div class="usage"><code>(ensure-map x v)</code></div><div class="doc"><pre class="plaintext">Ensures `x`to be a map. If `x` is a value a map is constucted from
the last keyword and the value.
Example:
......@@ -18,13 +18,20 @@ Example:
(ensure-map {:d 10} [:a :b :c])
;; =&gt;
;; [{:d 10} [:a :b :c]]
```
</pre></div></div><div class="public anchor" id="var-ensure-vec"><h3>ensure-vec</h3><div class="usage"><code>(ensure-vec v)</code></div><div class="doc"><pre class="plaintext">Ensures that `v` is a vector.
```</pre></div></div><div class="public anchor" id="var-ensure-vec"><h3>ensure-vec</h3><div class="usage"><code>(ensure-vec v)</code></div><div class="doc"><pre class="plaintext">Ensures that `v` is a vector even if `v` is `nil`.
Example:
```clojure
(ensure-vec nil) ;!
;; nil
;; important:
(ensure-vec nil)
;;=&gt; [nil]
;; ^^ because:
(concat [1 2] nil)
;; =&gt; (1 2) ; but we need:
(concat [1 2] [nil])
;; =&gt; (1 2 nil)
;; to ensure that all
;; Value-vectors keep the same length
(ensure-vec 1)
;; [1]
(ensure-vec [1])
......@@ -42,5 +49,5 @@ Example:
(replace-if {:Type "a"} :Type "b")
;; {:Type "b"}
```
</pre></div></div><div class="public anchor" id="var-vector-if"><h3>vector-if</h3><div class="usage"><code>(vector-if m kw)</code></div><div class="doc"><pre class="plaintext">Makes the value `v` behind the keyword `kw` a vector if `v` is not
nil.</pre></div></div></div></body></html>
\ No newline at end of file
</pre></div></div><div class="public anchor" id="var-vector-if"><h3>vector-if</h3><div class="usage"><code>(vector-if m kw)</code></div><div class="doc"><pre class="plaintext">Makes the value `v` of keyword `kw` a vector also if `v` is `nil`.
</pre></div></div></div></body></html>
\ No newline at end of file
......@@ -16,37 +16,37 @@
</tr></thead>
<tr>
<td><a href="vl_data_insert/core.clj.html">vl-data-insert.core</a></td><td class="with-bar"><div class="covered"
style="width:99.38271604938272%;
float:left;"> 161 </div><div class="not-covered"
style="width:0.6172839506172839%;
style="width:99.4475138121547%;
float:left;"> 180 </div><div class="not-covered"
style="width:0.5524861878453039%;
float:left;"> 1 </div></td>
<td class="with-number">99,38 %</td>
<td class="with-number">99,45 %</td>
<td class="with-bar"><div class="covered"
style="width:96.875%;
float:left;"> 31 </div><div class="partial"
style="width:3.125%;
style="width:96.96969696969697%;
float:left;"> 32 </div><div class="partial"
style="width:3.0303030303030303%;
float:left;"> 1 </div></td>
<td class="with-number">100,00 %</td>
<td class="with-number">98</td><td class="with-number">8</td><td class="with-number">32</td>
<td class="with-number">97</td><td class="with-number">7</td><td class="with-number">33</td>
</tr>
<tr>
<td><a href="vl_data_insert/utils.clj.html">vl-data-insert.utils</a></td><td class="with-bar"><div class="covered"
style="width:99.24242424242425%;
float:left;"> 131 </div><div class="not-covered"
style="width:0.7575757575757576%;
style="width:99.1869918699187%;
float:left;"> 122 </div><div class="not-covered"
style="width:0.8130081300813008%;
float:left;"> 1 </div></td>
<td class="with-number">99,24 %</td>
<td class="with-number">99,19 %</td>
<td class="with-bar"><div class="covered"
style="width:95.45454545454545%;
float:left;"> 21 </div><div class="partial"
style="width:4.545454545454546%;
style="width:95.65217391304348%;
float:left;"> 22 </div><div class="partial"
style="width:4.3478260869565215%;
float:left;"> 1 </div></td>
<td class="with-number">100,00 %</td>
<td class="with-number">86</td><td class="with-number">11</td><td class="with-number">22</td>
<td class="with-number">94</td><td class="with-number">12</td><td class="with-number">23</td>
</tr>
<tr><td>Totals:</td>
<td class="with-bar"></td>
<td class="with-number">99,32 %</td>
<td class="with-number">99,34 %</td>
<td class="with-bar"></td>
<td class="with-number">100,00 %</td>
</tr>
......
This diff is collapsed.
This diff is collapsed.
(defproject org.clojars.wactbprot/vl-data-insert "0.2.0"
(defproject org.clojars.wactbprot/vl-data-insert "0.2.1"
:description "Functions to insert vaclab style data in vaclab style database documents."
:url "https://github.com/wactbprot/vl-data-insert"
:dependencies [[org.clojure/clojure "1.10.0"]]
......
......@@ -20,14 +20,15 @@
(defn append-and-replace
"Append `:Value`, `:SdValue` and `:N` if present. Relaces `:Type` and
`:Unit`."
[struct {t :Type v :Value u :Unit n :N s :SdValue}]
(->
(-> struct
(u/replace-if :Type t)
(u/replace-if :Unit u))
(u/append-if :Value v)
(u/append-if :SdValue s)
(u/append-if :N n)))
[struct m]
(let [{t :Type v :Value u :Unit n :N s :SdValue} m]
(->
(-> struct
(u/replace-if (u/check-kw m :Type) t)
(u/replace-if (u/check-kw m :Unit) u))
(u/append-if (u/check-kw m :Value) v)
(u/append-if (u/check-kw m :SdValue) s)
(u/append-if (u/check-kw m :N) n))))
(defn fit-in-struct
"Fits `m` into the given structure `s`. Function looks up the
......@@ -49,13 +50,13 @@
forward (see [[vl-data-insert/test/cmp/doc_test.clj]] for details)."
[d x p]
(let [[m v] (u/ensure-map x (u/path->kw-vec p))]
(if (and (:Type m) (:Value m))
(if-let [s (get-in d v)]
(assoc-in d v (fit-in-struct s m))
(assoc-in d v [(vector-vals m)]))
(if-let [s (get-in d v)]
(assoc-in d v (merge s m))
(assoc-in d v m)))))
(if (and (contains? m :Type) (contains? m :Value))
(if-let [s (get-in d v)]
(assoc-in d v (fit-in-struct s m))
(assoc-in d v [(vector-vals m)]))
(if-let [s (get-in d v)]
(assoc-in d v (merge s m))
(assoc-in d v m)))))
(defn store-results
"Takes a vector of maps. Calls `store-result` on each map.
......@@ -91,8 +92,6 @@
;; :Value [0 0 0 0 0],
;; :SdValue [0 0 0 0 0],
;; :N [1 1 1 1 1]}]}}}}
```
"
```"
[doc v p]
(reduce (fn [doc m] (store-result doc m p)) doc v))
......@@ -3,6 +3,8 @@
:doc "Utils for data insert tasks."}
(:require [clojure.string :as string]))
(defn check-kw [m kw] (when (contains? m kw) kw))
(defn ensure-map
"Ensures `x`to be a map. If `x` is a value a map is constucted from
the last keyword and the value.
......@@ -15,31 +17,37 @@
(ensure-map {:d 10} [:a :b :c])
;; =>
;; [{:d 10} [:a :b :c]]
```
"
```"
[x v]
(if (map? x)
[x v]
[{(last v) x} (into [] (butlast v))]))
(defn ensure-vec
"Ensures that `v` is a vector.
"Ensures that `v` is a vector even if `v` is `nil`.
Example:
```clojure
(ensure-vec nil) ;!
;; nil
;; important:
(ensure-vec nil)
;;=> [nil]
;; ^^ because:
(concat [1 2] nil)
;; => (1 2) ; but we need:
(concat [1 2] [nil])
;; => (1 2 nil)
;; to ensure that all
;; Value-vectors keep the same length
(ensure-vec 1)
;; [1]
(ensure-vec [1])
;; [1]
```"
[v]
(when v (if (vector? v) v [v])))
(if (vector? v) v [v]))
(defn vector-if
"Makes the value `v` behind the keyword `kw` a vector if `v` is not
nil."
"Makes the value `v` of keyword `kw` a vector also if `v` is `nil`."
[m kw]
(if (and (map? m) (keyword? kw))
(if-let [v (kw m)] (assoc m kw (ensure-vec v)) m)))
......@@ -54,7 +62,7 @@
```
"
[m k v]
(if (and (some? v) (keyword? k)) (assoc m k v) m))
(if (keyword? k) (assoc m k v) m))
(defn append-if
"Appends `v` to the value of `k`. If `k` does not exist in `m`,
......@@ -66,7 +74,7 @@
;; {:Value [1 2 3 4]}
```"
[m k v]
(if (and (some? v) (keyword? k))
(if (keyword? k)
(let [new-v (ensure-vec v)]
(if-let [old-v (k m)]
(assoc m k (into [] (concat old-v new-v)))
......
......@@ -52,12 +52,11 @@
(def doc2 {:Calibration
{:Measurement
{:Values
{:Pressure [
{:Type "a"
:Unit "b"
:Value [0]
:SdValue [0]
:N [1]}]}}}})
{:Pressure [{:Type "a"
:Unit "b"
:Value [0]
:SdValue [0]
:N [1]}]}}}})
(def p1 "Calibration.Measurement.Values.Pressure")
(def p2 "Calibration.Measurement.Values.not-there")
......@@ -166,28 +165,25 @@
1)))
"Map is inserted and values become vectors.")))
(comment
(def doc3 {:Calibration
{:Measurement
{:Values
{:Pressure [
{:Type "a"
(def doc3 {:Calibration
{:Measurement
{:Values
{:Pressure [{:Type "a"
:Unit "b"
:Value [0]
:SdValue [0]
:N [1]}]}}}})
(def m-val-nil {:Type "b" :Unit "b" :Value nil :SdValue nil :N nil})
(def p3 "Calibration.Measurement.Values.Pressure")
(def m-val-3 {:Type "a" :Unit "b" :Value nil :SdValue nil :N nil})
(def p5 "Calibration.Measurement.Values.Pressure")
(deftest store-results-ii
(testing "value is nil"
(is (map? (store-results doc1 [] p1))
"Values got attached if they have equal Types.")))
(store-results doc3 [m-val-nil] p3)
{:Calibration
{:Measurement
{:Values
{:Pressure
[{:Type "a", :Unit "b", :Value [0], :SdValue [0], :N [1]}
{:Type "b", :Unit "b", :Value nil, :SdValue nil, :N nil}]}}}})
\ No newline at end of file
(deftest store-results-ii
(testing "nil value"
(let [d (store-results doc3 [m-val-3] p5)]
(is (= [0 nil] (get-in d [:Calibration :Measurement :Values :Pressure 0 :Value]))
"is appended.")
(is (= [0 nil] (get-in d [:Calibration :Measurement :Values :Pressure 0 :SdValue]))
"is appended.")
(is (= [1 nil] (get-in d [:Calibration :Measurement :Values :Pressure 0 :N]))
"is appended."))))
......@@ -23,3 +23,8 @@
(testing "Path translation (i)"
(is (= v1 (path->kw-vec p1))
"Translates path to keyword vector.")))
(deftest ensure-vec-i
(testing "vector is ensured (i)"
(is (vector? (ensure-vec nil))
"nil is a valid value.")))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment