WebPurify RubyGem
This gem allows simple interaction with the WebPurify API using Ruby. For more information about WebPurify and the services it offers, check out http://webpurify.com/.
Commands
Text Filters
- check
- check_count
- replace
- return
Blacklist
- add_to_blacklist
- remove_from_blacklist
- get_blacklist
Whitelist
- add_to_whitelist
- remove_from_whitelist
- get_whitelist
Image Filters
- imgcheck
- imgstatus
- imgaccount
Install & Initialize
gem install webpurify
or with bundler
gem webpurify
bundle install
Initialize with
@wp = WebPurify::Client.new('my_api_key')
or
@wp = WebPurify::Client.new({
api_key: 'my_api_key',
endpoint: :us, # can be :us, :eu, :ap (defaults to :us)
enterprise: false, # true for ssl (default false, enterprise key required)
})
Commands
puts @wp.check('some profane text')
puts @wp.check_count('profane text')
puts @wp.replace('profane text', '*')
p @wp.return('profane text')
All text filter commands can take an additional options object, just before the callback. The available options are:
options = {
lang: 'en', # the 2 letter language code for the text you are submitting
semail: 1, # treat email addresses like profanity
sphone: 1, # treat phone numbers like profanity
slink: 1 # treat urls like profanity
}
puts @wp.check('some profane text', options)
@wp.add_to_blacklist('my_awesome_word')
For Deep search, add optional parameter 1 after word:
@wp.add_to_blacklist('my_awesome_word', 1)
@wp.remove_from_blacklist('my_awesome_word')
p @wp.get_blacklist
@wp.add_to_whitelist('my_awesome_word')
@wp.remove_from_whitelist('my_awesome_word')
p @wp.get_whitelist
puts @wp.imgcheck(imgurl)
imgcheck can take an additional options object. The available options are:
options = {
customimgid: 1 # Custom ID that will be associated with the image
callback: url # Callback URL that will receive a GET request once the image has been moderated
}
puts @wp.imgcheck(imgurl, options)
puts @wp.imgstatus(imgid)
imgstatus can take an additional options object. The available options are:
options = {
customimgid: 1 # Custom ID that is associated with the image
}
puts @wp.imgstatus(imgid, options)
p @wp.imgaccount
- Handle error responses
- Tests