You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 19, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+124-121
Original file line number
Diff line number
Diff line change
@@ -6,21 +6,21 @@ Obscenity is a profanity filter gem for Ruby, Rails (through ActiveModel), and R
6
6
7
7
Add this line to your application's Gemfile:
8
8
9
-
```ruby
10
-
gem 'obscenity'
11
-
```
9
+
```ruby
10
+
gem 'obscenity'
11
+
```
12
12
13
13
And then execute:
14
14
15
-
```ruby
16
-
bundle install
17
-
```
15
+
```ruby
16
+
bundle install
17
+
```
18
18
19
19
Or install it yourself as:
20
20
21
-
```ruby
22
-
gem install obscenity
23
-
```
21
+
```ruby
22
+
gem install obscenity
23
+
```
24
24
25
25
## Compatibility
26
26
@@ -56,107 +56,107 @@ The following methods are available to use with Obscenity:
56
56
57
57
Example:
58
58
59
-
```ruby
60
-
Obscenity.configure do |config|
61
-
config.blacklist = "path/to/blacklist/file.yml"
62
-
config.whitelist = ["safe", "word"]
63
-
config.replacement = :stars
64
-
end
65
-
```
59
+
```ruby
60
+
Obscenity.configure do |config|
61
+
config.blacklist ="path/to/blacklist/file.yml"
62
+
config.whitelist = ["safe", "word"]
63
+
config.replacement =:stars
64
+
end
65
+
```
66
66
67
67
### Basic Usage
68
68
69
69
`Obscenity.profane?(text)` analyses the content and returns `true` or `false` based on its profanity:
70
70
71
-
```ruby
72
-
Obscenity.profane?("simple text")
73
-
=> false
74
-
75
-
Obscenity.profane?("text with shit")
76
-
=> true
77
-
```
71
+
```ruby
72
+
Obscenity.profane?("simple text")
73
+
=> false
74
+
75
+
Obscenity.profane?("text with shit")
76
+
=> true
77
+
```
78
78
79
79
`Obscenity.sanitize(text)` sanities the content and returns a new sanitized content (if profane) or the original content (if not profane):
80
80
81
-
```ruby
82
-
Obscenity.sanitize("simple text")
83
-
=> "simple text"
84
-
85
-
Obscenity.sanitize("text with shit")
86
-
=> "text with $@!#%"
87
-
```
81
+
```ruby
82
+
Obscenity.sanitize("simple text")
83
+
=> "simple text"
84
+
85
+
Obscenity.sanitize("text with shit")
86
+
=> "text with $@!#%"
87
+
```
88
88
89
89
`Obscenity.replacement(style).sanitize(text)` allows you to pass the replacement method to be used when sanitizing the given content. Available replacement values are `:default`, `:garbled`, `:stars`, `:vowels`, and a custom string.
90
90
91
-
```ruby
92
-
Obscenity.replacement(:default).sanitize("text with shit")
93
-
=> "text with $@!#%"
91
+
```ruby
92
+
Obscenity.replacement(:default).sanitize("text with shit")
93
+
=> "text with $@!#%"
94
94
95
-
Obscenity.replacement(:garbled).sanitize("text with shit")
96
-
=> "text with $@!#%"
97
-
98
-
Obscenity.replacement(:stars).sanitize("text with shit")
99
-
=> "text with ****"
95
+
Obscenity.replacement(:garbled).sanitize("text with shit")
96
+
=> "text with $@!#%"
97
+
98
+
Obscenity.replacement(:stars).sanitize("text with shit")
99
+
=> "text with ****"
100
100
101
-
Obscenity.replacement(:vowels).sanitize("text with shit")
102
-
=> "text with sh*t"
101
+
Obscenity.replacement(:vowels).sanitize("text with shit")
102
+
=> "text with sh*t"
103
103
104
-
Obscenity.replacement("[censored]").sanitize("text with shit")
105
-
=> "text with [censored]"
106
-
```
104
+
Obscenity.replacement("[censored]").sanitize("text with shit")
105
+
=> "text with [censored]"
106
+
```
107
107
108
108
`Obscenity.offensive(text)` returns an array of profane words in the given content:
109
109
110
-
```ruby
111
-
Obscenity.offensive("simple text")
112
-
=> []
113
-
114
-
Obscenity.offensive("text with shit and another biatch")
115
-
=> ["shit", "biatch"]
116
-
```
110
+
```ruby
111
+
Obscenity.offensive("simple text")
112
+
=> []
113
+
114
+
Obscenity.offensive("text with shit and another biatch")
115
+
=> ["shit", "biatch"]
116
+
```
117
117
118
118
### ActiveModel
119
119
120
120
The ActiveModel component provides easy profanity validation for your models.
121
121
122
122
First, you need to explicitly require the ActiveModel component:
0 commit comments