0.0
No commit activity in last 3 years
No release in over 3 years
Detects and masks banned words within a text
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

>= 3.0
>= 0

Runtime

>= 3.0
 Project Readme

Banned Words

Detects and masks banned words within a text

Build Status

Installation

Add this line in your Gemfile:

gem 'banned_words'

Then you need to run:

rails g banned_words

to generate the banned_words.yml file.

Usage

Masking

# Single banned word
BannedWords.create!('dog')
phrase = 'Red d-o-g'
BannedWords.mask(phrase)
> 'Red *Buzz*'

# With an array of banned words
BannedWords.create!(['fox', 'over'])
phrase = 'The quick brown fox jumps over the lazy dog'
BannedWords.mask(phrase)
> 'The quick brown *Buzz* jumps *Buzz* the lazy *Buzz*'

# Override the masking word
BannedWords.mask(phrase, "*Bad Word*")
> 'The quick brown *Bad Word* jumps *Bad Word* the lazy *Bad Word*'

Detecting

BannedWords.create!(['quick', 'jumps'])
phrase = 'The q-u#-_^i!c~k brown fox j=u m p?s over the lazy dog'
BannedWords.detect(phrase)
> ['q-u#-_^i!c~k', 'j=u m p?s']

Listing

BannedWords.list
> ['dog', 'fox', 'over']

Removing

BannedWords.remove('dog')
BannedWords.list
> ['fox', 'over']

# Another example:
BannedWords.remove(['fox', 'over'])
BannedWords.list
> []

Copyright

See LICENSE for details.