Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/progrhyme/ruby-camel_snake
String Mix-in to convert CamelCase and snake_case
https://github.com/progrhyme/ruby-camel_snake
Last synced: 2 days ago
JSON representation
String Mix-in to convert CamelCase and snake_case
- Host: GitHub
- URL: https://github.com/progrhyme/ruby-camel_snake
- Owner: progrhyme
- License: mit
- Created: 2016-04-04T08:55:12.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-04-09T16:10:26.000Z (over 8 years ago)
- Last Synced: 2024-10-18T00:20:24.566Z (21 days ago)
- Language: Ruby
- Size: 9.77 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# camel\_snake
[![Gem Version](https://badge.fury.io/rb/camel_snake.svg)](https://badge.fury.io/rb/camel_snake)
[![Build Status](https://travis-ci.org/key-amb/ruby-camel_snake.svg?branch=master)](https://travis-ci.org/key-amb/ruby-camel_snake)This package provides a Mix-in module which extends String class and adds features
to convert itself into _CamelCase_ or *snake\_case*.## Usage
```ruby
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:
```ruby
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](http://ruby-doc.org/core-2.3.0/doc/syntax/refinements_rdoc.html),
Ruby's recent feature, we can safely extend classes.
Jan Lelis's [sugar_refinery](https://rubygems.org/gems/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
- [sugar_refinery](https://rubygems.org/gems/sugar_refinery)
- [string-cases](https://rubygems.org/gems/string-cases)## 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](../../pull/new/master)## License
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
Copyright (c) 2016 YASUTAKE Kiyoshi