aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Smith-Mannschott <bsmith.occs@gmail.com>2010-08-23 20:51:51 +0200
committerStuart Sierra <mail@stuartsierra.com>2010-09-03 12:23:36 -0400
commit1be54b2f9bd3c9f35385a015b14fc93337bffcac (patch)
tree205388106c009877d1ed2dd0168231245493cc64
parentbf85deddc000469cb2f7af06c2a63d72c1894a00 (diff)
remove deprecated clojure.contrib.properties
Signed-off-by: Stuart Sierra <mail@stuartsierra.com>
-rw-r--r--modules/complete/pom.xml5
-rw-r--r--modules/properties/pom.xml26
-rw-r--r--modules/properties/src/main/clojure/clojure/contrib/properties.clj77
-rw-r--r--modules/properties/src/test/clojure/clojure/contrib/test_properties.clj63
-rw-r--r--modules/sql/pom.xml5
-rw-r--r--modules/sql/src/main/clojure/clojure/contrib/sql/internal.clj19
-rw-r--r--pom.xml1
7 files changed, 17 insertions, 179 deletions
diff --git a/modules/complete/pom.xml b/modules/complete/pom.xml
index 0ac8d3d1..2c195bbe 100644
--- a/modules/complete/pom.xml
+++ b/modules/complete/pom.xml
@@ -272,11 +272,6 @@
</dependency>
<dependency>
<groupId>org.clojure.contrib</groupId>
- <artifactId>properties</artifactId>
- <version>1.3.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.clojure.contrib</groupId>
<artifactId>prxml</artifactId>
<version>1.3.0-SNAPSHOT</version>
</dependency>
diff --git a/modules/properties/pom.xml b/modules/properties/pom.xml
deleted file mode 100644
index c0cbca7a..00000000
--- a/modules/properties/pom.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http//www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
- http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.clojure.contrib</groupId>
- <artifactId>parent</artifactId>
- <version>1.3.0-SNAPSHOT</version>
- <relativePath>../parent</relativePath>
- </parent>
- <artifactId>properties</artifactId>
- <dependencies>
- <dependency>
- <groupId>org.clojure.contrib</groupId>
- <artifactId>io</artifactId>
- <version>1.3.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.clojure.contrib</groupId>
- <artifactId>string</artifactId>
- <version>1.3.0-SNAPSHOT</version>
- </dependency>
- </dependencies>
-</project> \ No newline at end of file
diff --git a/modules/properties/src/main/clojure/clojure/contrib/properties.clj b/modules/properties/src/main/clojure/clojure/contrib/properties.clj
deleted file mode 100644
index 0e210206..00000000
--- a/modules/properties/src/main/clojure/clojure/contrib/properties.clj
+++ /dev/null
@@ -1,77 +0,0 @@
-; Copyright (c) Stuart Halloway & Contributors, April 2009. All rights reserved.
-; The use and distribution terms for this software are covered by the
-; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
-; which can be found in the file epl-v10.html at the root of this distribution.
-; By using this software in any fashion, you are agreeing to be bound by
-; the terms of this license.
-; You must not remove this notice, or any other, from this software.
-
-;; DEPRECATED in 1.2. Moved to c.c.java-utils
-
-(ns ^{:deprecated "1.2"}
- clojure.contrib.properties
- (:use [clojure.contrib.string :only (as-str)]
- [clojure.contrib.io :only (file)])
- (:import (java.util Properties)
- (java.io FileInputStream FileOutputStream)))
-
-(defn get-system-property
- "Get a system property."
- ([stringable]
- (System/getProperty (as-str stringable)))
- ([stringable default]
- (System/getProperty (as-str stringable) default)))
-
-(defn set-system-properties
- "Set some system properties. Nil clears a property."
- [settings]
- (doseq [[name val] settings]
- (if val
- (System/setProperty (as-str name) (as-str val))
- (System/clearProperty (as-str name)))))
-
-(defmacro with-system-properties
- "setting => property-name value
-
- Sets the system properties to the supplied values, executes the body, and
- sets the properties back to their original values. Values of nil are
- translated to a clearing of the property."
- [settings & body]
- `(let [settings# ~settings
- current# (reduce (fn [coll# k#]
- (assoc coll# k# (get-system-property k#)))
- {}
- (keys settings#))]
- (set-system-properties settings#)
- (try
- ~@body
- (finally
- (set-system-properties current#)))))
-
-
-; Not there is no corresponding props->map. Just destructure!
-(defn ^Properties as-properties
- "Convert any seq of pairs to a java.utils.Properties instance.
- Uses as-str to convert both keys and values into strings."
- {:tag Properties}
- [m]
- (let [p (Properties.)]
- (doseq [[k v] m]
- (.setProperty p (as-str k) (as-str v)))
- p))
-
-(defn read-properties
- "Read properties from file-able."
- [file-able]
- (with-open [f (java.io.FileInputStream. (file file-able))]
- (doto (Properties.)
- (.load f))))
-
-(defn write-properties
- "Write properties to file-able."
- {:tag Properties}
- ([m file-able] (write-properties m file-able nil))
- ([m file-able comments]
- (with-open [^FileOutputStream f (FileOutputStream. (file file-able))]
- (doto (as-properties m)
- (.store f ^String comments)))))
diff --git a/modules/properties/src/test/clojure/clojure/contrib/test_properties.clj b/modules/properties/src/test/clojure/clojure/contrib/test_properties.clj
deleted file mode 100644
index 65b1371f..00000000
--- a/modules/properties/src/test/clojure/clojure/contrib/test_properties.clj
+++ /dev/null
@@ -1,63 +0,0 @@
-(ns clojure.contrib.test-properties
- (:refer-clojure :exclude (spit))
- (:use clojure.test clojure.contrib.properties
- [clojure.contrib.io :only (spit)])
- (:import (java.util Properties)
- (java.io File)))
-
-(deftest test-get-system-property
- (testing "works the same with keywords, symbols, and strings"
- (is (= (get-system-property "java.home") (get-system-property 'java.home)))
- (is (= (get-system-property "java.home") (get-system-property :java.home))))
- (testing "treats second arg as default"
- (is (= "default" (get-system-property "testing.test-system-property" "default"))))
- (testing "returns nil for missing properties"
- (is (nil? (get-system-property "testing.test-system-property")))))
-
-(deftest test-set-system-properties
- (testing "set and then unset a property using keywords"
- (let [propname :clojure.contrib.java.test-set-system-properties]
- (is (nil? (get-system-property propname)))
- (set-system-properties {propname :foo})
- (is (= "foo") (get-system-property propname))
- (set-system-properties {propname nil})
- (is (nil? (get-system-property propname))))))
-
-(deftest test-with-system-properties
- (let [propname :clojure.contrib.java.test-with-system-properties]
- (testing "sets a property only for the duration of a block"
- (is (= "foo"
- (with-system-properties {propname "foo"}
- (get-system-property propname))))
- (is (nil? (get-system-property propname)))))
- (testing "leaves other properties alone"
- ; TODO: write this test better, using a properties -> map function
- (let [propname :clojure.contrib.java.test-with-system-properties
- propcount (count (System/getProperties))]
- (with-system-properties {propname "foo"}
- (is (= (inc propcount) (count (System/getProperties)))))
- (is (= propcount (count (System/getProperties)))))))
-
-(deftest test-as-properties
- (let [expected (doto (Properties.)
- (.setProperty "a" "b")
- (.setProperty "c" "d"))]
- (testing "with a map"
- (is (= expected
- (as-properties {:a "b" :c "d"}))))
- (testing "with a sequence of pairs"
- (is (= expected
- (as-properties [[:a :b] [:c :d]]))))))
-
-(deftest test-read-properties
- (let [f (File/createTempFile "test" "properties")]
- (spit f "a=b\nc=d")
- (is (= {"a" "b" "c" "d"}
- (read-properties f)))))
-
-(deftest test-write-properties
- (let [f (File/createTempFile "test" "properties")]
- (write-properties [['a 'b] ['c 'd]] f)
- (is (= {"a" "b" "c" "d"}
- (read-properties f)))))
-
diff --git a/modules/sql/pom.xml b/modules/sql/pom.xml
index 998a5cad..c36f876f 100644
--- a/modules/sql/pom.xml
+++ b/modules/sql/pom.xml
@@ -29,11 +29,6 @@
</dependency>
<dependency>
<groupId>org.clojure.contrib</groupId>
- <artifactId>properties</artifactId>
- <version>1.3.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.clojure.contrib</groupId>
<artifactId>seq</artifactId>
<version>1.3.0-SNAPSHOT</version>
</dependency>
diff --git a/modules/sql/src/main/clojure/clojure/contrib/sql/internal.clj b/modules/sql/src/main/clojure/clojure/contrib/sql/internal.clj
index 59a05205..57d7050f 100644
--- a/modules/sql/src/main/clojure/clojure/contrib/sql/internal.clj
+++ b/modules/sql/src/main/clojure/clojure/contrib/sql/internal.clj
@@ -15,12 +15,11 @@
(:use
(clojure.contrib
[except :only (throwf throw-arg)]
- [properties :only (as-properties)]
[seq :only (indexed)]))
(:import
(clojure.lang RT)
(java.sql BatchUpdateException DriverManager SQLException Statement)
- (java.util Hashtable Map)
+ (java.util Hashtable Map Properties)
(javax.naming InitialContext Name)
(javax.sql DataSource)))
@@ -48,6 +47,22 @@
([val]
(swap! (:rollback *db*) (fn [_] val))))
+(defn- as-str
+ [x]
+ (if (instance? clojure.lang.Named x)
+ (name x)
+ (str x)))
+
+(defn- ^Properties as-properties
+ "Convert any seq of pairs to a java.utils.Properties instance.
+ Uses as-str to convert both keys and values into strings."
+ {:tag Properties}
+ [m]
+ (let [p (Properties.)]
+ (doseq [[k v] m]
+ (.setProperty p (as-str k) (as-str v)))
+ p))
+
(defn get-connection
"Creates a connection to a database. db-spec is a map containing values
for one of the following parameter sets:
diff --git a/pom.xml b/pom.xml
index de9be890..1a1e9e11 100644
--- a/pom.xml
+++ b/pom.xml
@@ -69,7 +69,6 @@
<module>modules/priority-map</module>
<module>modules/probabilities</module>
<module>modules/profile</module>
- <module>modules/properties</module>
<module>modules/prxml</module>
<module>modules/reflect</module>
<module>modules/repl-ln</module>