You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by ma...@redhat.com on 2011/11/16 09:58:26 UTC

[PATCH] Rename 'capitalize' in core-ext/string.rb to 'upcase_first'

From: marios <ma...@redhat.com>

Used as part of CIMI schema class, but causes naming conflict
with Ruby's own 'capitalize':
https://issues.apache.org/jira/browse/DTACLOUD-104

Signed-off-by: marios <ma...@redhat.com>
---
 server/lib/cimi/model/schema.rb          |    4 ++--
 server/lib/deltacloud/core_ext/string.rb |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/server/lib/cimi/model/schema.rb b/server/lib/cimi/model/schema.rb
index e470121..8b0911b 100644
--- a/server/lib/cimi/model/schema.rb
+++ b/server/lib/cimi/model/schema.rb
@@ -136,11 +136,11 @@ class CIMI::Model::Schema
 
     private
     def struct
-      cname = "CIMI_#{json_name.capitalize}"
+      cname = "CIMI_#{json_name.upcase_first}"
       if ::Struct.const_defined?(cname)
         ::Struct.const_get(cname)
       else
-        ::Struct.new("CIMI_#{json_name.capitalize}",
+        ::Struct.new("CIMI_#{json_name.upcase_first}",
                      *@schema.attribute_names)
       end
     end
diff --git a/server/lib/deltacloud/core_ext/string.rb b/server/lib/deltacloud/core_ext/string.rb
index c5d9bf3..53b3984 100644
--- a/server/lib/deltacloud/core_ext/string.rb
+++ b/server/lib/deltacloud/core_ext/string.rb
@@ -59,7 +59,7 @@ class String
     self[0, 1].downcase + self[1..-1]
   end
 
-  def capitalize
+  def upcase_first
     self[0, 1].upcase + self[1..-1]
   end
 end
-- 
1.7.6.4


Re: [PATCH] Rename 'capitalize' in core-ext/string.rb to 'upcase_first'

Posted by Michal Fojtik <mi...@mifo.sk>.
ACK.

--- michal

Sent from my tablet.

On 16.11.2011, at 9:58, marios@redhat.com wrote:

> From: marios <ma...@redhat.com>
> 
> Used as part of CIMI schema class, but causes naming conflict
> with Ruby's own 'capitalize':
> https://issues.apache.org/jira/browse/DTACLOUD-104
> 
> Signed-off-by: marios <ma...@redhat.com>
> ---
> server/lib/cimi/model/schema.rb          |    4 ++--
> server/lib/deltacloud/core_ext/string.rb |    2 +-
> 2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/server/lib/cimi/model/schema.rb b/server/lib/cimi/model/schema.rb
> index e470121..8b0911b 100644
> --- a/server/lib/cimi/model/schema.rb
> +++ b/server/lib/cimi/model/schema.rb
> @@ -136,11 +136,11 @@ class CIMI::Model::Schema
> 
>     private
>     def struct
> -      cname = "CIMI_#{json_name.capitalize}"
> +      cname = "CIMI_#{json_name.upcase_first}"
>       if ::Struct.const_defined?(cname)
>         ::Struct.const_get(cname)
>       else
> -        ::Struct.new("CIMI_#{json_name.capitalize}",
> +        ::Struct.new("CIMI_#{json_name.upcase_first}",
>                      *@schema.attribute_names)
>       end
>     end
> diff --git a/server/lib/deltacloud/core_ext/string.rb b/server/lib/deltacloud/core_ext/string.rb
> index c5d9bf3..53b3984 100644
> --- a/server/lib/deltacloud/core_ext/string.rb
> +++ b/server/lib/deltacloud/core_ext/string.rb
> @@ -59,7 +59,7 @@ class String
>     self[0, 1].downcase + self[1..-1]
>   end
> 
> -  def capitalize
> +  def upcase_first
>     self[0, 1].upcase + self[1..-1]
>   end
> end
> -- 
> 1.7.6.4
>