unswear 4.0 → 4.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +2 -2
- data/README.md +21 -14
- data/Rakefile +10 -1
- data/lib/unswear.rb +2 -65
- data/lib/unswear/string.rb +36 -0
- data/lib/unswear/unswear.rb +16 -0
- data/lib/unswear/version.rb +1 -1
- data/test/test_unswear.rb +25 -0
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba967e55ba598ecbf215f5b01220a9cd250ba5c2
|
4
|
+
data.tar.gz: f02edcd1a775370117ac87ba5691a4e731ce6911
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d22bfeb58e154a89e8afebfa13e88188d73b314893d3cdbe9d2ab30111b6bbb179906e2b89c7fec6d01fa782c5cf9e8cbe6e82ee03c0248de9f0f19ff3d314f8
|
7
|
+
data.tar.gz: 7c06f5cf5a96abf76d5dfd7b5768fa903d7b2acffac61fbd7bf953d69b493849a0a64d01512bb3a4dbef227d325f25c0e82b34e6d490d944eadd6fc81a187d76
|
data/LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (c)
|
3
|
+
Copyright (c) 2015 Josh Trommel
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
SOFTWARE.
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
@@ -8,17 +8,21 @@ Censor swear words in a string
|
|
8
8
|
## Install
|
9
9
|
You can install unswear via [RubyGems](https://rubygems.org/gems/unswear)
|
10
10
|
|
11
|
-
|
11
|
+
```bash
|
12
|
+
$ gem install unswear
|
13
|
+
```
|
12
14
|
|
13
|
-
Or stick it in your Gemfile
|
15
|
+
Or stick it in your Gemfile (and smoke it)
|
14
16
|
|
15
|
-
|
17
|
+
```ruby
|
18
|
+
gem 'unswear'
|
19
|
+
```
|
16
20
|
|
17
21
|
## Usage
|
18
22
|
|
19
23
|
Censor a string
|
20
24
|
```ruby
|
21
|
-
require 'unswear'
|
25
|
+
require 'unswear' # Grab all of Unswear's methods
|
22
26
|
|
23
27
|
"bitch ass nigga".censor # => b*tch *ss n*gg*
|
24
28
|
```
|
@@ -28,26 +32,29 @@ require 'unswear'
|
|
28
32
|
```ruby
|
29
33
|
"oh shit".swear? # => true
|
30
34
|
"sandwhich".swear? # => false
|
35
|
+
"fuckface".curse? # => true
|
31
36
|
```
|
32
37
|
|
33
38
|
You can also list the swears that will be censored
|
34
39
|
|
35
40
|
```ruby
|
36
|
-
Unswear.list # => arse, arsehole, ass, ass-fucker, ass-hat ...
|
37
|
-
```
|
38
|
-
|
39
|
-
.. or list swears that start with a certain letter
|
40
|
-
|
41
|
-
```ruby
|
42
|
-
Unswear.list('c') # => cunt, chink, cock, camel-toe, choad ...
|
41
|
+
Unswear.list # => ["arse", "arsehole", "ass", "ass-fucker", "ass-hat" ...
|
43
42
|
```
|
44
43
|
|
45
44
|
And if you'd like to check the version, there's a method for that as well
|
46
45
|
|
47
46
|
```ruby
|
48
|
-
Unswear.version
|
47
|
+
Unswear.version # => "4.0.1"
|
49
48
|
```
|
50
49
|
|
51
50
|
## To Do
|
52
|
-
- Create dangerous version of `censor` method
|
53
|
-
- Fix all of the damn global variables
|
51
|
+
- [ ] Create dangerous version of `censor` method
|
52
|
+
- [x] Fix all of the damn global variables
|
53
|
+
|
54
|
+
## License
|
55
|
+
Information over at [LICENSE](LICENSE).
|
56
|
+
|
57
|
+
## Disclaimer
|
58
|
+
Hopefully nobody's offended by any of the words here. I didn't mean any of it and I love you if you're reading this.
|
59
|
+
I'm just making this because it's
|
60
|
+
fun and interesting.
|
data/Rakefile
CHANGED
data/lib/unswear.rb
CHANGED
@@ -1,67 +1,4 @@
|
|
1
1
|
# Require some files
|
2
|
-
require_relative 'unswear/version'
|
3
2
|
require_relative 'unswear/curses'
|
4
|
-
|
5
|
-
|
6
|
-
class String
|
7
|
-
|
8
|
-
# Method to censor swears in string
|
9
|
-
def censor
|
10
|
-
new = self
|
11
|
-
new = new.split " "
|
12
|
-
# do some magic
|
13
|
-
new.count.times do |i|
|
14
|
-
Words::LIST.count.times do |c|
|
15
|
-
if new[i].downcase == Words::LIST[c]
|
16
|
-
new[i].gsub! "a", "*"
|
17
|
-
new[i].gsub! "e", "*"
|
18
|
-
new[i].gsub! "i", "*"
|
19
|
-
new[i].gsub! "o", "*"
|
20
|
-
new[i].gsub! "u", "*"
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
new = new.join(",")
|
25
|
-
new.gsub! ",", " "
|
26
|
-
#finally return new
|
27
|
-
puts new
|
28
|
-
end
|
29
|
-
|
30
|
-
# Method to check if string contains swear
|
31
|
-
def swear?
|
32
|
-
new = self
|
33
|
-
$swear = false
|
34
|
-
Words::LIST.each do |c|
|
35
|
-
if new.downcase.include?(c)
|
36
|
-
$swear = true
|
37
|
-
end
|
38
|
-
end
|
39
|
-
return $swear
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
43
|
-
|
44
|
-
# Define Unswear class
|
45
|
-
class Unswear
|
46
|
-
|
47
|
-
# Method to list all swear words
|
48
|
-
# If parameter (letter) is supplied,
|
49
|
-
# list all words that begin with that letter
|
50
|
-
def self.list(x=0)
|
51
|
-
unless x != 0
|
52
|
-
print "#{Words::LIST.sort_by(&:downcase).uniq}, "
|
53
|
-
else
|
54
|
-
Words::LIST.count.times do |m|
|
55
|
-
if Words::LIST[m][0] == x
|
56
|
-
print "#{Words::LIST[m]}, "
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
# Method to display Unswear's version
|
63
|
-
def self.version
|
64
|
-
puts "unswear v#{VERSION}"
|
65
|
-
end
|
66
|
-
|
67
|
-
end
|
3
|
+
require_relative 'unswear/string'
|
4
|
+
require_relative 'unswear/unswear'
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# Add some methods to the String class
|
2
|
+
class String
|
3
|
+
|
4
|
+
# Censor swears in string
|
5
|
+
def censor
|
6
|
+
input = self.split
|
7
|
+
|
8
|
+
# Thank you friends on SO
|
9
|
+
input.count.times do |i|
|
10
|
+
Words::LIST.count.times do |c|
|
11
|
+
if input[i].downcase == Words::LIST[c]
|
12
|
+
input[i] = input[i].tr("aeiou", "*")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# Join the string together and remove commas
|
18
|
+
input = input.join(",").gsub! ",", " "
|
19
|
+
|
20
|
+
# Return input with censored words
|
21
|
+
return input
|
22
|
+
end
|
23
|
+
|
24
|
+
# Method to check if string contains swear
|
25
|
+
def swear?
|
26
|
+
isSwear = false
|
27
|
+
Words::LIST.each do |word|
|
28
|
+
isSwear = true if self.downcase.include? word
|
29
|
+
end
|
30
|
+
# Return if string contains swear or not
|
31
|
+
return isSwear
|
32
|
+
end
|
33
|
+
|
34
|
+
alias :curse? :swear?
|
35
|
+
|
36
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require_relative 'version'
|
2
|
+
|
3
|
+
# Define Unswear class
|
4
|
+
class Unswear
|
5
|
+
|
6
|
+
# List all swear words
|
7
|
+
def self.list
|
8
|
+
Words::LIST.sort_by(&:downcase).uniq
|
9
|
+
end
|
10
|
+
|
11
|
+
# Return Unswear's version
|
12
|
+
def self.version
|
13
|
+
return Version::VERSION
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
data/lib/unswear/version.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require_relative '../lib/unswear'
|
3
|
+
|
4
|
+
class UnswearTest < Minitest::Test
|
5
|
+
def test_censor
|
6
|
+
'oh shit'.censor
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_swear?
|
10
|
+
'fuck this'.swear?
|
11
|
+
end
|
12
|
+
|
13
|
+
# alias for #swear?
|
14
|
+
def test_curse?
|
15
|
+
'fuck that'.curse?
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_list
|
19
|
+
Unswear.list
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_version
|
23
|
+
Unswear.version
|
24
|
+
end
|
25
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unswear
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,7 +52,10 @@ files:
|
|
52
52
|
- Rakefile
|
53
53
|
- lib/unswear.rb
|
54
54
|
- lib/unswear/curses.rb
|
55
|
+
- lib/unswear/string.rb
|
56
|
+
- lib/unswear/unswear.rb
|
55
57
|
- lib/unswear/version.rb
|
58
|
+
- test/test_unswear.rb
|
56
59
|
- unswear.gemspec
|
57
60
|
homepage: https://github.com/trommel/unswear
|
58
61
|
licenses: []
|
@@ -77,4 +80,5 @@ rubygems_version: 2.4.5
|
|
77
80
|
signing_key:
|
78
81
|
specification_version: 4
|
79
82
|
summary: Censor swear words in a string
|
80
|
-
test_files:
|
83
|
+
test_files:
|
84
|
+
- test/test_unswear.rb
|