On Oct 20, 2011, at 3:31 AM, Tong Li wrote: > The changes actually break things. for a string like "machine_images", what > is needed is actually "machineImages", not MachineImages, so the method does > not do what it needs to. The original method does. I think that this patch > needs to be reverted. The strings are actually needed in the cloudEntryPoint > response. In other places, there is a need for MachineImage, but never the > string MachineImages.
This is not really what .camelize method should do. However in ActiveSupport there is an option (:lower) for this so I'll update my code to support this option as well: class String def camelize(lowercase_first_letter=nil) s = split('_').map { |w| w.capitalize }.join lowercase_first_letter ? s.uncapitalize : s end def uncapitalize self[0, 1].downcase + self[1..-1] end end -- Michal > > Thanks. > > Tong Li > Emerging Technologies & Standards > B062/K317 > liton...@us.ibm.com > > mfojtik---10/19/2011 09:55:03 AM---From: Michal Fojtik <mfoj...@redhat.com> > Signed-off-by: Michal fojtik <mfoj...@redhat.com> > > From: mfoj...@redhat.com > To: deltacloud-dev@incubator.apache.org > Date: 10/19/2011 09:55 AM > Subject: [PATCH core 3/4] Core: Improved camelize method to upcase first > letter in string > > > > From: Michal Fojtik <mfoj...@redhat.com> > > > Signed-off-by: Michal fojtik <mfoj...@redhat.com> > --- > server/lib/deltacloud/core_ext/string.rb | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) > > diff --git a/server/lib/deltacloud/core_ext/string.rb > b/server/lib/deltacloud/core_ext/string.rb > index 1cd79a0..42d5677 100644 > --- a/server/lib/deltacloud/core_ext/string.rb > +++ b/server/lib/deltacloud/core_ext/string.rb > @@ -52,6 +52,6 @@ class String > > > def camelize > - gsub(/_[a-z]/) { |match| match[1].chr.upcase } > + split('_').map { |w| w.capitalize }.join > end > end > -- > 1.7.4.4 > > ------------------------------------------------------ Michal Fojtik, mfoj...@redhat.com Deltacloud API: http://deltacloud.org