• Stars
    star
    215
  • Rank 177,842 (Top 4 %)
  • Language
    Elixir
  • License
    MIT License
  • Created almost 7 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

โ™ป๏ธ Convert strings to any case.

Recase

Recase

Build Status Coverage Status Hex Version Hex Docs Total Download License Last Updated

Recase helps you to convert a string from any case to any case.

Why?

One can ask: "Why should I use Recase when I can use built-in Macro module?". But, you have to keep in mind that Macro's functions are not suitable for general case usage:

Do not use it as a general mechanism for underscoring or camelizing strings as it does not support Unicode or characters that are not valid in Elixir identifiers.

Installation

def deps do
  [
    {:recase, "~> 0.5"}
  ]
end

Usage

Pascal

Pascal (or Upper) case uses mixed case with lower and upper cased characters. Separates words from each other with the upper case letters. Starts with upper case letter.

Recase.to_pascal("some-value") # => "SomeValue"
Recase.to_pascal("Some value") # => "SomeValue"

Camel

Camel case uses mixed case with lower and upper cased characters. Separates words from each other with the upper cased letters. Starts with lower case letter.

Recase.to_camel("some-value") # => "someValue"
Recase.to_camel("Some Value") # => "someValue"

Snake

Snake cases uses all lower case. Uses _ as a separator.

Recase.to_snake("someValue") # => "some_value"
Recase.to_snake("Some Value") # => "some_value"

Kebab

Kebab cases uses all lower case. Uses - as a separator.

Recase.to_kebab("someValue") # => "some-value"
Recase.to_kebab("Some Value") # => "some-value"

Constant

Constant case uses all upper case. Uses _ as a separator.

Recase.to_constant("SomeValue") # => "SOME_VALUE"
Recase.to_constant("some value") # => "SOME_VALUE"

Dot

Dot case uses all lower case similar to snake case. Uses . as a separator.

Recase.to_dot("SomeValue") # => "some.value"
Recase.to_dot("some value") # => "some.value"

Path

Path case preserves case, you can also provide a separator as the second argument.

Recase.to_path("SomeValue") # => "Some/Value"
Recase.to_path("some value", "\\") # => "some\\value"

Sentence

Sentence case uses the same rules as regular sentence. First letter is uppercase all others letters are lowercase separated by spaces.

Recase.to_sentence("SomeValue") # => "Some value"
Recase.to_sentence("some value") # => "Some value"

Title

Title case applies a "Title Style" to all words in a sentence.

Recase.to_title("some-value") # => "Some Value"
Recase.to_title("some value") # => "Some Value"

Header

Header case uses the same case as PascalCase, while using - as a separator.

Recase.to_header("SomeValue") # => "Some-Value"
Recase.to_header("some value") # => "Some-Value"

Enumerable

You can convert all keys in an enumerable with:

Recase.Enumerable.convert_keys(
  %{"yourKey" => "value"},
  &Recase.to_snake/1
) # => %{"your_key" => "value"}

Recase.Enumerable.convert_keys(
  %{"your_key" => "value"},
  &Recase.to_camel/1
) # => %{"yourKey" => "value"}

Recase.Enumerable.atomize_keys(
  %{"yourKey" => "value"},
  &Recase.to_snake/1
) # => %{your_key: "value"}

Recase.Enumerable.atomize_keys(
  %{"your_key" => "value"},
  &Recase.to_camel/1
) # => %{yourKey: "value"}

Changelog

Full changelog is available here.

Copyright and License

Copyright (c) 2017 Nikita Sobolev

This work is free. You can redistribute it and/or modify it under the terms of the MIT License. See the LICENSE.md file for more details.

Thanks

Thanks to Gyan Lakhwani for the logo.

More Repositories

1

wemake-python-styleguide

The strictest and most opinionated python linter ever!
Python
2,417
star
2

wemake-django-template

Bleeding edge django template focused on code quality and security.
Python
1,933
star
3

django-split-settings

Organize Django settings into multiple files and directories. Easily override and modify settings. Use wildcards and optional settings files.
Python
1,031
star
4

wemake-vue-template

Bleeding edge vue template focused on code quality and developer happiness.
TypeScript
730
star
5

django-test-migrations

Test django schema and data migrations, including migrations' order and best practices.
Python
490
star
6

wemake-python-package

Bleeding edge cookiecutter template to create new python packages
Python
395
star
7

flake8-eradicate

Flake8 plugin to find commented out or dead code
Python
304
star
8

dotenv-linter

โ˜บ๏ธ Linting dotenv files like a charm!
Python
270
star
9

caddy-gen

Automated Caddy reverse proxy for docker containers
Shell
229
star
10

nuxt-imagemin

Nuxt module to minify your images. Works with: png, jpeg, gif, and svg
JavaScript
178
star
11

ecto_autoslug_field

Automatically create slugs for Ecto schemas.
Elixir
147
star
12

jekyll-theme-hackcss

Dead simple CSS framework now with Jekyll.
HTML
123
star
13

docker-image-size-limit

๐Ÿณ Keep an eye on your docker image size and prevent it from growing too big
Python
113
star
14

flake8-broken-line

๐Ÿšจ Flake8 plugin to forbid backslashes (\) for line breaks
Python
108
star
15

kira-dependencies

๐Ÿฟ Kira's micro-bot to update project dependencies
Ruby
102
star
16

dump-env

A utility tool to create .env files
Python
97
star
17

wemake-frontend-styleguide

Set of the strictest linters for your next frontend app
JavaScript
74
star
18

kira

๐Ÿฟ๏ธ Project management framework with deep philosophy underneath
Elixir
69
star
19

coverage-conditional-plugin

Conditional coverage based on any rules you define!
Python
63
star
20

meta

Home of Repeatable Software Development Process
HTML
51
star
21

pravda

Python type-checker written in Rust
Makefile
33
star
22

nuxt-babel

Use normal .babelrc file with your Nuxt app
JavaScript
33
star
23

asyncio-redis-rate-limit

Rate limiter for async functions using Redis as a backend.
Python
30
star
24

vue-material-input

Simple implementation of Material Input with no dependencies
Vue
24
star
25

vue-analytics-facebook-pixel

A small wrapper around Facebook Pixel API
JavaScript
23
star
26

mypy-extras

A collection of extra types and features for mypy
Python
22
star
27

caddy-docker

Docker image for Caddy
Dockerfile
19
star
28

awesome-microtasking

List of awesome resources and companies that practice microtasking
15
star
29

jinja2-git

Jinja2 extension to handle git-specific things
Python
15
star
30

safe-assert

Safe and composable assert for Python that can be used together with optimised mode
Python
13
star
31

kira-stale

๐Ÿฟ๏ธ Kira's micro-bot to fight with stale GitLab issues and merge requests
Procfile
13
star
32

pytest-modified-env

Pytest plugin to fail a test if it leaves modified `os.environ` afterwards.
Python
11
star
33

vue-material-ripple

Simple material ripple effect wrapped in a component
Vue
11
star
34

remark-lint-are-links-valid

This package allows to perform multiple checks on your links
JavaScript
11
star
35

wemake-django-rest

Create Django REST APIs the right way, no magic intended
HTML
11
star
36

wemake-dind

Our docker-in-docker image with Python
Dockerfile
10
star
37

stylelint-config-strict-scss

Deprecated, use wemake-frontend-styleguide instead
JavaScript
8
star
38

kira-review

๐Ÿฟ๏ธ Kira's micro-bot to review merge requests before real humans
Ruby
7
star
39

django-pre-deploy-checks

Django checks that you should run on application deploy
Python
5
star
40

mimesis-cloud

Python
5
star
41

kira-release

๐Ÿฟ๏ธ Kira's micro-bot to release your code and track changes
JavaScript
5
star
42

vue-material-radio

Simple implementation of Material Radio Button with no dependencies
Vue
4
star
43

eslint-config-flowtype-essential

Deprecated, use wemake-frontend-styleguide instead
JavaScript
4
star
44

kira-setup

๐Ÿฟ Kira's micro-bot to setup new projects
Python
3
star
45

remark-lint-list-item-punctuation

This package allows to check either a list item ends with a period.
JavaScript
3
star
46

eslint-config-jsdoc-essential

Deprecated, use wemake-frontend-styleguide instead
JavaScript
2
star
47

.github

GitHub metadata
1
star
48

wemake-services.github.io

Company's website. As minimal as possible.
JavaScript
1
star