Bomberman
This is a ruby client gem for the Bomberman HTTP API. It has been built and tested against Ruby 1.9.3.
Bomberman: shelter from profanity bombing, is an add-on for Heroku applications. If you would like to be part of the alpha or early beta testing process please email [email protected].
For detailed instructions on installing the addon to your Heroku application please see our add-on documentation page
Using with Rails 3.x
We developed a ruby client gem for making requests to the Bomberman API.
Ruby on Rails applications will need to add the following entry into their Gemfile
specifying the Bomberman client library.
gem 'bomberman'
Update application dependencies with bundler.
$ bundle install
Now create an initializer file config/initializers/bomberman.rb
with
your BOMBERMAN_API_KEY
Bomberman.configure do |config|
config.api_key = ENV['BOMBERMAN_API_KEY']
end
From here you can call the Bomberman::Profanity functionality within your application.
Checking if Text Contains Profanity
To check if a piece of text or corpus contains profanity use the
.profane?(corpus)
method. This will return a boolean value as the
result
non_profane_text = "The quick brown fox jumped over the lazy dog."
Bomberman::Profanity.profane?(non_profane_text)
#=> false
profane_text = "The quick brown fox jumped over the F-BOMBing lazy dog."
Bomberman::Profanity.profane?(profane_text)
#=> true
Censoring Profane Words & Phrases
If you would like to save or display text where the profane words (if
any) are obfuscated the .censor(corpus, replacement_text)
method is
what you are looking for.
non_profane_text = "The quick brown fox jumped over the lazy dog."
Bomberman::Profanity.censor(non_profane_text, "####")
#=> "The quick brown fox jumped over the lazy dog."
profane_text = "The quick brown fox jumped over the F-BOMBing lazy dog."
Bomberman::Profanity.censor(profane_text, "####")
#=> "The quick brown fox jumped over the ### lazy dog."
The replacement_text
parameter is a string and optional. "***"
is
suppled by default.
Highlighting Profane Words & Phrases
Sometimes it is useful to leave the original profane word/phrase intact
but wrap it in some sort of tag to make it stand out. This can be
accomplished with the .highlight(corpus, start_tag, end_tag)
method.
non_profane_text = "The quick brown fox jumped over the lazy dog."
BomberMan::Profanity.highlight(non_profane_text, "<blink>", "</blink>")
#=> "The quick brown fox jumped over the lazy dog."
profane_text = "The quick brown fox jumped over the F-BOMBing lazy dog."
BomberMan::Profanity.highlight(profane_text, "<blink>", "</blink>")
#=> "The quick brown fox jumped over the <blink>F-BOMBing</blink> lazy dog."
The start_tag
& end_tag
parameters are strings and optional. A pair
of opening and closing <span>
tags are used if none are provided.
Checking Japanese Text for Profanity.
Bomberman supports for checking Japanese text for profanity.
To do this pass an optional language argument with the value :ja
as the
last parameter to any of the Bomberman::Profanity
methods
non_profane_text = "聖パトリックの日"
Bomberman::Profanity.profane?(non_profane_text, :ja)
#=> false
For more info on customizing Bomberman please refer to the add-on documentation.
Troubleshooting
We are just starting out. If you experience trouble please contact us at [email protected].
Contributing
Given the early stage of this project we are open to comments & suggestions for this library please send them to [email protected].