bad_words 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/bad_words.gemspec +1 -1
- data/lib/bad_words.rb +10 -11
- data/test/bad_words_test.rb +1 -0
- metadata +3 -3
data/bad_words.gemspec
CHANGED
data/lib/bad_words.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
1
3
|
module BadWords
|
2
4
|
|
3
5
|
#Str : String a ser limpa
|
@@ -5,14 +7,15 @@ module BadWords
|
|
5
7
|
#Nivel 2 : clean block words {exemplo name of concurrence, name of group or products of group}
|
6
8
|
#Nivel 3 : use all filters
|
7
9
|
def self.make_clean(str, nivel)
|
8
|
-
|
10
|
+
words_define = ""
|
11
|
+
load_words
|
9
12
|
if nivel == 1 || nivel == 3
|
10
|
-
|
13
|
+
words_define << @words['bad_words'] << " "
|
11
14
|
end
|
12
15
|
if nivel == 2 || nivel == 3
|
13
|
-
|
16
|
+
words_define << @words['block_words']
|
14
17
|
end
|
15
|
-
clean_string(str,
|
18
|
+
clean_string(str, words_define.split(' '))
|
16
19
|
end
|
17
20
|
|
18
21
|
def self.clean_string(str, bad_words)
|
@@ -21,12 +24,8 @@ module BadWords
|
|
21
24
|
(str_broken - bad_words).join(' ')
|
22
25
|
end
|
23
26
|
|
24
|
-
def self.
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
def self.generate_block_words
|
29
|
-
"ig"
|
30
|
-
end
|
27
|
+
def self.load_words
|
28
|
+
@words = YAML.load_file("./config/words.yml")
|
29
|
+
end
|
31
30
|
|
32
31
|
end
|
data/test/bad_words_test.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bad_words
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 3
|
10
|
+
version: 0.1.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Alessandro Neri
|