Skip to content

Commit

Permalink
Move version fn from plugin ns to core ns
Browse files Browse the repository at this point in the history
enables #132 and fixes broken lein plugin
  • Loading branch information
benedekfazekas committed Jan 31, 2016
1 parent e905994 commit cb72cd9
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 18 deletions.
11 changes: 11 additions & 0 deletions src/refactor_nrepl/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@
[refactor-nrepl.s-expressions :as sexp])
(:import [java.io File FileReader PushbackReader StringReader]))

(defn version []
(let [v (-> (or (io/resource "refactor-nrepl/refactor-nrepl/project.clj")
"project.clj")
slurp
read-string
(nth 2))]
(assert (string? v)
(str "Something went wrong, version is not a string: "
v))
v))

(defn ns-from-string
"Retrieve the symbol naming the ns from file-content."
[file-content]
Expand Down
4 changes: 2 additions & 2 deletions src/refactor_nrepl/middleware.clj
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
[refactor-nrepl.artifacts :refer
[artifact-list artifact-versions hotload-dependency]]
[refactor-nrepl.config :as config]
[refactor-nrepl.core :as core]
[refactor-nrepl.extract-definition :refer [extract-definition]]
[refactor-nrepl.find.find-locals :refer [find-used-locals]]
[refactor-nrepl.find.find-symbol :refer [find-symbol]]
[refactor-nrepl.ns.clean-ns :refer [clean-ns]]
[refactor-nrepl.ns.libspecs :refer [namespace-aliases]]
[refactor-nrepl.ns.pprint :refer [pprint-ns]]
[refactor-nrepl.ns.resolve-missing :refer [resolve-missing]]
[refactor-nrepl.plugin :as plugin]
[refactor-nrepl.rename-file-or-dir :refer [rename-file-or-dir]]
[refactor-nrepl.stubs-for-interface :refer [stubs-for-interface]]))

Expand Down Expand Up @@ -78,7 +78,7 @@
(reply transport msg :used-locals (find-used-locals msg)))

(defn- version-reply [{:keys [transport] :as msg}]
(reply transport msg :status :done :version (plugin/version)))
(reply transport msg :status :done :version (core/version)))

(defn- warm-ast-cache-reply [{:keys [transport] :as msg}]
(reply transport msg :status :done
Expand Down
18 changes: 4 additions & 14 deletions src/refactor_nrepl/plugin.clj
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
(ns refactor-nrepl.plugin
(:require [clojure.java.io :as io]
[leiningen.core.main :as lein]))
(:require
[refactor-nrepl.core :as core]
[leiningen.core.main :as lein]))

(def ^:private external-dependencies
;; For whatever reason it didn't work to look for cider-nrepl here.
{'org.clojure/clojure "1.7.0"})

(defn version []
(let [v (-> (or (io/resource "refactor-nrepl/refactor-nrepl/project.clj")
"project.clj")
slurp
read-string
(nth 2))]
(assert (string? v)
(str "Something went wrong, version is not a string: "
v))
v))

(defn- version-ok?
[dependencies artifact version-string]
(or (->> dependencies
Expand All @@ -38,7 +28,7 @@
(-> project
(update-in [:dependencies]
(fnil into [])
[['refactor-nrepl (version)]])
[['refactor-nrepl (core/version)]])
(update-in [:repl-options :nrepl-middleware]
(fnil into [])
'[refactor-nrepl.middleware/wrap-refactor]))
Expand Down
4 changes: 2 additions & 2 deletions test/refactor_nrepl/integration_tests.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[clojure.tools.nrepl.server :as nrserver]
[refactor-nrepl middleware
[client :refer :all]
[plugin :as plugin]]
[core :as core]]
[clojure.string :as str])
(:import java.io.File
org.apache.commons.io.FileUtils))
Expand Down Expand Up @@ -235,5 +235,5 @@
:line 12 :column 6))))))

(deftest test-version
(is (= (str (plugin/version))
(is (= (str (core/version))
(version :transport (connect :port 7777)))))

0 comments on commit cb72cd9

Please sign in to comment.