A set of helpers for elixir.
Add henchman
to your list of dependencies in mix.exs
:
def deps do
[{:henchman, "~> 0.3.0"}]
end
Henchman provides a set helpers that will come in handy.
Generate random string for a specific length. There are 4 types supported:
:alphanumeric
- Random alphanumeric string:numeric
- Random numeric only string:upper
- Random non-numeric only string:lower
- Random non-numeric only string
iex> Henchman.Randomizer.generate(20) #generate alphanumeric string
iex> Henchman.Randomizer.generate(20, :numeric) #generate numeric only string
Generate acronym from string.
iex> Henchman.String.acronym("foo bar")#FB
Convert string to camelCase
.
iex> Henchman.String.camel_case("foo-bar")#fooBar
Determine if string contains alphabets only.
iex> Henchman.String.is_alpha?("fooBAR")#true
Determine if string contains alphabets and integers.
iex> Henchman.String.is_alphanumeric?("123fooBAR")#true
Determine if string is blank.
iex> Henchman.String.is_blank?("")#true
Determine if string contains lower case characters only.
iex> Henchman.String.is_lowercase?("foo")#true
Determine if string contains integers only.
iex> Henchman.String.is_numeric?("123")#true
Determine if string contains upper case characters only.
iex> Henchman.String.is_uppercase?("BAR")#true
Convert string to slug format.
iex> Henchman.String.slug("Foo bar")#foo-bar
iex> Henchman.String.slug("Foo bar", "_")#foo_bar
Convert string to snake_case
.
iex> Henchman.String.snake_case("FooBar")#foo_bar
iex> Henchman.String.snake_case("FooBar", "-")#foo-bar
Convert string to StudlyCase
.
iex> Henchman.String.studly_case("foo-bar")#FooBar
Capitalize every first letters in a string.
iex> Henchman.String.title_case("foo bar-baz")#Foo Bar-baz
The string module can either truncate characters or words within a string.
iex> Henchman.String.limit("Foo bar baz baz", 10)#Foo bar ba....
iex> Henchman.String.word_limit("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", 7)#Lorem ipsum dolor sit amet, consectetur adipiscing...
Released under the MIT license - see LICENSE
for details.