Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
ptaoussanis committed Mar 19, 2013
2 parents 9331c90 + 07d94bf commit 3e281d3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Current [semantic](http://semver.org/) version:

```clojure
[com.taoensso/touchstone "0.14.0"]
[com.taoensso/touchstone "0.15.0"]
```

# Touchstone, a Clojure split-testing library
Expand All @@ -26,7 +26,7 @@ Touchstone is an attempt to bring **dead-simple, high-power split-testing** to a
Depend on Touchstone in your `project.clj`:

```clojure
[com.taoensso/touchstone "0.14.0"]
[com.taoensso/touchstone "0.15.0"]
```

and `require` the library:
Expand All @@ -49,7 +49,7 @@ Traditional split-testing consists of 4 steps:

The particular multi-armed bandit technique used by Touchstone means that we only concern ourselves with steps 1 and 3. Steps 2 and 4 are handled automatically by the algorithm.

**To optimize a Ring web application**, start by adding `(taoensso.touchstone.ring/wrap-random-test-subject-id)` to your middleware stack.
**To optimize a Ring web application**, start by adding `(taoensso.touchstone.ring/wrap-random-subject-id)` to your middleware stack.

One or more named-test selectors can then be used as part of your page content:

Expand Down
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject com.taoensso/touchstone "0.14.0"
(defproject com.taoensso/touchstone "0.15.0"
:description "Clojure split-testing library"
:url "https://github.com/ptaoussanis/touchstone"
:license {:name "Eclipse Public License"}
Expand Down
15 changes: 5 additions & 10 deletions src/taoensso/touchstone/ring.clj
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@

(comment (bot-user-agent? {"user-agent" "GoogleBot"}))

(defn wrap-random-test-subject-id
(defn wrap-test-subject-id
"Ring middleware that generates, sessionizes, and binds a test-subject id for
requests eligible for split-testing (by default this excludes clients that
report themselves as bots)."
[handler
& {:keys [eligible?-fn]
:or {eligible?-fn (fn [request] (not (bot-user-agent? (:headers request))))}}]
[handler & [wrap-pred]]
(fn [request]
(if-not (eligible?-fn request)
(if-not ((or wrap-pred (fn [request] (not (bot-user-agent? (:headers request)))))
request)
(handler request)

(if (contains? (:session request) :mab-subject-id)
Expand All @@ -31,8 +30,4 @@

(let [new-id (str (rand-int 2147483647))
response (touchstone/with-test-subject new-id (handler request))]
(assoc-in response [:session :mab-subject-id] new-id))))))

(defn make-wrap-random-test-subject-id
"DEPRECATED. Please use `wrap-random-test-subject-id."
[& args] (fn [handler] (apply wrap-random-test-subject-id handler args)))
(assoc-in response [:session :mab-subject-id] new-id))))))

0 comments on commit 3e281d3

Please sign in to comment.