Introducing Chars 0.1.0

Yesterday I released the first version of Chars. Chars is a Ruby library for working with character sets, generating random text and determining whether Strings or Integers belong to specific sets. Originally, Chars was part of the Ronin code-base, but was split-out in order to keep Ronin small and to promote code-reuse. So without further ado, here’s some examples of what Chars can do:

  • Determine whether a byte belongs to a character set:

    # => true
  • Determine whether a String belongs to a character set:

    # => true
  • Find all sub-strings that belong to a character set within a String:

    ls ='/bin/ls')
    # => ["/lib64/", "KIq/", "5J~!", "%L~!", ...]
  • Return a random character from the set of all characters:

    # => "\x94"
  • Return a random Array of characters from the alpha-numeric character set:

    # => ["Q", "N", "S", "4", "x", "z", "3", "M", "F", "F"]
  • Return a random String from the set of all characters:

    # => "\xc2h\xad\xccm7\x1e6J\x13"
  • Return a random String with a random length between 5 and 10, from the set of space characters:
    # => "\r\v\n\t\n\f"

You can install Chars as a rubygem using the following command:

$ sudo gem install chars

If you want to hack on Chars, the code-base is available on GitHub.


About this entry