/ tips

Lightweight Rubygems to Convert String Case

I was in a situation where I needed a string utility to transform snake case to lower camel case. Then when I looked in rubygems.org, there were so many usable rubygems.
From what I found, most of them monkey patched String class or rely on ActiveSupport

What I want is a rubygem that does not add any method to String class and as much as possible without dependencies. A moment later, I think this one is the best one. It can be seen from the test code and build history. However it depends on Rails ActiveSupport gem, which too heavy for a project that doesn't use ActiveSupport.

So because that reason, I forked it and removed ActiveSupport dependency. I name it as case_transform2 on https://rubygems.org. While constructing case_transform2, I copied few required tests from ActiveSupport, e.g. deep_transform_keys!, camelize, dasherize, etc.

How to install

gem install case_transform2

# when case_transform2 file is loaded, it will load case_transform.rb
require 'case_transform2'

CaseTransform.camel_lower(value)
camel	PascalCase
camel_lower	camelCase
dash	dash-case
underscore	under_score
unaltered	pass through