profanity 0.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 +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +4 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +20 -0
- data/config/obscenity.yml +1190 -0
- data/lib/profanity.rb +11 -0
- data/lib/profanity/base.rb +21 -0
- data/lib/profanity/config.rb +6 -0
- data/lib/profanity/version.rb +3 -0
- data/profanity.gemspec +31 -0
- data/test/profanity_test.rb +28 -0
- data/test/test_helper.rb +4 -0
- metadata +103 -0
data/lib/profanity.rb
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Profanity
|
|
2
|
+
class Base
|
|
3
|
+
class << self
|
|
4
|
+
|
|
5
|
+
def blacklist
|
|
6
|
+
@blacklist = Profanity::Config::BLACKLIST
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def profane?(text)
|
|
10
|
+
profane = false
|
|
11
|
+
blacklist.each do |word|
|
|
12
|
+
if text.include? word
|
|
13
|
+
profane = true; break
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
profane
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
data/profanity.gemspec
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'profanity/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "profanity"
|
|
8
|
+
spec.version = Profanity::VERSION
|
|
9
|
+
spec.authors = ["Marcin Świątkiewicz"]
|
|
10
|
+
spec.email = ["m.swiatkiewicz91@gmail.com"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{This gem detect profanity words in text}
|
|
13
|
+
spec.description = %q{This gem provide you to check if in text is any profanity words, text can be without white characters and this stil will be work}
|
|
14
|
+
spec.homepage = "http://github.com/swiatkiewicz/profanity"
|
|
15
|
+
spec.license = "MIT"
|
|
16
|
+
spec.test_files = ["test/test_helper.rb", "test/profanity_test.rb"]
|
|
17
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
|
18
|
+
# delete this section to allow pushing this gem to any host.
|
|
19
|
+
# if spec.respond_to?(:metadata)
|
|
20
|
+
# spec.metadata['allowed_push_host'] = "'http://rubygems.com'"
|
|
21
|
+
# else
|
|
22
|
+
# raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
|
23
|
+
# end
|
|
24
|
+
|
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
26
|
+
spec.require_paths = ["lib"]
|
|
27
|
+
|
|
28
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
|
29
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
30
|
+
spec.add_development_dependency "minitest"
|
|
31
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class ProfanityTest < Minitest::Test
|
|
4
|
+
|
|
5
|
+
def test_check_single_word
|
|
6
|
+
response = Profanity.check('ass')
|
|
7
|
+
assert_equal true, response
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def test_check_words_in_one_string
|
|
11
|
+
response = Profanity.check('profanityass')
|
|
12
|
+
assert_equal true, response
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def test_check_no_profanity_words
|
|
16
|
+
response = Profanity.check('Only beutiful words')
|
|
17
|
+
assert_equal false, response
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def test_check_profanity_text
|
|
21
|
+
response = Profanity.check('There is one ass profanity word')
|
|
22
|
+
assert_equal true, response
|
|
23
|
+
response = Profanity.check('There-is-one-ass-profanity-word')
|
|
24
|
+
assert_equal true, response
|
|
25
|
+
response = Profanity.check('There$is$on$assass$profanity$word')
|
|
26
|
+
assert_equal true, response
|
|
27
|
+
end
|
|
28
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: profanity
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Marcin Świątkiewicz
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2015-06-12 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.10'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.10'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: minitest
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
description: This gem provide you to check if in text is any profanity words, text
|
|
56
|
+
can be without white characters and this stil will be work
|
|
57
|
+
email:
|
|
58
|
+
- m.swiatkiewicz91@gmail.com
|
|
59
|
+
executables: []
|
|
60
|
+
extensions: []
|
|
61
|
+
extra_rdoc_files: []
|
|
62
|
+
files:
|
|
63
|
+
- ".gitignore"
|
|
64
|
+
- ".travis.yml"
|
|
65
|
+
- Gemfile
|
|
66
|
+
- LICENSE.txt
|
|
67
|
+
- README.md
|
|
68
|
+
- Rakefile
|
|
69
|
+
- config/obscenity.yml
|
|
70
|
+
- lib/profanity.rb
|
|
71
|
+
- lib/profanity/base.rb
|
|
72
|
+
- lib/profanity/config.rb
|
|
73
|
+
- lib/profanity/version.rb
|
|
74
|
+
- profanity.gemspec
|
|
75
|
+
- test/profanity_test.rb
|
|
76
|
+
- test/test_helper.rb
|
|
77
|
+
homepage: http://github.com/swiatkiewicz/profanity
|
|
78
|
+
licenses:
|
|
79
|
+
- MIT
|
|
80
|
+
metadata: {}
|
|
81
|
+
post_install_message:
|
|
82
|
+
rdoc_options: []
|
|
83
|
+
require_paths:
|
|
84
|
+
- lib
|
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - ">="
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0'
|
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
|
+
requirements:
|
|
92
|
+
- - ">="
|
|
93
|
+
- !ruby/object:Gem::Version
|
|
94
|
+
version: '0'
|
|
95
|
+
requirements: []
|
|
96
|
+
rubyforge_project:
|
|
97
|
+
rubygems_version: 2.4.7
|
|
98
|
+
signing_key:
|
|
99
|
+
specification_version: 4
|
|
100
|
+
summary: This gem detect profanity words in text
|
|
101
|
+
test_files:
|
|
102
|
+
- test/test_helper.rb
|
|
103
|
+
- test/profanity_test.rb
|