From 29ed7275c6d554e9958330c3a668bae119aac0f4 Mon Sep 17 00:00:00 2001 From: Philip Healy Date: Mon, 30 Apr 2018 00:06:36 +0100 Subject: [PATCH] Ready for PR. --- README.md | 2 +- project.clj | 6 +++--- src/spyscope/core.cljc | 12 ++++-------- test/spyscope/tests.cljs | 2 +- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 5047825..550fad2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Spyscope -A Clojure library designed to make it easy to debug single- and multi-threaded applications. +A Clojure(Script) library designed to make it easy to debug single- and multi-threaded applications. ## Installation diff --git a/project.clj b/project.clj index 536b68e..0397026 100644 --- a/project.clj +++ b/project.clj @@ -13,9 +13,9 @@ [clj-time "0.14.3"] [com.andrewmcveigh/cljs-time "0.5.2"] [net.cgrand/macrovich "0.2.1"] - ;[mvxcvi/puget "1.0.2"] - [mvxcvi/puget "1.0.2" :exclusions [org.clojure/core.rrb-vector]] - [quantum/org.clojure.core.rrb-vector "0.0.12"]] + [mvxcvi/puget "1.0.2" :exclusions [brandonbloom/fipp]] + [bigml/fipp "0.6.8"]] + :plugins [[lein-cljsbuild "1.1.7"] [lein-doo "0.1.10" :exclusions [org.clojure/clojurescript]]] diff --git a/src/spyscope/core.cljc b/src/spyscope/core.cljc index d5cf19b..5504623 100644 --- a/src/spyscope/core.cljc +++ b/src/spyscope/core.cljc @@ -1,17 +1,13 @@ (ns spyscope.core (:require [clojure.string :as str] - #?(:clj [clj-time.core :as time] :cljs [cljs-time.core :as time]) - #?(:clj [clj-time.format :as fmt] :cljs [cljs-time.format :as fmt]) - #?(:clj [puget.printer :as pp])) #?(:clj (:require [net.cgrand.macrovich :as macrovich]) :cljs (:require-macros [net.cgrand.macrovich :as macrovich]))) - (defn- indent "Indents a string with `n` spaces." [n string] @@ -91,8 +87,7 @@ [form] `(macrovich/case :clj (doto ~form pp/cprint) - :cljs (println ~form))) - + :cljs (doto ~form println))) ; Trace storage - an atom rather than an agent is used in cljs. #?(:clj (def ^{:internal true} trace-storage (agent {:trace [] :generation 0})) @@ -107,7 +102,9 @@ ~(assoc (meta form) ::form (list 'quote form)))] (when ~(::print? (meta form)) - (print (str (:message value#) "\n"))) + (macrovich/case + :clj (print (str (:message value#) "\n")) + :cljs (print (str (:message value#))))) ((macrovich/case :clj send-off :cljs swap!) trace-storage (fn [{g# :generation t# :trace :as storage#}] (assoc storage# @@ -116,7 +113,6 @@ :generation g#))))) f#)) - (defn print-log-detailed "Reader function to pprint a form's value with some extra information." [form] diff --git a/test/spyscope/tests.cljs b/test/spyscope/tests.cljs index e4b4a1f..6f37b1a 100644 --- a/test/spyscope/tests.cljs +++ b/test/spyscope/tests.cljs @@ -9,7 +9,7 @@ (deftest print-log-detailed-test (spyscope.repl/trace-clear) - (is (re-matches #"spyscope\.tests\.print_log_detailed_test\.cljs.*\(\+ 1 2 3\) => 6\n" + (is (re-matches #"spyscope\.tests\.print_log_detailed_test\.cljs.*\(\+ 1 2 3\) => 6" (with-out-str #spy/d (+ 1 2 3))))) (deftest trace-test