Skip to content

Commit 9c05be1

Browse files
committed
Cleaning namespaces for coding style
1 parent d86cd10 commit 9c05be1

File tree

1 file changed

+52
-43
lines changed

1 file changed

+52
-43
lines changed

src/lambdaisland/deep_diff/printer.cljc

Lines changed: 52 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,25 @@
99
#?@(:cljs
1010
[[cljs-time.coerce :refer [from-date]]
1111
[cljs-time.format :refer [formatter unparse]]
12-
[goog.string :refer [format]]
13-
[goog.object :as gobj]]))
14-
#?(:clj (:import (java.text SimpleDateFormat)
15-
(java.util TimeZone)
16-
(java.sql Timestamp))))
12+
[goog.string :refer [format]]]))
13+
#?(:clj
14+
(:import (java.text SimpleDateFormat)
15+
(java.util TimeZone)
16+
(java.sql Timestamp))))
1717

1818
(defn get-type-name
1919
"Get the type of the given object as a string. For Clojure, gets the name of
2020
the class of the object. For ClojureScript, gets either the `name` attribute
2121
or the protocol name if the `name` attribute doesn't exist."
2222
[x]
23-
#?(:clj (.getName (class x))
24-
:cljs (let [t (type x)
25-
n (.-name t)]
26-
(if (empty? n)
27-
(pr-str t)
28-
n))))
23+
#?(:clj
24+
(.getName (class x))
25+
:cljs
26+
(let [t (type x)
27+
n (.-name t)]
28+
(if (empty? n)
29+
(pr-str t)
30+
n))))
2931

3032
(defn print-deletion [printer expr]
3133
(let [no-color (assoc printer :print-color false)]
@@ -77,39 +79,46 @@
7779
(if (coll? v) (:map-coll-separator printer) " ")
7880
(puget/format-doc printer v)]))))
7981

80-
81-
#?(:clj (def ^:private ^ThreadLocal thread-local-utc-date-format
82-
(proxy [ThreadLocal] []
83-
(initialValue []
84-
(doto (SimpleDateFormat. "yyyy-MM-dd'T'HH:mm:ss.SSS-00:00")
85-
(.setTimeZone (TimeZone/getTimeZone "GMT"))))))
86-
:cljs (def thread-local-utc-date-format
87-
(doto (cljs-time.format/formatter "yyyy-MM-dd'T'HH:mm:ss.SSS-00:00"))))
82+
#?(:clj
83+
(def ^:private ^ThreadLocal thread-local-utc-date-format
84+
(proxy [ThreadLocal] []
85+
(initialValue []
86+
(doto (SimpleDateFormat. "yyyy-MM-dd'T'HH:mm:ss.SSS-00:00")
87+
(.setTimeZone (TimeZone/getTimeZone "GMT"))))))
88+
:cljs
89+
(def thread-local-utc-date-format
90+
(doto (cljs-time.format/formatter "yyyy-MM-dd'T'HH:mm:ss.SSS-00:00"))))
8891

8992
(def ^:private print-date
9093
(puget/tagged-handler
9194
'inst
92-
#?(:clj #(.format ^SimpleDateFormat (.get thread-local-utc-date-format) %)
93-
:cljs (fn [input-date]
94-
(let [dt (from-date input-date)]
95-
(cljs-time.format/unparse thread-local-utc-date-format dt))))))
96-
97-
#?(:clj (def ^:private ^ThreadLocal thread-local-utc-timestamp-format
98-
(proxy [ThreadLocal] []
99-
(initialValue []
100-
(doto (SimpleDateFormat. "yyyy-MM-dd'T'HH:mm:ss")
101-
(.setTimeZone (TimeZone/getTimeZone "GMT"))))))
102-
:cljs (def thread-local-utc-timestamp-format
103-
(doto (cljs-time.format/formatter "yyyy-MM-dd'T'HH:mm:ss"))))
95+
#?(:clj
96+
#(.format ^SimpleDateFormat (.get thread-local-utc-date-format) %)
97+
:cljs
98+
(fn [input-date]
99+
(let [dt (from-date input-date)]
100+
(cljs-time.format/unparse thread-local-utc-date-format dt))))))
101+
102+
#?(:clj
103+
(def ^:private ^ThreadLocal thread-local-utc-timestamp-format
104+
(proxy [ThreadLocal] []
105+
(initialValue []
106+
(doto (SimpleDateFormat. "yyyy-MM-dd'T'HH:mm:ss")
107+
(.setTimeZone (TimeZone/getTimeZone "GMT"))))))
108+
:cljs
109+
(def thread-local-utc-timestamp-format
110+
(doto (cljs-time.format/formatter "yyyy-MM-dd'T'HH:mm:ss"))))
104111

105112
(def ^:private print-timestamp
106113
(puget/tagged-handler
107114
'inst
108-
#?(:clj #(str (.format ^SimpleDateFormat (.get thread-local-utc-timestamp-format) %)
109-
(format ".%09d-00:00" (.getNanos ^Timestamp %)))
110-
:cljs (fn [input-date]
111-
(let [dt (from-date input-date)]
112-
(cljs-time.format/unparse thread-local-utc-timestamp-format dt))))))
115+
#?(:clj
116+
#(str (.format ^SimpleDateFormat (.get thread-local-utc-timestamp-format) %)
117+
(format ".%09d-00:00" (.getNanos ^Timestamp %)))
118+
:cljs
119+
(fn [input-date]
120+
(let [dt (from-date input-date)]
121+
(cljs-time.format/unparse thread-local-utc-timestamp-format dt))))))
113122

114123
(def ^:private print-calendar
115124
(puget/tagged-handler
@@ -166,19 +175,19 @@
166175
'cljs.core.uuid
167176
(puget/tagged-handler 'uuid str)}))
168177

169-
170178
(defn- print-handler-resolver [extra-handlers]
171179
(fn [^Class klz]
172180
(and klz (get (merge @#'common-handlers @#'print-handlers extra-handlers)
173181
(symbol (get-type-name klz))))))
174182

175-
;; (defn register-print-handler!
176-
;; "Register an extra print handler.
183+
#?(:clj
184+
(defn register-print-handler!
185+
"Register an extra print handler.
177186
178-
;; `type` must be a symbol of the fully qualified class name. `handler` is a
179-
;; Puget handler function of two arguments, `printer` and `value`."
180-
;; [type handler]
181-
;; (alter-var-root #'print-handlers assoc type handler))
187+
`type` must be a symbol of the fully qualified class name. `handler` is a
188+
Puget handler function of two arguments, `printer` and `value`."
189+
[type handler]
190+
(alter-var-root #'print-handlers assoc type handler)))
182191

183192
(defn puget-printer
184193
([]

0 commit comments

Comments
 (0)