CaseStyle behaviour (case_style v0.5.0)

Library from converting to different CaseSyles

Currently implemented:

Link to this section Summary

Functions

same as camel_to_kebab but return a string on success and raises on error on failure

same as camel_to_pascal but return a string on success and raises on error on failure

same as camel_to_snake but return a string on success and raises on error on failure

parse given input with the given module

same as graphql_to_snake but return a string on success and raises on error on failure

same as kebab_to_camel but return a string on success and raises on error on failure

same as kebab_to_pascal but return a string on success and raises on error on failure

same as kebab_to_snake but return a string on success and raises on error on failure

same as pascal_to_camel but return a string on success and raises on error on failure

same as pascal_to_kebab but return a string on success and raises on error on failure

same as pascal_to_snake but return a string on success and raises on error on failure

same as snake_to_camel but return a string on success and raises on error on failure

same as snake_to_graphql but return a string on success and raises on error on failure

same as snake_to_kebab but return a string on success and raises on error on failure

same as snake_to_pascal but return a string on success and raises on error on failure

dump given input with the given module

Link to this section Types

Link to this type

nimble_parsec_error()

Specs

nimble_parsec_error() ::
  {:error, binary(), binary(), map(), {pos_integer(), pos_integer()},
   pos_integer()}
Link to this type

parser_output()

Specs

parser_output() ::
  {:ok, list(), binary(), map(), {pos_integer(), pos_integer()}, pos_integer()}

Specs

t() :: %CaseStyle{from_type: module(), tokens: CaseStyle.Tokens.t()}

Link to this section Callbacks

Link to this callback

matches?(input)

Specs

matches?(input :: binary()) :: boolean()

Specs

parse(input :: binary()) :: parser_output() | nimble_parsec_error()

Specs

to_string(t()) :: binary()

Link to this section Functions

Link to this function

camel_to_kebab(input)

Specs

camel_to_kebab(binary()) :: {:ok, binary()} | nimble_parsec_error()

Converts from CaseStyle.CamelCase to CaseStyle.KebabCase

Link to this function

camel_to_kebab!(input)

Specs

camel_to_kebab!(binary()) :: binary()

same as camel_to_kebab but return a string on success and raises on error on failure

Link to this function

camel_to_pascal(input)

Specs

camel_to_pascal(binary()) :: {:ok, binary()} | nimble_parsec_error()

Converts from CaseStyle.CamelCase to CaseStyle.PascalCase

Link to this function

camel_to_pascal!(input)

Specs

camel_to_pascal!(binary()) :: binary()

same as camel_to_pascal but return a string on success and raises on error on failure

Link to this function

camel_to_snake(input)

Specs

camel_to_snake(binary()) :: {:ok, binary()} | nimble_parsec_error()

Converts from CaseStyle.CamelCase to CaseStyle.SnakeCase

Link to this function

camel_to_snake!(input)

Specs

camel_to_snake!(binary()) :: binary()

same as camel_to_snake but return a string on success and raises on error on failure

Link to this function

from_string(input, module)

Specs

from_string(binary(), module()) ::
  {:ok, t()} | parser_output() | nimble_parsec_error()

parse given input with the given module

iex> CaseStyle.from_string("snake_case", CaseStyle.SnakeCase)
{:ok,
   %CaseStyle{
     from_type: CaseStyle.SnakeCase,
     tokens: [
       %CaseStyle.Tokens.Start{},
       %CaseStyle.Tokens.FirstLetter{value: 's'},
       %CaseStyle.Tokens.Char{value: 'n'},
       %CaseStyle.Tokens.Char{value: 'a'},
       %CaseStyle.Tokens.Char{value: 'k'},
       %CaseStyle.Tokens.Char{value: 'e'},
       %CaseStyle.Tokens.Spacing{},
       %CaseStyle.Tokens.AfterSpacingChar{value: 'c'},
       %CaseStyle.Tokens.Char{value: 'a'},
       %CaseStyle.Tokens.Char{value: 's'},
       %CaseStyle.Tokens.Char{value: 'e'},
       %CaseStyle.Tokens.End{}
     ]
   }
}
Link to this function

graphql_to_snake(input)

Specs

graphql_to_snake(binary()) :: {:ok, binary()} | nimble_parsec_error()

Converts from CaseStyle.GraphQLCase to CaseStyle.SnakeCase

Link to this function

graphql_to_snake!(input)

Specs

graphql_to_snake!(binary()) :: binary()

same as graphql_to_snake but return a string on success and raises on error on failure

Link to this function

kebab_to_camel(input)

Specs

kebab_to_camel(binary()) :: {:ok, binary()} | nimble_parsec_error()

Converts from CaseStyle.KebabCase to CaseStyle.CamelCase

Link to this function

kebab_to_camel!(input)

Specs

kebab_to_camel!(binary()) :: binary()

same as kebab_to_camel but return a string on success and raises on error on failure

Link to this function

kebab_to_pascal(input)

Specs

kebab_to_pascal(binary()) :: {:ok, binary()} | nimble_parsec_error()

Converts from CaseStyle.KebabCase to CaseStyle.PascalCase

Link to this function

kebab_to_pascal!(input)

Specs

kebab_to_pascal!(binary()) :: binary()

same as kebab_to_pascal but return a string on success and raises on error on failure

Link to this function

kebab_to_snake(input)

Specs

kebab_to_snake(binary()) :: {:ok, binary()} | nimble_parsec_error()

Converts from CaseStyle.KebabCase to CaseStyle.SnakeCase

Link to this function

kebab_to_snake!(input)

Specs

kebab_to_snake!(binary()) :: binary()

same as kebab_to_snake but return a string on success and raises on error on failure

Link to this function

pascal_to_camel(input)

Specs

pascal_to_camel(binary()) :: {:ok, binary()} | nimble_parsec_error()

Converts from CaseStyle.PascalCase to CaseStyle.CamelCase

Link to this function

pascal_to_camel!(input)

Specs

pascal_to_camel!(binary()) :: binary()

same as pascal_to_camel but return a string on success and raises on error on failure

Link to this function

pascal_to_kebab(input)

Specs

pascal_to_kebab(binary()) :: {:ok, binary()} | nimble_parsec_error()

Converts from CaseStyle.PascalCase to CaseStyle.KebabCase

Link to this function

pascal_to_kebab!(input)

Specs

pascal_to_kebab!(binary()) :: binary()

same as pascal_to_kebab but return a string on success and raises on error on failure

Link to this function

pascal_to_snake(input)

Specs

pascal_to_snake(binary()) :: {:ok, binary()} | nimble_parsec_error()

Converts from CaseStyle.PascalCase to CaseStyle.SnakeCase

Link to this function

pascal_to_snake!(input)

Specs

pascal_to_snake!(binary()) :: binary()

same as pascal_to_snake but return a string on success and raises on error on failure

Link to this function

snake_to_camel(input)

Specs

snake_to_camel(binary()) :: {:ok, binary()} | nimble_parsec_error()

Converts from CaseStyle.SnakeCase to CaseStyle.CamelCase

Link to this function

snake_to_camel!(input)

Specs

snake_to_camel!(binary()) :: binary()

same as snake_to_camel but return a string on success and raises on error on failure

Link to this function

snake_to_graphql(input)

Specs

snake_to_graphql(binary()) :: {:ok, binary()} | nimble_parsec_error()

Converts from CaseStyle.SnakeCase to CaseStyle.GraphQLCase

Link to this function

snake_to_graphql!(input)

Specs

snake_to_graphql!(binary()) :: binary()

same as snake_to_graphql but return a string on success and raises on error on failure

Link to this function

snake_to_kebab(input)

Specs

snake_to_kebab(binary()) :: {:ok, binary()} | nimble_parsec_error()

Converts from CaseStyle.SnakeCase to CaseStyle.KebabCase

Link to this function

snake_to_kebab!(input)

Specs

snake_to_kebab!(binary()) :: binary()

same as snake_to_kebab but return a string on success and raises on error on failure

Link to this function

snake_to_pascal(input)

Specs

snake_to_pascal(binary()) :: {:ok, binary()} | nimble_parsec_error()

Converts from CaseStyle.SnakeCase to CaseStyle.PascalCase

Link to this function

snake_to_pascal!(input)

Specs

snake_to_pascal!(binary()) :: binary()

same as snake_to_pascal but return a string on success and raises on error on failure

Link to this function

to_string(input, module)

Specs

to_string(t(), module()) :: binary()

dump given input with the given module

iex> input = %CaseStyle{
...>  from_type: CaseStyle.SnakeCase,
...>  tokens: [
...>   %CaseStyle.Tokens.Start{},
...>   %CaseStyle.Tokens.FirstLetter{value: 's'},
...>   %CaseStyle.Tokens.Char{value: 'n'},
...>   %CaseStyle.Tokens.Char{value: 'a'},
...>   %CaseStyle.Tokens.Char{value: 'k'},
...>   %CaseStyle.Tokens.Char{value: 'e'},
...>   %CaseStyle.Tokens.Spacing{},
...>   %CaseStyle.Tokens.AfterSpacingChar{value: 'c'},
...>   %CaseStyle.Tokens.Char{value: 'a'},
...>   %CaseStyle.Tokens.Char{value: 's'},
...>   %CaseStyle.Tokens.Char{value: 'e'},
...>   %CaseStyle.Tokens.End{}
...>  ]
...> }
iex> CaseStyle.to_string(input, CaseStyle.CamelCase)
"snakeCase"