Skip to content

Commit 75ec3c9

Browse files
committed
Merge branch '0.11.2'
2 parents f11e183 + 9c58fa1 commit 75ec3c9

22 files changed

+312
-80
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ target/
1313
.ritz*
1414
.project
1515
.classpath
16+
doc/
17+
/.nrepl-port

build-docs.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
lein doc
6+
echo "*** Docs built ***"
7+
tmpdir=`mktemp -d /tmp/flatland-useful.XXXXXX`
8+
mv doc/** $tmpdir
9+
rmdir doc
10+
git checkout gh-pages
11+
git rm -rf .
12+
mv $tmpdir/** .
13+
git add -Av .
14+
git commit -m "Updated docs"
15+
echo "*** gh-pages branch updated ***"
16+
rmdir $tmpdir
17+
git checkout -
18+
echo "Run this to complete:"
19+
echo "git push origin gh-pages:gh-pages"

project.clj

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1-
(defproject org.flatland/useful "0.10.0"
1+
(defproject org.flatland/useful "0.11.2"
22
:description "A collection of generally-useful Clojure utility functions"
33
:license {:name "Eclipse Public License - v 1.0"
44
:url "http://www.eclipse.org/legal/epl-v10.html"
55
:distribution :repo}
66
:url "https://github.com/flatland/useful"
7-
:dependencies [[org.clojure/clojure "1.5.0"]
7+
:dependencies [[org.clojure/clojure "1.6.0"]
88
[org.clojure/tools.macro "0.1.1"]
99
[org.clojure/tools.reader "0.7.2"]]
10-
:aliases {"testall" ["with-profile" "dev,default:dev,1.3,default:dev,1.5,default" "test"]}
11-
:profiles {:1.4 {:dependencies [[org.clojure/clojure "1.4.0"]]}
12-
:1.3 {:dependencies [[org.clojure/clojure "1.3.0"]]}})
10+
:aliases {"testall" ["with-profile" "dev,default:dev,1.3,default:dev,1.4,default:dev,1.5,default:dev,1.7,default" "test"]}
11+
:profiles {:1.7 {:dependencies [[org.clojure/clojure "1.7.0-alpha2"]]}
12+
:1.5 {:dependencies [[org.clojure/clojure "1.5.1"]]}
13+
:1.4 {:dependencies [[org.clojure/clojure "1.4.0"]]}
14+
:1.3 {:dependencies [[org.clojure/clojure "1.3.0"]]} }
15+
:plugins [[codox "0.8.0"]]
16+
:codox {:src-dir-uri "http://github.com/flatland/useful/blob/develop/"
17+
:src-linenum-anchor-prefix "L"})

src/flatland/useful/cli.clj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
(ns flatland.useful.cli
2+
(:refer-clojure :exclude [update])
23
(:use [flatland.useful.experimental :only [cond-let]]
34
[flatland.useful.map :only [update]]))
45

src/flatland/useful/core.clj

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/flatland/useful/datatypes.clj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
(ns flatland.useful.datatypes
2+
(:refer-clojure :exclude [update])
23
(:use [flatland.useful.map :only [position into-map update]]
34
[flatland.useful.utils :only [invoke]]
45
[flatland.useful.fn :only [fix]])

src/flatland/useful/debug.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
wrap a form with ?, and the form will be printed alongside
2929
its result. The result will still be passed along."
3030
[val]
31-
(interrogate-form `(print) val))
31+
(interrogate-form `(#(do (print %) (flush))) val))
3232

3333
(defmacro ^{:dont-test "Complicated to test, and should work if ? does"}
3434
?!

src/flatland/useful/dispatch.clj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
[dispatch-fn & options]
1515
(let [{:keys [hierarchy wrap default]} (into-map options)
1616
wrap (or wrap identity)
17-
require (memoize require)]
17+
publics (memoize (fn [ns]
18+
(try (require ns)
19+
(ns-publics (find-ns ns))
20+
(catch java.io.FileNotFoundException e))))]
1821
(fn [& args]
1922
(let [fname (apply dispatch-fn args)
2023
default (or default
@@ -23,10 +26,7 @@
2326
{:no-wrap true}))]
2427
(loop [[ns method] (map symbol ((juxt namespace name) (symbol fname)))]
2528
(if-let [f (if ns
26-
(try (require ns)
27-
(-> (ns-publics (find-ns ns))
28-
(get method))
29-
(catch java.io.FileNotFoundException e))
29+
(get (publics ns) method)
3030
default)]
3131
(let [wrap (if (:no-wrap (meta f))
3232
identity

src/flatland/useful/experimental.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@
230230

231231
(defn lift-meta
232232
"Move some of the keys from m into its metadata, overriding existing values.
233-
(lift-meta {:a 1 :b 2} [:a]) -> ^{:a 1} {:b 2]"
233+
(lift-meta {:a 1 :b 2} [:a]) -> ^{:a 1} {:b 2}"
234234
[m & ks]
235235
(-> (apply dissoc m ks)
236236
(vary-meta merge (select-keys m ks))))

src/flatland/useful/fn.clj

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@
132132
(transform y)."
133133
([modifier]
134134
(fn [a b]
135-
(- (modifier a) (modifier b))))
135+
(compare (modifier a) (modifier b))))
136136
([direction modifier]
137-
(let [f (comparator modifier)]
137+
(let [f (key-comparator modifier)]
138138
(condp #(% %2) direction
139139
#{:desc :descending -} (comp - f)
140140
#{:asc :ascending +} f))))
@@ -169,3 +169,10 @@
169169
(if (= args (get cache :args ::not-found))
170170
cache
171171
{:args args, :value (apply f args)})))))))
172+
173+
(defn applied
174+
"A version of f that uses apply on its args."
175+
[f]
176+
(partial apply f))
177+
178+
(def ap "A shorthand version of applied" applied)

0 commit comments

Comments
 (0)