On Wed, 2011-10-12 at 13:10 -0700, email4t...@gmail.com wrote:
> From: Tong Li <liton...@us.ibm.com>
> 
> ---
>  server/views/cimi/cloudEntryPoint/index.xml.haml |    7 +++----
>  1 files changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/server/views/cimi/cloudEntryPoint/index.xml.haml 
> b/server/views/cimi/cloudEntryPoint/index.xml.haml
> index a8f0fce..75c772a 100644
> --- a/server/views/cimi/cloudEntryPoint/index.xml.haml
> +++ b/server/views/cimi/cloudEntryPoint/index.xml.haml
> @@ -4,7 +4,6 @@
>    %name cloud entry point
>    %description cloud entry point
>    %created= Time.new.getutc.to_s
> -  - @all_apis.each do |api|
> -    - if api != :cloudEntryPoint
> -      - path_name = api.to_s.gsub(/[A-Z]/, '_\0').downcase
> -      = "<#{api.to_s.pluralize} href=\"#{api_url_for(path_name)}\"/>"
> \ No newline at end of file
> +  - @collections.each do |api|
> +    - res_name = api[0].to_s.gsub(/_[a-z]/) { |match| match[1].to_s.upcase }

There's a little Ruby surprise for you: match[1] is actually an integer;
and "ab"[1].to_s.upcase == "98"

Instead of your patch I am using the one below. I also rebased against
the latest HEAD and updated the patch series at
http://people.apache.org/~lutter/patches/dmtf/

>From 90c10d96d1265f8f3cc62e9420504299f2ac455d Mon Sep 17 00:00:00 2001
From: Tong Li <liton...@us.ibm.com>
Date: Wed, 12 Oct 2011 13:10:39 -0700
Subject: [PATCH] fix cloud entry point xml/json bugs caused by the collection
 changes


Signed-off-by: David Lutterkort <lut...@redhat.com>
---
 server/lib/deltacloud/core_ext/string.rb         |    5 +++
 server/tests/core_ext/string.rb                  |   31 ++++++++++++++++++++++
 server/views/cimi/cloudEntryPoint/index.xml.haml |    7 ++---
 3 files changed, 39 insertions(+), 4 deletions(-)
 create mode 100644 server/tests/core_ext/string.rb

diff --git a/server/lib/deltacloud/core_ext/string.rb 
b/server/lib/deltacloud/core_ext/string.rb
index 42fbad0..1cd79a0 100644
--- a/server/lib/deltacloud/core_ext/string.rb
+++ b/server/lib/deltacloud/core_ext/string.rb
@@ -49,4 +49,9 @@ class String
           tr("-", "_").
           downcase
   end
+
+
+  def camelize
+    gsub(/_[a-z]/) { |match| match[1].chr.upcase }
+  end
 end
diff --git a/server/tests/core_ext/string.rb b/server/tests/core_ext/string.rb
new file mode 100644
index 0000000..dfa57dc
--- /dev/null
+++ b/server/tests/core_ext/string.rb
@@ -0,0 +1,31 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+
+$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', '..')
+require 'tests/common'
+
+require 'deltacloud/drivers'
+require 'deltacloud/drivers/mock/mock_driver'
+
+module DeltacloudUnitTest
+
+  class StringTest < Test::Unit::TestCase
+    def test_camelize
+      "hello_camel".camelize.should == "helloCamel"
+      "hello_camel_lots_of_humps".camelize.should == "helloCamelLotsOfHumps"
+    end
+  end
+end
diff --git a/server/views/cimi/cloudEntryPoint/index.xml.haml 
b/server/views/cimi/cloudEntryPoint/index.xml.haml
index a8f0fce..c39a34d 100644
--- a/server/views/cimi/cloudEntryPoint/index.xml.haml
+++ b/server/views/cimi/cloudEntryPoint/index.xml.haml
@@ -4,7 +4,6 @@
   %name cloud entry point
   %description cloud entry point
   %created= Time.new.getutc.to_s
-  - @all_apis.each do |api|
-    - if api != :cloudEntryPoint
-      - path_name = api.to_s.gsub(/[A-Z]/, '_\0').downcase
-      = "<#{api.to_s.pluralize} href=\"#{api_url_for(path_name)}\"/>"
\ No newline at end of file
+  - @collections.each do |api|
+    - res_name = api[0].to_s.camelize
+    = "<#{res_name} href=\"#{api[1]}\"/>"
-- 
1.7.6.4



Reply via email to