From d15d882bc6b4fb5af16f6bdef76062c2a76d1488 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20L=C3=B6tzsch?= Date: Tue, 26 Feb 2019 02:28:53 +0000 Subject: [PATCH] preparation for [whidbey "2.0.1"] + example To be compliant with https://github.com/greglook/whidbey/pull/28 fixes: https://github.com/greglook/whidbey/issues/21 --- example/README.md | 19 +++++++++++++++++++ example/project.clj | 9 +++++++++ example/src/example/core.clj | 6 ++++++ example/test/example/core_test.clj | 11 +++++++++++ project.clj | 2 +- src/ultra/plugin.clj | 10 +++++++--- src/ultra/plugin/utils.clj | 17 +++++++++++------ 7 files changed, 64 insertions(+), 10 deletions(-) create mode 100644 example/README.md create mode 100644 example/project.clj create mode 100644 example/src/example/core.clj create mode 100644 example/test/example/core_test.clj diff --git a/example/README.md b/example/README.md new file mode 100644 index 0000000..444f852 --- /dev/null +++ b/example/README.md @@ -0,0 +1,19 @@ +# example + +This example demonstrates +1. How to use ultra +2. How `:repl-options {:init …}` can be used in combination with ultra +3. That `[nrepl "0.6.0"]` is supported +## Usage + +```sh +lein repl +``` + +```clj +nrepl.version/version +``` + +```sh +lein test +``` diff --git a/example/project.clj b/example/project.clj new file mode 100644 index 0000000..3c3a6ba --- /dev/null +++ b/example/project.clj @@ -0,0 +1,9 @@ +(defproject example "0.1.0-SNAPSHOT" + :description "FIXME: write description" + :dependencies [[org.clojure/clojure "1.10.0"] + [nrepl "0.6.0"] + #_[mvxcvi/whidbey "2.0.1-SNAPSHOT"] [johannesloetzsch/whidbey "2.0.1-SNAPSHOT"]] ;; not yet released by mvxcvi + :plugins [[venantius/ultra "0.6.0-SNAPSHOT"]] + :middleware [ultra.plugin/middleware] + :repl-options {:init-ns example.core + :custom-init (example.core/init)}) diff --git a/example/src/example/core.clj b/example/src/example/core.clj new file mode 100644 index 0000000..fe996ea --- /dev/null +++ b/example/src/example/core.clj @@ -0,0 +1,6 @@ +(ns example.core) + +(defn init [] + (println "Hello, World!") + (println "You may want check: nrepl.version/version") + (println "nrepl 0.6.0 is now supported by whidbey and ultra :)\n")) diff --git a/example/test/example/core_test.clj b/example/test/example/core_test.clj new file mode 100644 index 0000000..320f6b8 --- /dev/null +++ b/example/test/example/core_test.clj @@ -0,0 +1,11 @@ +(ns example.core-test + "String tests that will fail on purpose to show diff output. Intended for makin' pretty screenshots." + (:require [clojure.test :refer :all])) + +(deftest string-comparison-1 + (is (= "spice" "spork"))) + +(deftest string-comparison-2 + (is (= "strings equal" "strings equal")) + (is (= "balloon" "baloon")) + (is (= "animal" "imal"))) diff --git a/project.clj b/project.clj index afd02ad..9d7ded8 100644 --- a/project.clj +++ b/project.clj @@ -6,7 +6,7 @@ :dependencies [[nrepl "0.6.0"] [grimradical/clj-semver "0.3.0" :exclusions [org.clojure/clojure]] [io.aviso/pretty "0.1.37"] - [mvxcvi/whidbey "2.0.0"] + #_[mvxcvi/whidbey "2.0.1-SNAPSHOT"] [johannesloetzsch/whidbey "2.0.1-SNAPSHOT"] ;; not yet released by mvxcvi [mvxcvi/puget "1.1.0"] [org.clojars.brenton/google-diff-match-patch "0.1"] [robert/hooke "1.3.0"] diff --git a/src/ultra/plugin.clj b/src/ultra/plugin.clj index b2dd1d0..2b1532b 100644 --- a/src/ultra/plugin.clj +++ b/src/ultra/plugin.clj @@ -11,7 +11,9 @@ {:added "0.2.0"} [project {:keys [repl] :as opts}] (if (not (false? repl)) - (whidbey.plugin/repl-pprint project) + (-> project + (plugin/set-interactive-eval-renderer 'whidbey.repl/render-str) + (whidbey.plugin/repl-pprint)) project)) (defn add-legacy-repl-middleware @@ -21,7 +23,9 @@ {:added "0.4.1"} [project {:keys [repl] :as opts}] (if (not (false? repl)) - (whidbey.plugin/repl-pprint project) + (-> project + (plugin/set-interactive-eval-renderer 'whidbey.repl/render-str) + (whidbey.plugin/repl-pprint)) project)) (defn inject-repl-initialization @@ -34,7 +38,7 @@ (if repl `(do (require 'ultra.hardcore) (require 'whidbey.repl) - (whidbey.repl/init! ~whidbey-opts) + (whidbey.repl/update-options! ~whidbey-opts) (ultra.hardcore/configure! ~opts)) `(do (require 'ultra.hardcore) (ultra.hardcore/configure! ~opts)))))) diff --git a/src/ultra/plugin/utils.clj b/src/ultra/plugin/utils.clj index 4c6558b..53f9ec0 100644 --- a/src/ultra/plugin/utils.clj +++ b/src/ultra/plugin/utils.clj @@ -72,12 +72,17 @@ form is executed." {:added "0.3.3"} [project & forms] - (update-in project - [:repl-options :init] - (fn [current] - (if current - `(do ~current ~@forms) - `(do ~@forms))))) + (-> project + (update-in [:repl-options :init] + (fn [current] + (if current + `(do ~current ~@forms) + `(do ~@forms)))) + (update-in [:repl-options :custom-init] + (fn [current] + (if current + `(do ~current ~@forms) + `(do ~@forms)))))) (defn add-nrepl-middleware "Adds the middleware identified by the given symbol to the *front* of the