From fe50ae36bca8161239c93b13b56d89194d8d4650 Mon Sep 17 00:00:00 2001 From: Allen Rohner Date: Wed, 12 Oct 2011 11:29:14 -0500 Subject: [PATCH 1/2] Issue 716: fix :map-ebs-snapshot-to-device-name --- compute/src/main/clojure/org/jclouds/compute.clj | 4 ++-- core/src/main/clojure/org/jclouds/core.clj | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/compute/src/main/clojure/org/jclouds/compute.clj b/compute/src/main/clojure/org/jclouds/compute.clj index 91179512f6..b0f6863a7e 100644 --- a/compute/src/main/clojure/org/jclouds/compute.clj +++ b/compute/src/main/clojure/org/jclouds/compute.clj @@ -399,8 +399,8 @@ See http://code.google.com/p/jclouds for details." ;; aws ec2 options :map-ephemeral-device-to-device-name]) {:map-ebs-snapshot-to-device-name - (kw-memfn-apply :map-ebs-snapshot-to-device-name - device-name snapshot-id size-in-gib delete-on-termination) + (memfn-apply mapEBSSnapshotToDeviceName + device-name snapshot-id size-in-gib delete-on-termination) :map-new-volume-to-device-name (kw-memfn-apply :map-new-volume-to-device-name device-name size-in-gib delete-on-termination)})) diff --git a/core/src/main/clojure/org/jclouds/core.clj b/core/src/main/clojure/org/jclouds/core.clj index 6c8787de7c..2279c83d00 100644 --- a/core/src/main/clojure/org/jclouds/core.clj +++ b/core/src/main/clojure/org/jclouds/core.clj @@ -94,6 +94,12 @@ Ensure the module is on the classpath. You are maybe missing a dependency on [kw] (symbol (camelize-mixed kw))) +(defmacro memfn-apply + "Expands into a function that takes one argument," + [fn-name & args] + `(fn [target# [~@args]] + ((memfn ~fn-name ~@args) target# ~@args))) + (defmacro kw-memfn "Expands into code that creates a function that expects to be passed an object and any args, and calls the instance method corresponding to From 17b277c24e0b7f9c55596f9db411e441b2a59e3d Mon Sep 17 00:00:00 2001 From: Allen Rohner Date: Wed, 12 Oct 2011 12:30:50 -0500 Subject: [PATCH 2/2] Issue 716: add tests for memfn-apply --- core/src/test/clojure/org/jclouds/core_test.clj | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/src/test/clojure/org/jclouds/core_test.clj b/core/src/test/clojure/org/jclouds/core_test.clj index d0dbad3706..de8aae2b5a 100644 --- a/core/src/test/clojure/org/jclouds/core_test.clj +++ b/core/src/test/clojure/org/jclouds/core_test.clj @@ -55,6 +55,11 @@ list, Alan Dipert and MeikelBrandmeyer." (deftest kw-fn-symbol-test (is (= 'aB (kw-fn-symbol :a-b)))) + +(deftest memfn-apply-test + (is (= "Ab" ((memfn-apply concat s) "A" ["b"]))) + (is (= "Ac" ((memfn-apply replace a b) "Ab" ["b" "c"])))) + (deftest kw-memfn-test (is (= "a" ((kw-memfn :to-lower-case) "A"))) (is (= "Ab" ((kw-memfn :concat s) "A" "b")))