Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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
Blacklist
Whitelist
Image Filters

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')

Text Filter Options

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 Options

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 Options

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

To-do:

  • Handle error responses
  • Tests

About

RubyGem for WebPurify

Resources

License

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages