Skip to content

elepunk/henchman

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Henchman

Build Status Hex Downloads Hex Version

A set of helpers for elixir.

Installation

Add henchman to your list of dependencies in mix.exs:

def deps do
  [{:henchman, "~> 0.3.0"}]
end

Usage

Henchman provides a set helpers that will come in handy.

Randomizer

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

String Helpers

acronym/1

Generate acronym from string.

iex> Henchman.String.acronym("foo bar")#FB
camel_case/1

Convert string to camelCase.

iex> Henchman.String.camel_case("foo-bar")#fooBar
is_alpha?/1

Determine if string contains alphabets only.

iex> Henchman.String.is_alpha?("fooBAR")#true
is_alphanumeric?/1

Determine if string contains alphabets and integers.

iex> Henchman.String.is_alphanumeric?("123fooBAR")#true
is_blank?/1

Determine if string is blank.

iex> Henchman.String.is_blank?("")#true
is_lowercase?/1

Determine if string contains lower case characters only.

iex> Henchman.String.is_lowercase?("foo")#true
is_numeric?/1

Determine if string contains integers only.

iex> Henchman.String.is_numeric?("123")#true
is_uppercase?/1

Determine if string contains upper case characters only.

iex> Henchman.String.is_uppercase?("BAR")#true
slug/1 or slug/2

Convert string to slug format.

iex> Henchman.String.slug("Foo bar")#foo-bar
iex> Henchman.String.slug("Foo bar", "_")#foo_bar
snake_case/1 or snake_case/2

Convert string to snake_case.

iex> Henchman.String.snake_case("FooBar")#foo_bar
iex> Henchman.String.snake_case("FooBar", "-")#foo-bar
studly_case/1

Convert string to StudlyCase.

iex> Henchman.String.studly_case("foo-bar")#FooBar
title_case/1

Capitalize every first letters in a string.

iex> Henchman.String.title_case("foo bar-baz")#Foo Bar-baz
limit/2 or word_limit/2

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...

License

Released under the MIT license - see LICENSE for details.

Releases

No releases published

Packages

No packages published

Languages