0.0
No commit activity in last 3 years
No release in over 3 years
Mix-in module for String class which enables to convert CamelCase and snake_case
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.11
~> 10.0
~> 3.0
 Project Readme

camel_snake

Gem Version Build Status

This package provides a Mix-in module which extends String class and adds features to convert itself into CamelCase or snake_case.

Usage

require 'camel_snake'

"FooBar".extend(CamelSnake).to_snake  #=> "foo_bar"
"bar_baz".extend(CamelSnake).to_camel #=> "BarBaz"

# Or you can do bellow
String.include CamelSnake

"FooBar".to_snake  #=> "foo_bar"
"bar_baz".to_camel #=> "BarBaz"

Installation

Add this line to your application's Gemfile:

gem 'camel_snake'

And then run bundle command on your terminal.

Or install it yourself as:

$ gem install camel_snake

Motivation

I know there are a lot of packages which provide similar features including ActiveSupport in Rails.
But I want a minimul package which gives only these two conversion functions out of Rails.

With refinements, Ruby's recent feature, we can safely extend classes.
Jan Lelis's sugar_refinery uses this feature. But it is not usable in older Ruby versions.

This module is simple and hopefully usable in many Ruby versions. And it meets my needs.

See Also

Contribution

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

The gem is available as open source under the terms of the MIT License.

Copyright (c) 2016 YASUTAKE Kiyoshi