|
93 | 93 | #(.toLowerCase %) |
94 | 94 | name)) |
95 | 95 |
|
96 | | -(defn clojure-version->cmp-key |
97 | | - "Create a comparison key from a Clojure version string, as returned |
98 | | - from function clojure.core/clojure-version. The key is a vector of |
99 | | - integers and strings, and two such keys may be compared via |
100 | | - clojure.core/compare to get the correct relative order of the two |
101 | | - Clojure versions. |
102 | | -
|
103 | | - Makes simplifying assumption that: |
104 | | - x.y.z-alpha<n> < x.y.z-beta<m> < x.y.z-RC<p> < x.y.z. |
105 | | -
|
106 | | - Note that this was not the time order of release for some 1.5.0-beta |
107 | | - and 1.5.0-RC releases, historically, as they switched from 1.5.0-RC |
108 | | - releases back to 1.5.0-beta, and then back to 1.5.0-RC again. |
109 | | - Hopefully that will not happen again. |
110 | | -
|
111 | | - Stolen from AndyF with thanks." |
112 | | - [version-str] |
113 | | - (let [to-long (fn [^String s] (Long/parseLong s)) |
114 | | - [v q] (str/split version-str #"-" 2) |
115 | | - [major minor incremental] (mapv to-long (str/split v #"\."))] |
116 | | - [major |
117 | | - (or minor 0) |
118 | | - (or incremental 0) |
119 | | - ;; qual1 will be one of "alpha" "beta" "rc", or "zfinal" if |
120 | | - ;; version-str is of the form "x.y.z". It will always be |
121 | | - ;; lower case so that normal alphabetic order comparison is |
122 | | - ;; used, without weirdness of upper case letters being sorted |
123 | | - ;; earlier than lower case letters. |
124 | | - (if q (str/lower-case (re-find #"[^\d]+" q)) "zfinal") |
125 | | - (some->> q (re-find #"\d+$") to-long)])) |
126 | | - |
127 | 96 | (defn edn-read-string-with-readers |
128 | 97 | "Read a string with clojure.edn/read-string and additional reader functions |
129 | 98 | installed. |
|
0 commit comments