Skip to content

Commit fef3431

Browse files
committed
Cleanup
* Test coverage is around 100% * JS bundle now 177K size * More detailed exceptions * Stable parser
1 parent e231b7c commit fef3431

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2022
-3460
lines changed

.circleci/config.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
name: Test with clojure 1.9
3030
type: shell
3131
command: |
32-
clojure -A:with-optional-deps:test:coverage
32+
clojure -A:test:coverage
3333
bash <(curl -s https://codecov.io/bash)
3434
3535
- save_cache:
@@ -51,7 +51,7 @@ jobs:
5151
name: Test with clojure 1.10-master
5252
type: shell
5353
command: |
54-
clojure -A:with-optional-deps:master:test:clj-runner
54+
clojure -A:master:test:clj-runner
5555
5656
- save_cache:
5757
paths:
@@ -80,7 +80,7 @@ jobs:
8080
name: Test clojurescript
8181
type: shell
8282
command: |
83-
clojure -A:cljs:with-optional-deps:test:cljs-runner
83+
clojure -A:cljs:test:cljs-runner
8484
8585
- save_cache:
8686
paths:
@@ -102,7 +102,7 @@ jobs:
102102
name: Build JavaScript bundle
103103
type: shell
104104
command: |
105-
clojure -A:with-optional-deps:cljs -m cljs.main -co axel_f.min.js.edn --compile
105+
clojure -A:cljs -m cljs.main -co axel_f.min.js.edn --compile
106106
107107
- run:
108108
name: Prepare workspace for publishing

.dir-locals.el

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
;;; For more information see (info "(emacs) Directory Variables")
33

44
((clojure-mode
5-
(cider-clojure-cli-global-options . "-A:with-optional-deps:bench:test")))
5+
(cider-clojure-cli-global-options . "-A:bench:test")))

axel_f.dev.html

-9
This file was deleted.

axel_f.min.html

-9
This file was deleted.

axel_f.min.js.edn

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
:elide-asserts true
99
:parallel-build true
1010
:checked-arrays :warn
11+
:static-fns true
12+
:fn-invoke-direct true
13+
:warnings {:fn-deprecated false}
14+
:optimize-constants true
1115
:output-wrapper "/**
1216
* Axel-f v0.1.0
1317
*

base64/deps.edn

-1
This file was deleted.

base64/src/axel_f/base64.cljc

-54
This file was deleted.

deps.edn

+6-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
{:deps {org.clojure/clojure {:mvn/version "1.9.0"}}
1+
{:deps {org.clojure/clojure {:mvn/version "1.9.0"}
2+
cheshire {:mvn/version "5.8.1"}}
23

34
:paths ["src"]
45

@@ -9,18 +10,12 @@
910
:aliases
1011
{:master {:override-deps {org.clojure/clojure {:mvn/version "1.10.0-master-SNAPSHOT"}}}
1112

12-
:with-optional-deps {:extra-deps {io.xapix/axel-f.base64 {:local/root "./base64"}
13-
io.xapix/axel-f.json {:local/root "./json"}
14-
io.xapix/axel-f.geo {:local/root "./geo"}}}
15-
1613
:cljs {:extra-deps {org.clojure/clojurescript {:mvn/version "1.10.439"}}}
1714

1815
:cljs-compile {:main-opts ["-m" "cljs.main"
19-
"--watch" "src/axel_f/v2"
20-
"-co" "axel_f.dev.js.edn"
21-
"--compile"
22-
;; "--repl"
23-
]}
16+
"--watch" "src/axel_f/v2"
17+
"-co" "axel_f.dev.js.edn"
18+
"--compile"]}
2419

2520
:bench {:extra-deps {criterium {:mvn/version "0.4.4"}
2621
com.taoensso/tufte {:mvn/version "2.0.1"}}}
@@ -34,7 +29,7 @@
3429
"--test-ns-path" "test"
3530
"--codecov"]}
3631

37-
:cljs-runner {:extra-deps {olical/cljs-test-runner {:mvn/version "2.1.0"}}
32+
:cljs-runner {:extra-deps {olical/cljs-test-runner {:mvn/version "3.4.0"}}
3833
:main-opts ["-m" "cljs-test-runner.main"]}
3934

4035
:clj-runner {:extra-deps {com.cognitect/test-runner

geo/deps.edn

-1
This file was deleted.

json/deps.edn

-3
This file was deleted.

json/src/axel_f/json.cljc

-53
This file was deleted.

pom.xml

+5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
<artifactId>clojure</artifactId>
1212
<version>1.9.0</version>
1313
</dependency>
14+
<dependency>
15+
<groupId>cheshire</groupId>
16+
<artifactId>cheshire</artifactId>
17+
<version>5.8.1</version>
18+
</dependency>
1419
</dependencies>
1520
<build>
1621
<sourceDirectory>src</sourceDirectory>

src/axel_f/api.cljs

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
(ns axel-f.api
2-
(:require [axel-f.core :as axel-f]
3-
axel-f.functions
4-
axel-f.base64
5-
axel-f.json
6-
axel-f.geo))
2+
(:require [axel-f.core :as axel-f]))
73

84
(defn- fix-regex-in-exception [exception-data]
95
(update exception-data

src/axel_f/core.cljc

+18-14
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
(ns axel-f.core
2-
(:require [axel-f.v2.parser :as parser]
3-
[axel-f.v2.runtime :as runtime])
4-
(:refer-clojure :exclude [compile]))
2+
(:refer-clojure :exclude [compile])
3+
(:require [axel-f.lexer :as lexer]
4+
[axel-f.parser :as parser]
5+
[axel-f.runtime :as runtime]
6+
[axel-f.functions :as core]))
57

68
(defn compile [formula & _]
7-
(parser/parse formula))
9+
(-> formula
10+
lexer/read-formula
11+
parser/parse
12+
runtime/eval))
813

9-
(defn run [formula & [context]]
10-
(let [ast (cond
11-
(string? formula)
12-
(compile formula)
14+
(defn ^:deprecated run [formula & [context]]
15+
(let [f (cond
16+
(string? formula)
17+
(compile formula)
1318

14-
(map? formula)
15-
formula
19+
(fn? formula)
20+
formula
1621

17-
:otherwise
18-
(throw (ex-info (str "`formula` must be a string or precompiled string, got `" (type formula) "` instead.")
19-
{:formula formula})))]
20-
((runtime/eval ast) context)))
22+
:otherwise
23+
(throw (ex-info "Formula must be a string or precompiled expression." {})))]
24+
(f context)))

src/axel_f/functions.cljc

+5-11
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
11
(ns axel-f.functions
2-
(:require [clojure.string :as string]
3-
[axel-f.functions.core :refer [def-excel-fn *functions-store*]]
2+
(:require [axel-f.functions.core :refer [*functions-store*]]
43
axel-f.functions.math
54
axel-f.functions.text
65
axel-f.functions.stat
7-
axel-f.functions.logic))
8-
9-
(def clean
10-
^{:desc "Returns the text with the non-printable ASCII characters removed."
11-
:args [{:desc "The text whose non-printable characters are to be removed."}]}
12-
(fn [text]
13-
(string/replace text #"[\x00-\x1F]" "")))
14-
15-
(def-excel-fn "CLEAN" clean)
6+
axel-f.functions.logic
7+
axel-f.functions.geo
8+
axel-f.functions.json
9+
axel-f.functions.base64))
1610

1711
(defn find-impl [fname]
1812
(get @*functions-store* fname))

src/axel_f/functions/base64.cljc

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
(ns axel-f.functions.base64
2+
(:require [axel-f.functions.core :refer [def-excel-fn]])
3+
#?(:clj (:import java.util.Base64)))
4+
5+
#?(:cljs
6+
(cond
7+
(exists? js/atob)
8+
(def atob js/atob)
9+
10+
(exists? js/Buffer)
11+
(defn atob [s]
12+
(.toString (js/Buffer.from s "base64") "binary"))))
13+
14+
#?(:cljs
15+
(cond
16+
(exists? js/btoa)
17+
(def btoa js/btoa)
18+
19+
(exists? js/Buffer)
20+
(defn btoa [s]
21+
(.toString (js/Buffer.from s "binary") "base64"))))
22+
23+
(def base64-encode
24+
^{:args [{:desc "String to encode"}]
25+
:desc "Creates a base-64 encoded ASCII string from a String"}
26+
(fn [to-encode]
27+
#?(:clj
28+
(.encodeToString (Base64/getEncoder) (.getBytes to-encode))
29+
:cljs
30+
(btoa to-encode))))
31+
32+
(def base64-decode
33+
^{:args [{:desc "String to decode"}]
34+
:desc "Decodes a string of data which has been encoded using base-64 encoding"}
35+
(fn [to-decode]
36+
#?(:clj
37+
(String. (.decode (Base64/getDecoder) to-decode))
38+
:cljs
39+
(atob to-decode))))
40+
41+
(def-excel-fn
42+
"BASE64ENCODE" base64-encode
43+
"BASE64.ENCODE" base64-encode
44+
"BASE64DECODE" base64-decode
45+
"BASE64.DECODE" base64-decode)

0 commit comments

Comments
 (0)