CssColour
Ruby CSS Colour validator.
It will tell if a colour is either:
- inherit,
- HEX
#123
or#123123
, - HSL,
- HSLA,
- RGB or
- RGBA
A couple of guidelines were used here:
- MDN's docs,
- this Ruby HEX validator and
- these Java regexes for HSL/RGB/RGBA were adapted to Ruby and made more readable.
Installation
Add this line to your application's Gemfile:
gem 'css-colour'
And then execute:
$ bundle
Or install it yourself as:
$ gem install css-colour
Usage
validator = CssColour::Validator.new 'inherit'
validator.valid? # true
You can also test against a specific colour type as follows:
validator = CssColour::Validator.new '#123456'
validator.rgb? # false
TODO
- Try to fix a colour.
Contributing
- Fork it ( http://github.com/dariocravero/css-colour/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 new Pull Request