Skip to content

Commit

Permalink
improve version number handling
Browse files Browse the repository at this point in the history
  • Loading branch information
martinklepsch committed Jun 5, 2018
1 parent 68c535d commit 6e0c85a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
7 changes: 4 additions & 3 deletions build.boot
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(set-env!
:resource-paths #{"src"}
:resource-paths #{"src" "resources"}
:dependencies '[[org.clojure/clojure "1.8.0" :scope "provided"]
[cheshire "5.0.1"]
[clj-http "3.0.1"]
Expand All @@ -8,10 +8,11 @@
[adzerk/bootlaces "0.1.13" :scope "test"]
[adzerk/boot-test "1.1.1" :scope "test"]])

(require '[adzerk.boot-test :refer [test]]
(require '[raven-clj.core :as raven-clj]
'[adzerk.boot-test :refer [test]]
'[adzerk.bootlaces :refer [bootlaces! build-jar push-release]])

(def +version+ "1.5.2")
(def +version+ (raven-clj/version))

(bootlaces! +version+ :dont-modify-paths? true)

Expand Down
1 change: 1 addition & 0 deletions resources/raven_clj/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.5.2
6 changes: 5 additions & 1 deletion src/raven_clj/core.clj
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
(ns raven-clj.core
(:require [cheshire.core :as json]
[clj-http.client :as http]
[clojure.java.io :as io]
[clojure.string :as string])
(:import [java.util Date UUID]
[java.sql Timestamp]
[java.net InetAddress]))

(defn version []
(string/trim (slurp (io/resource "raven_clj/version.txt"))))

(def ^:private ^:const sentry-client
"The name of this sentry client implementation"
"raven-clj/1.5.2")
(format "raven-clj/%s" (version)))

(defn- generate-uuid []
(string/replace (UUID/randomUUID) #"-" ""))
Expand Down
5 changes: 3 additions & 2 deletions test/raven_clj/core_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
(let [ts (str (Timestamp. (.getTime (Date.))))
key "b70a31b3510c4cf793964a185cfe1fd0"
secret "b7d80b520139450f903720eb7991bf3d"
client-version "1.5.2"
client-version (version)
hdr (make-sentry-header ts key secret)]

(is (.contains hdr "sentry_version=2.0")
Expand All @@ -50,7 +50,8 @@
(reset! actual-opts opts))]
(send-packet packet)

(is (= (-> @actual-opts :headers (get "User-Agent")) "raven-clj/1.5.2")
(is (= (-> @actual-opts :headers (get "User-Agent"))
(format "raven-clj/%s" (version)))
"includes User-Agent header in request")))))

(deftest test-parse-dsn
Expand Down

0 comments on commit 6e0c85a

Please sign in to comment.