profane 0.0.3 → 0.0.4
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 +7 -0
- data/README.md +9 -4
- data/config/dictionary.yml +0 -1
- data/lib/profane/version.rb +1 -1
- data/profane.gemspec +0 -1
- data/spec/profane/filter_spec.rb +16 -16
- data/spec/profane_spec.rb +2 -2
- metadata +15 -39
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c49d8e3267c132883e16536856139ca6457011cf
|
4
|
+
data.tar.gz: 398cdbb7699d1d1a8f683038186d1323785c7f3a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d47f8b1b378aac2d40908ed441514cc7c224ce7e0f0ba86de90d4477c76a8f9decad8437659060f7d63b86a3360a74f971ea2669bea772fe218999da336a23fe
|
7
|
+
data.tar.gz: 7170e80cdba57704e0e886368f470437c7bff098536bf84050f9db3ea5cc2254d611f4a4f8061df95d7d59cd597ade01f2c525a23dcddbf860e000a7b7b2594c
|
data/README.md
CHANGED
@@ -19,15 +19,20 @@ Or install it yourself as:
|
|
19
19
|
|
20
20
|
## Usage
|
21
21
|
|
22
|
-
|
22
|
+
To get started create a `Profane::Filter`:
|
23
23
|
```
|
24
|
-
Profane::Filter.
|
24
|
+
profanity_filter = Profane::Filter.new
|
25
|
+
```
|
26
|
+
|
27
|
+
Use the `Profane::Filter#filter` method to replace the naughty bits:
|
28
|
+
```
|
29
|
+
profanity_filter.filter('Voldemort!')
|
25
30
|
=> '*********!')
|
26
31
|
```
|
27
32
|
|
28
|
-
|
33
|
+
Use the `Profane::Filter#profane?` method to see check suspicious strings:
|
29
34
|
```
|
30
|
-
|
35
|
+
profanity_filter.profane?('If you come to a fork in the road, take it.')
|
31
36
|
=> false
|
32
37
|
```
|
33
38
|
|
data/config/dictionary.yml
CHANGED
data/lib/profane/version.rb
CHANGED
data/profane.gemspec
CHANGED
data/spec/profane/filter_spec.rb
CHANGED
@@ -9,20 +9,20 @@ describe 'Profane::Filter' do
|
|
9
9
|
it "filters words from the dictionary using the default character" do
|
10
10
|
filter = Profane::Filter.new
|
11
11
|
|
12
|
-
filter.filter('fuck').
|
12
|
+
expect(filter.filter('fuck')).to eql '****'
|
13
13
|
end
|
14
14
|
|
15
15
|
it "filters words from the dictionary ignoring punctuation" do
|
16
16
|
filter = Profane::Filter.new
|
17
17
|
|
18
|
-
filter.filter('fuck!').
|
18
|
+
expect(filter.filter('fuck!')).to eql '****!'
|
19
19
|
end
|
20
20
|
|
21
21
|
it "filters words from the dictionary using a custom character" do
|
22
22
|
Profane.configure(filter_character: '&')
|
23
23
|
filter = Profane::Filter.new
|
24
24
|
|
25
|
-
filter.filter('fuck!').
|
25
|
+
expect(filter.filter('fuck!')).to eql '&&&&!'
|
26
26
|
|
27
27
|
Profane.configure(filter_character: '*')
|
28
28
|
end
|
@@ -32,21 +32,21 @@ describe 'Profane::Filter' do
|
|
32
32
|
Profane.configure(dictionary: { 'shit' => '' })
|
33
33
|
filter = Profane::Filter.new
|
34
34
|
|
35
|
-
filter.filter('shit!?').
|
35
|
+
expect(filter.filter('shit!?')).to eql '****!?'
|
36
36
|
end
|
37
37
|
|
38
38
|
it "filters words from the custom dictionary with symbol keys" do
|
39
39
|
Profane.configure(dictionary: { :shit => '' })
|
40
40
|
filter = Profane::Filter.new
|
41
41
|
|
42
|
-
filter.filter('shit!?').
|
42
|
+
expect(filter.filter('shit!?')).to eql '****!?'
|
43
43
|
end
|
44
44
|
|
45
45
|
it "filters words from the default dictionary" do
|
46
|
-
Profane.
|
46
|
+
expect(Profane).to receive(:load_yaml_dictionary).and_return({ 'shit' => '' })
|
47
47
|
filter = Profane::Filter.new
|
48
48
|
|
49
|
-
filter.filter('shit!?').
|
49
|
+
expect(filter.filter('shit!?')).to eql '****!?'
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
@@ -57,12 +57,12 @@ describe 'Profane::Filter' do
|
|
57
57
|
|
58
58
|
it "filters words from the custom dictionary" do
|
59
59
|
filter = Profane::Filter.new
|
60
|
-
filter.filter('shit!?').
|
60
|
+
expect(filter.filter('shit!?')).to eql '****!?'
|
61
61
|
end
|
62
62
|
|
63
63
|
it "doesn't filter words from the default dictionary" do
|
64
64
|
filter = Profane::Filter.new
|
65
|
-
filter.filter('fuck!?').
|
65
|
+
expect(filter.filter('fuck!?')).to eql 'fuck!?'
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
@@ -70,38 +70,38 @@ describe 'Profane::Filter' do
|
|
70
70
|
context "#profane?" do
|
71
71
|
it "returns false if the phrase is not profane" do
|
72
72
|
filter = Profane::Filter.new
|
73
|
-
filter.profane?('this is not profane').
|
73
|
+
expect(filter.profane?('this is not profane')).to be false
|
74
74
|
end
|
75
75
|
|
76
76
|
it "returns false given nil" do
|
77
77
|
filter = Profane::Filter.new
|
78
|
-
filter.profane?(nil).
|
78
|
+
expect(filter.profane?(nil)).to be false
|
79
79
|
end
|
80
80
|
|
81
81
|
it "detects the presence of words from the default dictionary" do
|
82
82
|
filter = Profane::Filter.new
|
83
|
-
filter.profane?('fuck').
|
83
|
+
expect(filter.profane?('fuck')).to be true
|
84
84
|
end
|
85
85
|
|
86
86
|
it "detects the presence of words from the custom dictionary" do
|
87
87
|
Profane.configure(dictionary: { 'microsoft' => '' })
|
88
88
|
filter = Profane::Filter.new
|
89
|
-
filter.profane?('microsoft').
|
89
|
+
expect(filter.profane?('microsoft')).to be true
|
90
90
|
end
|
91
91
|
|
92
92
|
it "ignores case" do
|
93
93
|
filter = Profane::Filter.new
|
94
|
-
filter.profane?('ruby is the SHIT').
|
94
|
+
expect(filter.profane?('ruby is the SHIT')).to be true
|
95
95
|
end
|
96
96
|
|
97
97
|
it "detects profanity in quotes" do
|
98
98
|
filter = Profane::Filter.new
|
99
|
-
filter.profane?("ruby is the 'SHIT'").
|
99
|
+
expect(filter.profane?("ruby is the 'SHIT'")).to be true
|
100
100
|
end
|
101
101
|
|
102
102
|
it "detects profanity surrounded by non-word characters" do
|
103
103
|
filter = Profane::Filter.new
|
104
|
-
filter.profane?("ruby is the -SHIT-").
|
104
|
+
expect(filter.profane?("ruby is the -SHIT-")).to be true
|
105
105
|
end
|
106
106
|
end
|
107
107
|
end
|
data/spec/profane_spec.rb
CHANGED
@@ -7,14 +7,14 @@ describe Profane do
|
|
7
7
|
|
8
8
|
context "without configuration options" do
|
9
9
|
it "loads the default dictionary" do
|
10
|
-
Profane.dictionary['fuck'].
|
10
|
+
expect(Profane.dictionary['fuck']).to eql ''
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
context "with configuration options" do
|
15
15
|
it "includes the supplied configuration options with the defaults" do
|
16
16
|
Profane.configure(dictionary: { geega: 'bobby pants' })
|
17
|
-
Profane.config[:dictionary][:geega].
|
17
|
+
expect(Profane.config[:dictionary][:geega]).to eql 'bobby pants'
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
metadata
CHANGED
@@ -1,78 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: profane
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.4
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Jonan Scheffler
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2016-12-15 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: bundler
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- - ~>
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '1.3'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- - ~>
|
24
|
+
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '1.3'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rake
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: rspec
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - ">="
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: yaml
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
|
-
requirements:
|
67
|
-
- - ! '>='
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: '0'
|
70
|
-
type: :development
|
71
|
-
prerelease: false
|
72
|
-
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
|
-
requirements:
|
75
|
-
- - ! '>='
|
52
|
+
- - ">="
|
76
53
|
- !ruby/object:Gem::Version
|
77
54
|
version: '0'
|
78
55
|
description: A simple, flexible profanity filter.
|
@@ -82,8 +59,8 @@ executables: []
|
|
82
59
|
extensions: []
|
83
60
|
extra_rdoc_files: []
|
84
61
|
files:
|
85
|
-
- .gitignore
|
86
|
-
- .rvmrc
|
62
|
+
- ".gitignore"
|
63
|
+
- ".rvmrc"
|
87
64
|
- Gemfile
|
88
65
|
- LICENSE.txt
|
89
66
|
- README.md
|
@@ -99,27 +76,26 @@ files:
|
|
99
76
|
homepage: http://github.com/1337807/profane
|
100
77
|
licenses:
|
101
78
|
- MIT
|
79
|
+
metadata: {}
|
102
80
|
post_install_message:
|
103
81
|
rdoc_options: []
|
104
82
|
require_paths:
|
105
83
|
- lib
|
106
84
|
required_ruby_version: !ruby/object:Gem::Requirement
|
107
|
-
none: false
|
108
85
|
requirements:
|
109
|
-
- -
|
86
|
+
- - ">="
|
110
87
|
- !ruby/object:Gem::Version
|
111
88
|
version: '0'
|
112
89
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
90
|
requirements:
|
115
|
-
- -
|
91
|
+
- - ">="
|
116
92
|
- !ruby/object:Gem::Version
|
117
93
|
version: '0'
|
118
94
|
requirements: []
|
119
95
|
rubyforge_project:
|
120
|
-
rubygems_version:
|
96
|
+
rubygems_version: 2.5.1
|
121
97
|
signing_key:
|
122
|
-
specification_version:
|
98
|
+
specification_version: 4
|
123
99
|
summary: Profane is a basic profanity filter designed to filter and detect keywords
|
124
100
|
based on an internal or external dictionary, or a combination of both.
|
125
101
|
test_files:
|