Sha256: dfdd386b502a728bce44ad259a388cc9dba51b951297513c500cf6963d9e37f2

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

# Banned Words
Detects and masks banned words within a text

[![Build Status](https://secure.travis-ci.org/razvan-sv/banned_words.png?branch=master)](http://travis-ci.org/razvan-sv/banned_words)

## Installation

Add this line in your Gemfile:

```ruby
gem 'banned_words'
```
Then you need to run:

```ruby
rails g banned_words
```
to generate the banned_words.yml file.

## Usage

### Masking
```ruby
# 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
```ruby
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
```ruby
BannedWords.list
> ['dog', 'fox', 'over']
```

### Removing
```ruby
BannedWords.remove('dog')
BannedWords.list
> ['fox', 'over']

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

## Copyright

See LICENSE for details.

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
banned_words-0.1.1 README.md