Skip to content

Commit e31f61b

Browse files
committed
ported rest of schemata ns's to cljc
1 parent e2b0ae2 commit e31f61b

6 files changed

Lines changed: 62 additions & 63 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
(ns xapi-schema.schemata.i18n
2+
#?(:clj (:require [taoensso.tower :as tower :refer [make-t]])
3+
:cljs (:require [taoensso.tower :as tower
4+
:refer [make-t]
5+
:refer-macros (with-tscope dict-compile*)])))
6+
7+
(def tower-config
8+
{:fallback-locale :en
9+
#?@(:clj [:dictionary "i18n/dict.clj"]
10+
:cljs [:compiled-dictionary (dict-compile* "i18n/dict.clj")])
11+
;:dev-mode? true ; Set to true for auto dictionary reloading
12+
})
13+
14+
(def t (make-t tower-config))
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
Base64RegEx
1919
Sha1RegEx]]
2020
[xapi-schema.schemata.util :refer [check-type object-type-dispatch]]
21-
#+clj [schema.core :as s]
22-
#+cljs [schema.core :as s
23-
:include-macros true]))
21+
#?(:clj [schema.core :as s]
22+
:cljs [schema.core :as s
23+
:include-macros true])))
2424

2525

2626
;; Component schema

src/cljx/xapi_schema/schemata/predicates.cljx renamed to src/cljc/xapi_schema/schemata/predicates.cljc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
difference]]
55
[xapi-schema.schemata.regex :refer [AbsoluteIRIRegEx
66
UuidRegEx]]
7-
#+clj [schema.core :as s]
8-
#+cljs [schema.core :as s
9-
:include-macros true]))
7+
#?(:clj [schema.core :as s]
8+
:cljs [schema.core :as s
9+
:include-macros true])))
1010

1111
;; IFI predicates
1212
(defn ifi-count
Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
1-
(ns xapi-schema.schemata.regex
2-
(:require
3-
#+clj [schema.core :as s]
4-
#+cljs [schema.core :as s
5-
:include-macros true]))
1+
(ns xapi-schema.schemata.regex)
62

73
(def LanguageTagRegEx
84
#"^(((([A-Za-z]{2,3}(-([A-Za-z]{3}(-[A-Za-z]{3}){0,2}))?)|[A-Za-z]{4}|[A-Za-z]{5,8})(-([A-Za-z]{4}))?(-([A-Za-z]{2}|[0-9]{3}))?(-([A-Za-z0-9]{5,8}|[0-9][A-Za-z0-9]{3}))*(-([0-9A-WY-Za-wy-z](-[A-Za-z0-9]{2,8})+))*(-(x(-[A-Za-z0-9]{1,8})+))?)|(x(-[A-Za-z0-9]{1,8})+)|((en-GB-oed|i-ami|i-bnn|i-default|i-enochian|i-hak|i-klingon|i-lux|i-mingo|i-navajo|i-pwn|i-tao|i-tay|i-tsu|sgn-BE-FR|sgn-BE-NL|sgn-CH-DE)|(art-lojban|cel-gaulish|no-bok|no-nyn|zh-guoyu|zh-hakka|zh-min|zh-min-nan|zh-xiang)))$")
95

106
(def URIRegEx
11-
#+clj #"^((([A-Za-z]{3,9}:(?:\/\/)?)?(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)((?:\/[\+~%\/\.\w\-_]*)?\??(?:[\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w\-]*))?)$"
12-
#+cljs #"^((([A-Za-z]{3,9}:(?://)?)?(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)((?:/[\+~%\/\.\w\-_]*)?\??(?:[\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w\-]*))?)")
7+
#?(:clj #"^((([A-Za-z]{3,9}:(?:\/\/)?)?(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)((?:\/[\+~%\/\.\w\-_]*)?\??(?:[\-\+=&;%@\.\w_]*)#?(?:[\.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z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?")
Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
(ns xapi-schema.schemata.util
2-
#+clj (:require
3-
[schema.core :as s]
4-
[schema.utils :as su]
5-
[clojure.core.match :refer [match]]
6-
[clojure.walk :refer [prewalk]]
7-
[clojure.zip :as zip]
8-
[xapi-schema.schemata.i18n :refer [t]]
9-
[clojure.string :as string])
10-
#+cljs (:require
11-
[schema.core :as s :include-macros true]
12-
[schema.utils :as su]
13-
[cljs.core.match :refer-macros [match]]
14-
[clojure.walk :refer [prewalk]]
15-
[clojure.zip :as zip]
16-
[xapi-schema.schemata.i18n :refer [t]]
17-
[clojure.string :as string]))
2+
#?(:clj (:require
3+
[schema.core :as s]
4+
[schema.utils :as su]
5+
[clojure.core.match :refer [match]]
6+
[clojure.walk :refer [prewalk]]
7+
[clojure.zip :as zip]
8+
[xapi-schema.schemata.i18n :refer [t]]
9+
[clojure.string :as string])
10+
:cljs (:require
11+
[schema.core :as s :include-macros true]
12+
[schema.utils :as su]
13+
[cljs.core.match :refer-macros [match]]
14+
[clojure.walk :refer [prewalk]]
15+
[clojure.zip :as zip]
16+
[xapi-schema.schemata.i18n :refer [t]]
17+
[clojure.string :as string])))
1818

1919

2020

@@ -87,24 +87,27 @@
8787
[(['integer? value] :seq)] (str (t ltag :integer) ": " value)
8888

8989
;; catch cljs string schema, as it is just string?
90-
#+cljs
91-
[([(what :guard (partial = string?)) value] :seq)]
92-
#+cljs
93-
(str (t ltag :string) ": " value)
90+
#?@(:cljs
91+
[[([(what :guard (partial = string?)) value] :seq)]
92+
(str (t ltag :string) ": " value)])
9493

9594
[(['instance? klass value] :seq)]
96-
(str (cond
97-
#+clj (= klass java.lang.String)
98-
#+clj (str (t ltag :string) ": ")
99-
100-
#+clj (= klass java.lang.Number)
101-
#+cljs (= klass s/Num)
102-
(str (t ltag :number) ": ")
103-
#+clj (= klass java.lang.Boolean)
104-
#+cljs (= klass s/Bool)
105-
(str (t ltag :boolean) ": ")
106-
:else
107-
"unknown instance? predicate: ")
95+
(str #?(:clj (cond
96+
(= klass java.lang.String)
97+
(str (t ltag :string) ": ")
98+
(= klass java.lang.Number)
99+
(str (t ltag :number) ": ")
100+
(= klass java.lang.Boolean)
101+
(str (t ltag :boolean) ": ")
102+
:else
103+
"unknown instance? predicate: ")
104+
:cljs (cond
105+
(= klass s/Num)
106+
(str (t ltag :number) ": ")
107+
(= klass s/Bool)
108+
(str (t ltag :boolean) ": ")
109+
:else
110+
"unknown instance? predicate : "))
108111
value)
109112
[(['= what value] :seq)]
110113
(str what ": " value)
@@ -146,8 +149,8 @@
146149

147150
(defn- strip-named [node]
148151
(if (named-error? node)
149-
(let [name #+clj (.name node) #+cljs (.-name node)
150-
error #+clj (.error node) #+cljs (.-error node)]
152+
(let [name #?(:clj (.name node) :cljs (.-name node))
153+
error #?(:clj (.error node) :cljs (.-error node))]
151154
(strip-named error))
152155
node))
153156

src/cljx/xapi_schema/schemata/i18n.cljx

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)