word_censored 0.1.6 → 0.1.7
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 +34 -5
- data/lib/word_censored/version.rb +1 -1
- data/lib/word_censored.rb +3 -5
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: aed64d8a549257118000847dede5d6789b010b5c09025a72bbcaf0ad3c13e8cd
|
|
4
|
+
data.tar.gz: 4dc36a9d36c170d95b3d1e3554a0759005a3b14abcfb59aca23d02340ff01605
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5d73e37047d797ab3d1bc631be40cd85f71eec6dc4838cc3c4e70dd5474bc8df120c48c0ad22cd0372a20437ebb200aefeb02260808f3437a33a03930edcba1a
|
|
7
|
+
data.tar.gz: 399b07216ff0ae859624d6017a1f014b60a8f4d148d8ca32ab372098d9232cbbb5b81f1fd9fb7fea55c3f38ee94dd56ecfec0564afbf79e88e1b53897cb9a9e4
|
data/README.md
CHANGED
|
@@ -2,14 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/word_censored`. To experiment with that code, run `bin/console` for an interactive prompt.
|
|
4
4
|
|
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
|
6
|
-
|
|
7
5
|
## Installation
|
|
8
6
|
|
|
9
7
|
Add this line to your application's Gemfile:
|
|
10
8
|
|
|
11
9
|
```ruby
|
|
12
|
-
gem 'word_censored'
|
|
10
|
+
gem 'word_censored', '~> 0.1.6'
|
|
13
11
|
```
|
|
14
12
|
|
|
15
13
|
And then execute:
|
|
@@ -36,6 +34,37 @@ filter('bad word')
|
|
|
36
34
|
> *** ****
|
|
37
35
|
```
|
|
38
36
|
|
|
37
|
+
## External Badword
|
|
38
|
+
If you want to add more badwords, create file `blacklist.json` in `public/assets` (create folder if you don't have) and follow the format:
|
|
39
|
+
|
|
40
|
+
```ruby
|
|
41
|
+
{
|
|
42
|
+
"key": ["value", "value other ..."]
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
`"key"` : is the first letter of your input string
|
|
47
|
+
|
|
48
|
+
`"value"`: must be in an array
|
|
49
|
+
|
|
50
|
+
`ex: "github", "github wordcensored"`
|
|
51
|
+
|
|
52
|
+
```ruby
|
|
53
|
+
{
|
|
54
|
+
"g": ["github", "github wordcensored"]
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
<br/>
|
|
58
|
+
If your input string start with a number, `"key"` will be `"other"`
|
|
59
|
+
|
|
60
|
+
`ex: "2g1c"`
|
|
61
|
+
|
|
62
|
+
```ruby
|
|
63
|
+
{
|
|
64
|
+
"other": ["2g1c"]
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
39
68
|
## Development
|
|
40
69
|
|
|
41
70
|
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
@@ -44,7 +73,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
|
44
73
|
|
|
45
74
|
## Contributing
|
|
46
75
|
|
|
47
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
|
76
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/michaelt0520/word_censored. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
48
77
|
|
|
49
78
|
## License
|
|
50
79
|
|
|
@@ -52,4 +81,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
|
52
81
|
|
|
53
82
|
## Code of Conduct
|
|
54
83
|
|
|
55
|
-
Everyone interacting in the WordCensored project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
|
84
|
+
Everyone interacting in the WordCensored project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/michaelt0520/word_censored/blob/master/CODE_OF_CONDUCT.md).
|
data/lib/word_censored.rb
CHANGED
|
@@ -9,8 +9,8 @@ module WordCensored
|
|
|
9
9
|
REGEX_PREPROCESS = /([^0-9a-zàáãạảăắằẳẵặâấầẩẫậèéẹẻẽêềếểễệđìíĩỉịòóõọỏôốồổỗộơớờởỡợùúũụủưứừửữựỳỵỷỹý ])/i
|
|
10
10
|
|
|
11
11
|
def filter(str)
|
|
12
|
-
blacklist =
|
|
13
|
-
@str_array = str.split(
|
|
12
|
+
blacklist = JSON.parse(File.read(File.join(File.dirname(__FILE__), 'files/blacklist.json')))
|
|
13
|
+
@str_array = str.split(/[[:space:]]/)
|
|
14
14
|
cindex = -1
|
|
15
15
|
|
|
16
16
|
@str_array.each_with_index do |word, index|
|
|
@@ -25,8 +25,6 @@ module WordCensored
|
|
|
25
25
|
@str_array.join(' ')
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
private
|
|
29
|
-
|
|
30
28
|
def detect_badword(arr, origin_index, index, result_index = -1)
|
|
31
29
|
return result_index if arr.nil?
|
|
32
30
|
|
|
@@ -65,4 +63,4 @@ module WordCensored
|
|
|
65
63
|
rescue JSON::ParserError
|
|
66
64
|
false
|
|
67
65
|
end
|
|
68
|
-
end
|
|
66
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: word_censored
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Michael Tran
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-02-
|
|
11
|
+
date: 2020-02-28 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|