Project

webpurify

0.01
Low commit activity in last 3 years
No release in over a year
A RubyGem for interfacing with the WebPurify API.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
~> 3.10.0

Runtime

>= 0
 Project Readme

WebPurify RubyGem

Gem Version Build Status

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

### check Check a string of text for profanity. Returns true if profanity found, false if none.
puts @wp.check('some profane text')
### check_count Check a string of text for profanity. Returns number of words if profanity found, 0 if none.
puts @wp.check_count('profane text')
### replace Check a string of text for profanity. Replaces any found profanity with a provided symbol, and returns the formatted string.
puts @wp.replace('profane text', '*')
### return Check a string of text for profanity. If any found, returns an array of profane words. Else, returns empty array.
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)
### add_to_blacklist Add a word to the blacklist.
@wp.add_to_blacklist('my_awesome_word')

For Deep search, add optional parameter 1 after word:

@wp.add_to_blacklist('my_awesome_word', 1)
### remove_from_blacklist Remove a word from the blacklist.
@wp.remove_from_blacklist('my_awesome_word')
### get_blacklist Get the blacklist as an array of words.
p @wp.get_blacklist
### add_to_whitelist Add a word to the whitelist.
@wp.add_to_whitelist('my_awesome_word')
### remove_from_whitelist Remove a word from the whitelist.
@wp.remove_from_whitelist('my_awesome_word')
### get_whitelist Get the whitelist as an array of words.
p @wp.get_whitelist
### imgcheck Submit an image to the moderation service. Returns an image ID that is used to return the results of the moderation to a callback function.
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)
### imgstatus Check the moderation status of an image. Returns one of the following strings: pending, approved, declined.
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)
### imgaccount Check the number of image submissions remaining on your license. Returns an integer.
p @wp.imgaccount
  • Handle error responses
  • Tests