message_judgment 0.1.31 → 1.0
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/README.md +21 -2
- data/lib/message_judgment.rb +9 -3
- data/lib/message_judgment/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e8347d067719249534d6b9b5de48ba9a18a80a9
|
4
|
+
data.tar.gz: 174ef2744c57149de5d0eca2661a61d9dee6c3ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df58323b6e1b0f13dd3a2d83414176c26834ca394dd06cf941b65425d19fe3d14cca1c36db33bd19317e911684109200438f3750930003c42331779acc8a412b
|
7
|
+
data.tar.gz: 4c7da7a97d49c4c4c9d7c0c4c2c66672851c1ed5e8978ae10ba9d1a7fd2a5bb269134b065522cb50a48adc8f27a330a0c3547db36c503c1cffbb276dc3e76950
|
data/README.md
CHANGED
@@ -19,6 +19,13 @@ Or install it yourself as:
|
|
19
19
|
$ gem install message_judgment
|
20
20
|
|
21
21
|
## Usage
|
22
|
+
|
23
|
+
`MessageJudgment.message_judgment?(message,targets,false)`
|
24
|
+
- First argument is message which you wanna check.
|
25
|
+
- Second argument is some crazy word which you wanna forbid.
|
26
|
+
- Third argument is option which you wanna select if you wanna make some forbidden words into "*",you don't need to specify.
|
27
|
+
but if you wanna make it just some blank,you gotta give false to the argument.
|
28
|
+
|
22
29
|
```ruby
|
23
30
|
irb(main):001:0> require "message_judgment"
|
24
31
|
=> true
|
@@ -26,11 +33,23 @@ irb(main):002:0> message="Hello,I want your sex!"
|
|
26
33
|
=> "Hello,I want your sex!"
|
27
34
|
irb(main):003:0> targets=["sex","fack"]
|
28
35
|
=> ["sex", "fack"]
|
29
|
-
irb(main):004:0> MessageJudgment.message_judgment?(message,targets)
|
36
|
+
irb(main):004:0> MessageJudgment.message_judgment?(message,targets,false)
|
30
37
|
=> "Hello,I want your !"
|
31
38
|
|
32
39
|
```
|
33
40
|
|
41
|
+
```ruby
|
42
|
+
irb(main):001:0> require "message_judgment"
|
43
|
+
=> true
|
44
|
+
irb(main):002:0> message="Hello,I want your sex!"
|
45
|
+
=> "Hello,I want your sex!"
|
46
|
+
irb(main):003:0> targets=["sex","fack"]
|
47
|
+
=> ["sex", "fack"]
|
48
|
+
irb(main):004:0> MessageJudgment.message_judgment?(message,targets)
|
49
|
+
=> "Hello,I want your ***!"
|
50
|
+
```
|
51
|
+
|
52
|
+
|
34
53
|
## Development
|
35
54
|
|
36
55
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -47,4 +66,4 @@ The gem is available as open source under the terms of the [MIT License](http://
|
|
47
66
|
|
48
67
|
## Code of Conduct
|
49
68
|
|
50
|
-
Everyone interacting in the MessageJudgment project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
69
|
+
Everyone interacting in the MessageJudgment project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/message_judgment/blob/master/CODE_OF_CONDUCT.md).
|
data/lib/message_judgment.rb
CHANGED
@@ -1,9 +1,15 @@
|
|
1
1
|
require "message_judgment/version"
|
2
2
|
|
3
3
|
module MessageJudgment
|
4
|
-
def self.message_judgment?(message,targets)
|
5
|
-
|
6
|
-
|
4
|
+
def self.message_judgment?(message,targets,option=true)
|
5
|
+
unless option==true
|
6
|
+
targets.each do|target|
|
7
|
+
message.slice!(target) if message.include?(target)
|
8
|
+
end
|
9
|
+
else
|
10
|
+
message.gsub!(/(#{targets.join('|')})/) do |target|
|
11
|
+
'*' * target.length
|
12
|
+
end
|
7
13
|
end
|
8
14
|
return message
|
9
15
|
end
|