censor_bear 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/censor_bear/censor.rb +16 -0
- data/lib/censor_bear/version.rb +1 -1
- data/lib/censor_bear.rb +6 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: afa762c57b39c4646ab5d236763e02f0f7cdb8f32a0e9b38058ccf342382e526
|
4
|
+
data.tar.gz: e82d0275c7be7525037a91451d852d54549686f3fed0ca4d73a142a64f2e7b34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7e2ca96a5d99afcfdbac547d67bfa7e4dbe21e321e2a260db2006cbf1943577cb8b9306150a01d308e23c25f6d51399af7f4cbbfb592be50d3a4a0d4d8fc91f
|
7
|
+
data.tar.gz: 95fe89608248a273f2fa5e2560afe8ec9510555bee25afe542057c93f04799cc841b34d23be8846f8fcc1eeccfd7846a70b2887d926062f0f1a4f5fded287def
|
data/lib/censor_bear/censor.rb
CHANGED
@@ -42,6 +42,22 @@ module CensorBear
|
|
42
42
|
Result.new(@content, @is_mod, @mod_words.uniq)
|
43
43
|
end
|
44
44
|
|
45
|
+
# default type = :ugc
|
46
|
+
def check_search
|
47
|
+
result = false
|
48
|
+
stop_words = CensorBear::StopWord.where("#{@type} != 'IGNORE'")
|
49
|
+
stop_words.each do |word|
|
50
|
+
finder = Regexp.new(Regexp.escape(word.key))
|
51
|
+
action = word.send(@type.to_sym).upcase
|
52
|
+
if finder.match(@content)
|
53
|
+
result = true
|
54
|
+
CensorBear.info(@content, @type, action, 'check_search', mod_words: [word.key])
|
55
|
+
break
|
56
|
+
end
|
57
|
+
end
|
58
|
+
result
|
59
|
+
end
|
60
|
+
|
45
61
|
def local_check
|
46
62
|
original_content = @content.dup
|
47
63
|
stop_words = CensorBear::StopWord.where("#{@type} != 'IGNORE'")
|
data/lib/censor_bear/version.rb
CHANGED
data/lib/censor_bear.rb
CHANGED
@@ -31,9 +31,13 @@ module CensorBear
|
|
31
31
|
Censor.new(content, type).check_text
|
32
32
|
end
|
33
33
|
|
34
|
+
def check_search(content)
|
35
|
+
Censor.new(content, "ugc").check_search
|
36
|
+
end
|
37
|
+
|
34
38
|
def info(content, scenario, action, stage, options = {})
|
35
|
-
filtered_content = options[
|
36
|
-
mod_words = options[
|
39
|
+
filtered_content = options[:filtered_content] || nil
|
40
|
+
mod_words = options[:mod_words] || []
|
37
41
|
|
38
42
|
CensorBear::Log.create(
|
39
43
|
original_content: content,
|