Skip to content

Commit

Permalink
preparation for [whidbey "2.0.1"] + example
Browse files Browse the repository at this point in the history
To be compliant with greglook/whidbey#28

fixes: greglook/whidbey#21
  • Loading branch information
johannesloetzsch committed Feb 26, 2019
1 parent 309350c commit d15d882
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 10 deletions.
19 changes: 19 additions & 0 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -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
```
9 changes: 9 additions & 0 deletions example/project.clj
Original file line number Diff line number Diff line change
@@ -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)})
6 changes: 6 additions & 0 deletions example/src/example/core.clj
Original file line number Diff line number Diff line change
@@ -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"))
11 changes: 11 additions & 0 deletions example/test/example/core_test.clj
Original file line number Diff line number Diff line change
@@ -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")))
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
10 changes: 7 additions & 3 deletions src/ultra/plugin.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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))))))
Expand Down
17 changes: 11 additions & 6 deletions src/ultra/plugin/utils.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d15d882

Please sign in to comment.