Cregularity
A Crystal port of andrewberls's Regularity gem for Ruby.
Installation
Add this to your application's shard.yml
:
dependencies:
cregularity:
github: spencerwi/cregularity
Usage
The API basically mirrors the Regularity gem, though you instantiate it as Cregularity.new
.
To borrow one of the original gem's examples:
require "cregularity"
re = Cregularity.new
.start_with(3, :digits)
.then("-")
.then(2, :letters)
.maybe("#")
.one_of(["a", "b"])
.between([2,4], "a")
.end_with("s")
if (re =~ "123-ff#baaas")
puts "It works!"
end
Development
To run tests:
$ crystal spec
Contributing
- Fork it (https://github.com/spencerwi/cregularity/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Contributors
- spencerwi - creator, maintainer
- andrewberls - the developer of the original gem