A set of helpers for elixir.
Add henchman to your list of dependencies in mix.exs:
def deps do
[{:henchman, "~> 0.3.0"}]
endHenchman 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 stringGenerate acronym from string.
iex> Henchman.String.acronym("foo bar")#FBConvert string to camelCase.
iex> Henchman.String.camel_case("foo-bar")#fooBarDetermine if string contains alphabets only.
iex> Henchman.String.is_alpha?("fooBAR")#trueDetermine if string contains alphabets and integers.
iex> Henchman.String.is_alphanumeric?("123fooBAR")#trueDetermine if string is blank.
iex> Henchman.String.is_blank?("")#trueDetermine if string contains lower case characters only.
iex> Henchman.String.is_lowercase?("foo")#trueDetermine if string contains integers only.
iex> Henchman.String.is_numeric?("123")#trueDetermine if string contains upper case characters only.
iex> Henchman.String.is_uppercase?("BAR")#trueConvert string to slug format.
iex> Henchman.String.slug("Foo bar")#foo-bar
iex> Henchman.String.slug("Foo bar", "_")#foo_barConvert string to snake_case.
iex> Henchman.String.snake_case("FooBar")#foo_bar
iex> Henchman.String.snake_case("FooBar", "-")#foo-barConvert string to StudlyCase.
iex> Henchman.String.studly_case("foo-bar")#FooBarCapitalize every first letters in a string.
iex> Henchman.String.title_case("foo bar-baz")#Foo Bar-bazThe 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.