Merge branch 'master' of github.com:jclouds/jclouds

* 'master' of github.com:jclouds/jclouds:
  Issue 716: add tests for memfn-apply
  Issue 716: fix :map-ebs-snapshot-to-device-name
This commit is contained in:
Adrian Cole 2011-10-13 02:11:45 -07:00
commit e8f5d39c2e
3 changed files with 13 additions and 2 deletions

View File

@ -399,7 +399,7 @@ 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
(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

View File

@ -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

View File

@ -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")))