Ruby Gem by unreal


Download Project on Github

Installation

To install the gem, use the following command:

gem install rain_captcha

Getting the image

To get the URL of the CAPTCHA image, use the following code:

RainCaptcha.url("user_identifier")

Where user_identifier is a unique string which identifies the user. We recommend you to use the user's IP address, combined with the domain name of your website.

Checking the answer

To check whether user's response is correct or not, use the following code:

RainCaptcha.verify("user_identifier", "response")

Where response is a string with the submitted answer. If the submitted answer is correct, this method will return true, otherwise it will return false. If an error has occured, this method will return Net::HTTPFatalError. Call this method only once; if you need to use the returned value many times, save it in a variable.

License

Copyright © 2013 Jay Strybis

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


Advertisement