censor_bear 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '084b5a745f3e2eeef9a39a15bc2f87a9a0dadfe1b0cb41a30ac4bf131338c074'
4
- data.tar.gz: c1351c23521fad8b976b36cb7d8d4eeaaf04688eb9c3463152ddd6edbd786019
3
+ metadata.gz: afa762c57b39c4646ab5d236763e02f0f7cdb8f32a0e9b38058ccf342382e526
4
+ data.tar.gz: e82d0275c7be7525037a91451d852d54549686f3fed0ca4d73a142a64f2e7b34
5
5
  SHA512:
6
- metadata.gz: 71533c0392c3e6af14ad00fed488dcbc41d1cfe8d6dff8ee8664735857ee158f78ae70ab644b073e9f5e60c48ba4a05ee1d35a61310bccf31368892d897f8714
7
- data.tar.gz: f97b66983de762c530c79d2b541c756092c5fb1e2e6fd93178783cd26633121df88afe32cd28c4cc4851215c191901614ea255dc0375397cdceb42a321382157
6
+ metadata.gz: e7e2ca96a5d99afcfdbac547d67bfa7e4dbe21e321e2a260db2006cbf1943577cb8b9306150a01d308e23c25f6d51399af7f4cbbfb592be50d3a4a0d4d8fc91f
7
+ data.tar.gz: 95fe89608248a273f2fa5e2560afe8ec9510555bee25afe542057c93f04799cc841b34d23be8846f8fcc1eeccfd7846a70b2887d926062f0f1a4f5fded287def
@@ -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'")
@@ -1,3 +1,3 @@
1
1
  module CensorBear
2
- VERSION = '0.1.4'.freeze
2
+ VERSION = '0.1.5'.freeze
3
3
  end
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['filtered_content'] || nil
36
- mod_words = options['mod_words'] || []
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,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: censor_bear
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - 42up