cleanliness 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cleanliness.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Ty Rauber
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,41 @@
1
+ # Cleanliness
2
+
3
+ I love cursing as much as the next @sshole, but as an application developer sometimes you need to keep the conversation clean. Bad words, hate speech, general nastiness can have negative consequences. Whether it be usernames or comments, sometimes it helps to limit the offensiveness of the general population. Preventing the more sensitive portion of your user base from being inadvertently offended.
4
+
5
+ The *cleanliness* gem provides two functions:
6
+
7
+ #### "String".clean
8
+
9
+ "string".clean will clean an ugly string, by replace ugly words with a more tame, and oftentimes humorous counterpart.
10
+
11
+ #### cleanliness validation
12
+
13
+ To automatically clean a field in your rails application, you can use the clean validator:
14
+
15
+ validates :username, presence: true, cleanliness: true
16
+
17
+ ## Installation
18
+
19
+ Add this line to your application's Gemfile:
20
+
21
+ gem 'cleanliness'
22
+
23
+ And then execute:
24
+
25
+ $ bundle
26
+
27
+ Or install it yourself as:
28
+
29
+ $ gem install cleanliness
30
+
31
+ ## Usage
32
+
33
+ TODO: Write usage instructions here
34
+
35
+ ## Contributing
36
+
37
+ 1. Fork it
38
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
39
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
40
+ 4. Push to the branch (`git push origin my-new-feature`)
41
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,18 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'cleanliness/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "cleanliness"
8
+ gem.version = Cleanliness::VERSION
9
+ gem.authors = ["Ty Rauber"]
10
+ gem.email = ["tyrauber@mac.com"]
11
+ gem.description = %q{Clean Language Validation}
12
+ gem.summary = %q{The Cleanliness gem is an easy way to limit offensiveness in your application by replacing bad language, hate speech and other improperness with a more tame counterpart.}
13
+ gem.homepage = "https://github.com/tyrauber/cleanliness"
14
+ gem.files = `git ls-files`.split($/)
15
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
16
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
17
+ gem.require_paths = ["lib"]
18
+ end
@@ -0,0 +1,4 @@
1
+ require 'rubygems'
2
+ require 'cleanliness/version'
3
+ require 'cleanliness/cleanliness'
4
+ require 'cleanliness/dictionary'
@@ -0,0 +1,28 @@
1
+ require "active_record"
2
+
3
+ module Cleanliness
4
+ module ValidatesCleanliness
5
+ module Validator
6
+ class CleanlinessValidator < ActiveModel::EachValidator
7
+ def validate_each(record, attribute, value)
8
+ record[attribute] = value.clean if !!(value)
9
+ end
10
+ end
11
+ end
12
+
13
+ module ClassMethods
14
+ def validates_cleanliness_of(*attr_names)
15
+ validates_with ActiveRecord::Base::ExistenceValidator, _merge_attributes(attr_names)
16
+ end
17
+ end
18
+ end
19
+ end
20
+
21
+ ActiveRecord::Base.send(:include, Cleanliness::ValidatesCleanliness::Validator)
22
+ ActiveRecord::Base.send(:extend, Cleanliness::ValidatesCleanliness::ClassMethods)
23
+
24
+ String.class_eval do
25
+ def clean
26
+ Cleanliness::Dictionary.translate(self)
27
+ end
28
+ end
@@ -0,0 +1,21 @@
1
+ module Cleanliness
2
+ class Dictionary
3
+
4
+ def self.initialize
5
+ @dictionary ||= YAML.load_file(File.join(File.dirname(__FILE__), '', 'dictionary.yml'))
6
+ return @dictionary
7
+ end
8
+
9
+ def self.translate(string)
10
+ @dictionary = initialize
11
+ replace ={}
12
+ rgx = Regexp.new "#{@dictionary.keys.map{|k| "(#{k})"}.join("|")}", Regexp::IGNORECASE
13
+ scan_matches = string.scan(rgx).flatten.reject!(&:blank?)
14
+ scan_matches.each{|k|
15
+ replace[k] = (k =~ /^[A-Z]{1}/).nil? ? @dictionary[k.downcase] : @dictionary[k.downcase].capitalize
16
+ }
17
+ match = Regexp.new scan_matches.map{|k| "(#{k})"}.join("|")
18
+ return string.gsub(match, replace)
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,365 @@
1
+ ---
2
+ anus: 'butt'
3
+ arse: 'butt'
4
+ arsehole: 'butt'
5
+ ass: 'butt'
6
+ ass-hat: 'idiot'
7
+ ass-jabber: 'homosexual'
8
+ ass-pirate: 'homosexual'
9
+ assbag: 'idiot'
10
+ assbandit: 'homosexual'
11
+ assbanger: 'homosexual'
12
+ assbite: 'idiot'
13
+ assclown: 'butt'
14
+ asscock: 'idiot'
15
+ asscracker: 'butt'
16
+ asses: 'butts'
17
+ assface: 'butt'
18
+ assfuck: 'rear-loving'
19
+ assfucker: 'homosexual'
20
+ assgoblin: 'homosexual'
21
+ asshat: 'butt'
22
+ asshead: 'idiot'
23
+ asshole: 'jerk'
24
+ asshopper: 'homosexual'
25
+ assjacker: 'homosexual'
26
+ asslick: 'idiot'
27
+ asslicker: 'Buttlicker'
28
+ assmonkey: 'idiot'
29
+ assmunch: 'idiot'
30
+ assmuncher: 'butt'
31
+ assnigger: 'Racial Slur'
32
+ asspirate: 'homosexual'
33
+ assshit: 'idiot'
34
+ assshole: 'butt'
35
+ asssucker: 'idiot'
36
+ asswad: 'butt'
37
+ asswipe: 'butt'
38
+ axwound: 'female genitalia'
39
+ bampot: 'idiot'
40
+ bastard: 'illegitimate child'
41
+ beaner: 'Mexican'
42
+ bitch: 'female dog'
43
+ bitchass: 'idiot'
44
+ bitches: 'female dogs'
45
+ bitchtits: 'homosexual'
46
+ bitchy: 'mean'
47
+ blow job: 'sexual act'
48
+ blowjob: 'sexual act'
49
+ bollocks: 'male genitalia'
50
+ bollox: 'male genitalia'
51
+ boner: 'erection'
52
+ brotherfucker: 'homosexual'
53
+ bullshit: 'poop'
54
+ bumblefuck: 'homosexual'
55
+ butt plug: 'cork'
56
+ butt-pirate: 'homosexual'
57
+ buttfucka: 'homosexual'
58
+ buttfucker: 'homosexual'
59
+ camel toe: 'female genitalia'
60
+ carpetmuncher: 'homosexual'
61
+ chesticle: 'Breast'
62
+ chinc: 'Chinese'
63
+ chink: 'asian'
64
+ choad: 'male genitalia'
65
+ chode: 'small penis'
66
+ clit: 'female genitals'
67
+ clitface: 'idiot'
68
+ clitfuck: 'sexual act'
69
+ clusterfuck: 'mess up'
70
+ cock: 'penis'
71
+ cockass: 'Jerk'
72
+ cockbite: 'idiot'
73
+ cockburger: 'idiot'
74
+ cockface: 'idiot'
75
+ cockfucker: 'idiot'
76
+ cockhead: 'idiot'
77
+ cockjockey: 'homosexual'
78
+ cockknoker: 'homosexual'
79
+ cockmaster: 'homosexual'
80
+ cockmongler: 'homosexual'
81
+ cockmongruel: 'homosexual'
82
+ cockmonkey: 'idiot'
83
+ cockmuncher: 'homosexual'
84
+ cocknose: 'idiot'
85
+ cocknugget: 'idiot'
86
+ cockshit: 'idiot'
87
+ cocksmith: 'homosexual'
88
+ cocksmoke: 'homosexual'
89
+ cocksmoker: 'homosexual'
90
+ cocksniffer: 'homosexual'
91
+ cocksucker: 'homosexual'
92
+ cockwaffle: 'idiot'
93
+ coochie: 'female genitalia'
94
+ coochy: 'female genitalia'
95
+ coon: 'African American'
96
+ cooter: 'vagina'
97
+ cracker: 'Caucasian'
98
+ cum: 'semen'
99
+ cumbubble: 'idiot'
100
+ cumdumpster: 'prostitute'
101
+ cumguzzler: 'homosexual'
102
+ cumjockey: 'homosexual'
103
+ cumslut: 'dirty girl'
104
+ cumtart: 'idiot'
105
+ cunnie: 'female genitalia'
106
+ cunnilingus: 'sexual act'
107
+ cunt: 'vagina'
108
+ cuntass: 'idiot'
109
+ cuntface: 'idiot'
110
+ cunthole: 'female genitalia'
111
+ cuntlicker: 'homosexual'
112
+ cuntrag: 'idiot'
113
+ cuntslut: 'idiot'
114
+ dago: 'Italian'
115
+ damn: 'darn'
116
+ deggo: 'Italian'
117
+ dick: 'penis'
118
+ dick-sneeze: 'orgasm'
119
+ dickbag: 'idiot'
120
+ dickbeaters: 'Hands'
121
+ dickface: 'idiot'
122
+ dickfuck: 'idiot'
123
+ dickfucker: 'homosexual'
124
+ dickhead: 'phallace face'
125
+ dickhole: 'male genitalia'
126
+ dickjuice: 'semen'
127
+ dickmilk: 'sperm'
128
+ dickmonger: 'homosexual'
129
+ dicks: 'penises'
130
+ dickslap: 'sexual act'
131
+ dicksucker: 'homosexual'
132
+ dicksucking: 'sexual act'
133
+ dicktickler: 'homosexual'
134
+ dickwad: 'idiot'
135
+ dickweasel: 'idiot'
136
+ dickweed: 'idiot'
137
+ dickwod: 'idiot'
138
+ dike: 'homosexual'
139
+ dildo: 'sexual toy'
140
+ dipshit: 'idiot'
141
+ doochbag: 'idiot'
142
+ dookie: 'poop'
143
+ douche: 'female hygene product'
144
+ douche-fag: 'idiot'
145
+ douchebag: 'female hygene accessory'
146
+ douchewaffle: 'homosexual'
147
+ dumass: 'idiot'
148
+ dumb ass: 'idiot'
149
+ dumbass: 'idiot'
150
+ dumbfuck: 'idiot'
151
+ dumbshit: 'idiot'
152
+ dumshit: 'idiot'
153
+ dyke: 'homosexual'
154
+ fag: 'homosexual'
155
+ fagbag: 'homosexual'
156
+ fagfucker: 'homosexual'
157
+ faggit: 'homosexual'
158
+ faggot: 'homosexual'
159
+ faggotcock: 'homosexual'
160
+ fagtard: 'homosexual idiot'
161
+ fatass: 'a fat person'
162
+ fellatio: 'sexual act'
163
+ feltch: 'sexual act'
164
+ flamer: 'homosexual'
165
+ fuck: 'fornicate'
166
+ fuckass: 'idiot'
167
+ fuckbag: 'idiot'
168
+ fuckboy: 'idiot'
169
+ fuckbrain: 'idiot'
170
+ fuckbutt: 'butt'
171
+ fuckbutter: 'Sexual fluids'
172
+ fucked: 'had intercourse'
173
+ fucker: 'fornicator'
174
+ fuckersucker: 'idiot'
175
+ fuckface: 'idiot'
176
+ fuckhead: 'butt'
177
+ fuckhole: 'jerk'
178
+ fuckin: 'sexual act'
179
+ fucking: 'freaking'
180
+ fucknut: 'idiot'
181
+ fucknutt: 'idiot'
182
+ fuckoff: 'go away'
183
+ fucks: 'sexual act'
184
+ fuckstick: 'male genitalia'
185
+ fucktard: 'Moron'
186
+ fucktart: 'idiot'
187
+ fuckup: 'idiot'
188
+ fuckwad: 'idiot'
189
+ fuckwit: 'dummy'
190
+ fuckwitt: 'idiot'
191
+ fudgepacker: 'homosexual'
192
+ gay: 'homosexual'
193
+ gayass: 'butt'
194
+ gaybob: 'homosexual'
195
+ gaydo: 'homosexual'
196
+ gayfuck: 'homosexual'
197
+ gayfuckist: 'homosexual'
198
+ gaylord: 'homosexual'
199
+ gaytard: 'homosexual'
200
+ gaywad: 'homosexual'
201
+ goddamn: 'goshdarn'
202
+ goddamnit: 'goshdarnit'
203
+ gooch: 'female genitalia'
204
+ gook: 'Chinese'
205
+ gringo: 'foreigner'
206
+ guido: 'italian'
207
+ gay: 'homosexual'
208
+ gayass: 'butt'
209
+ gaybob: 'homosexual'
210
+ gaydo: 'homosexual'
211
+ gayfuck: 'homosexual'
212
+ gayfuckist: 'homosexual'
213
+ gaylord: 'homosexual'
214
+ gaytard: 'homosexual'
215
+ gaywad: 'homosexual'
216
+ goddamn: 'goshdarn'
217
+ goddamnit: 'goshdarnit'
218
+ gooch: 'female genitalia'
219
+ gook: 'Chinese'
220
+ gringo: 'foreigner'
221
+ guido: 'italian'
222
+ handjob: 'sexual act'
223
+ hard on: 'erection'
224
+ heeb: 'Jewish Person'
225
+ hell: 'heck'
226
+ ho: 'woman'
227
+ hoe: 'Woman'
228
+ homo: 'homosexual'
229
+ homodumbshit: 'idiot'
230
+ honkey: 'white person'
231
+ humping: 'sexual act'
232
+ jackass: 'idiot'
233
+ jagoff: 'idiot'
234
+ jap: 'japanesse person'
235
+ jerk off: 'masturbate'
236
+ jerkass: 'idiot'
237
+ jigaboo: 'African American'
238
+ jizz: 'Semen'
239
+ jungle bunny: 'african american'
240
+ junglebunny: 'african american'
241
+ kike: 'Jewish Person'
242
+ kooch: 'female genitalia'
243
+ kootch: 'female genitalia'
244
+ kraut: 'german'
245
+ kunt: 'female genitalia'
246
+ kyke: 'Jewish person'
247
+ lameass: 'loser'
248
+ lardass: 'overweight individual'
249
+ lesbian: 'homosexual'
250
+ lesbo: 'homosexual'
251
+ lezzie: 'homosexual'
252
+ mcfagget: 'homosexual'
253
+ mick: 'irish'
254
+ minge: 'female genitalia'
255
+ mothafucka: 'Jerk'
256
+ mothafuckin\': 'mother loving'
257
+ motherfucker: 'mother lover'
258
+ motherfucking: 'fornicating with mother'
259
+ muff: 'female genitalia'
260
+ muffdiver: 'homosexual'
261
+ munging: 'sexual act'
262
+ negro: 'african american'
263
+ nigaboo: 'African American'
264
+ nigga: 'african american'
265
+ nigger: 'african american'
266
+ niggers: 'African Americans'
267
+ niglet: 'african american child'
268
+ nut sack: 'male genitalia'
269
+ nutsack: 'male genitalia'
270
+ paki: 'pakistanien'
271
+ panooch: 'femail genitalia'
272
+ pecker: 'Penis'
273
+ peckerhead: 'idiot'
274
+ penis: 'male genitalia'
275
+ penisbanger: 'homosexual'
276
+ penisfucker: 'homosexual'
277
+ penispuffer: 'homosexual'
278
+ piss: 'urinate'
279
+ pissed: 'urinated'
280
+ pissed off: 'angry'
281
+ pissflaps: 'female genitalia'
282
+ polesmoker: 'homosexual'
283
+ pollock: 'polish person'
284
+ poon: 'female genitals'
285
+ poonani: 'female genitalia'
286
+ poonany: 'vagina'
287
+ poontang: 'female genitalia'
288
+ porch monkey: 'african american'
289
+ porchmonkey: 'African American'
290
+ prick: 'penis'
291
+ punanny: 'female genitalia'
292
+ punta: 'female dog'
293
+ pussies: 'Female Genitalias'
294
+ pussy: 'female reproductive organ'
295
+ pussylicking: 'sexual act'
296
+ puto: 'idiot'
297
+ queef: 'vaginal fart.'
298
+ queer: 'homosexual'
299
+ queerbait: 'homosexual'
300
+ queerhole: 'homosexual'
301
+ renob: 'erection'
302
+ rimjob: 'dirty sexual act'
303
+ ruski: 'Russian'
304
+ sand nigger: 'middle eastern'
305
+ sandnigger: 'middle eastern'
306
+ schlong: 'male genitalia'
307
+ scrote: 'male genitalia'
308
+ shit: 'poop'
309
+ shitass: 'idiot'
310
+ shitbag: 'idiot'
311
+ shitbagger: 'idiot'
312
+ shitbrains: 'idiot'
313
+ shitbreath: 'Bad Breath'
314
+ shitcanned: 'Fired'
315
+ shitcunt: 'idiot'
316
+ shitdick: 'idiot'
317
+ shitface: 'pooface'
318
+ shitfaced: 'Drunk'
319
+ shithead: 'jerk'
320
+ shithole: 'idiot'
321
+ shithouse: 'bathroom'
322
+ shitspitter: 'butt'
323
+ shitstain: 'poop'
324
+ shitter: 'defecator'
325
+ shittiest: 'worst'
326
+ shitting: 'pooping'
327
+ shitty: 'bad'
328
+ shiz: 'poop'
329
+ shiznit: 'poop'
330
+ skank: 'dirty girl'
331
+ skeet: 'semen'
332
+ skullfuck: 'sexual act'
333
+ slut: 'sexually popular woman'
334
+ slutbag: 'sexually popular woman'
335
+ smeg: 'poop'
336
+ snatch: 'female genitalia'
337
+ spic: 'mexican'
338
+ spick: 'mexican american'
339
+ splooge: 'ejaculate'
340
+ spook: 'White person'
341
+ suckass: 'idiot'
342
+ tard: 'mentally challenged'
343
+ testicle: 'male genitalia'
344
+ thundercunt: 'idiot'
345
+ tit: 'breast'
346
+ titfuck: 'sexual act'
347
+ tits: 'breasts'
348
+ tittyfuck: 'sexual act'
349
+ twat: 'female genitals'
350
+ twatlips: 'idiot'
351
+ twats: 'vaginas'
352
+ twatwaffle: 'homosexual'
353
+ unclefucker: 'homosexual'
354
+ va-j-j: 'female genitalia'
355
+ vag: 'femail genitalia'
356
+ vagina: 'female genitalia'
357
+ vajayjay: 'female genitalia'
358
+ vjayjay: 'female genitalia'
359
+ wank: 'sexual act'
360
+ wankjob: 'sexual act'
361
+ wetback: 'Mexican'
362
+ whore: 'hussy'
363
+ whorebag: 'idiot'
364
+ whoreface: 'idiot'
365
+ wop: 'Italian'
@@ -0,0 +1,3 @@
1
+ module Cleanliness
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,57 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cleanliness
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Ty Rauber
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-06-16 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Clean Language Validation
15
+ email:
16
+ - tyrauber@mac.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - Gemfile
23
+ - LICENSE.txt
24
+ - README.md
25
+ - Rakefile
26
+ - cleanliness.gemspec
27
+ - lib/cleanliness.rb
28
+ - lib/cleanliness/cleanliness.rb
29
+ - lib/cleanliness/dictionary.rb
30
+ - lib/cleanliness/dictionary.yml
31
+ - lib/cleanliness/version.rb
32
+ homepage: https://github.com/tyrauber/cleanliness
33
+ licenses: []
34
+ post_install_message:
35
+ rdoc_options: []
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ required_rubygems_version: !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ! '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ requirements: []
51
+ rubyforge_project:
52
+ rubygems_version: 1.8.24
53
+ signing_key:
54
+ specification_version: 3
55
+ summary: The Cleanliness gem is an easy way to limit offensiveness in your application
56
+ by replacing bad language, hate speech and other improperness with a more tame counterpart.
57
+ test_files: []