swear-jar 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.mkd +40 -0
- data/Rakefile +18 -0
- data/bin/swear-jar +17 -0
- data/data/translations.yml +84 -0
- data/lib/swear-jar.rb +26 -0
- data/spec/spec_helper.rb +15 -0
- data/spec/swear-jar_spec.rb +34 -0
- metadata +73 -0
data/README.mkd
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
= swear-jar
|
2
|
+
|
3
|
+
== DESCRIPTION:
|
4
|
+
|
5
|
+
Clean up dirty text.
|
6
|
+
|
7
|
+
== INSTALL:
|
8
|
+
|
9
|
+
sudo gem install swear-jar
|
10
|
+
|
11
|
+
== EXAMPLE:
|
12
|
+
|
13
|
+
require 'swear-jar'
|
14
|
+
t = SwearJar::Translator.new
|
15
|
+
t.cleanup("go **** yourself.") # => "go fluff yourself."
|
16
|
+
|
17
|
+
== LICENSE:
|
18
|
+
|
19
|
+
(The MIT License)
|
20
|
+
|
21
|
+
Copyright (c) 2011 Alex Genco
|
22
|
+
|
23
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
24
|
+
a copy of this software and associated documentation files (the
|
25
|
+
'Software'), to deal in the Software without restriction, including
|
26
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
27
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
28
|
+
permit persons to whom the Software is furnished to do so, subject to
|
29
|
+
the following conditions:
|
30
|
+
|
31
|
+
The above copyright notice and this permission notice shall be
|
32
|
+
included in all copies or substantial portions of the Software.
|
33
|
+
|
34
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
35
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
36
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
37
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
38
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
39
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
40
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'hoe'
|
5
|
+
|
6
|
+
# Hoe.plugin :compiler
|
7
|
+
# Hoe.plugin :gem_prelude_sucks
|
8
|
+
# Hoe.plugin :inline
|
9
|
+
# Hoe.plugin :racc
|
10
|
+
# Hoe.plugin :rubyforge
|
11
|
+
|
12
|
+
Hoe.spec 'swear_jar' do
|
13
|
+
developer('Alex Genco', 'alexgenco@gmail.com')
|
14
|
+
|
15
|
+
# self.rubyforge_name = 'swear_jarx' # if different than 'swear_jar'
|
16
|
+
end
|
17
|
+
|
18
|
+
# vim: syntax=ruby
|
data/bin/swear-jar
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require File.expand_path(File.join(File.dirname(__FILE__), %w[.. lib swear-jar.rb]))
|
4
|
+
include SwearJar
|
5
|
+
|
6
|
+
t = Translator.new
|
7
|
+
|
8
|
+
if ARGV.size > 0
|
9
|
+
phrase = ARGV.join(" ")
|
10
|
+
else
|
11
|
+
print "Enter a phrase: "
|
12
|
+
phrase = gets.chomp
|
13
|
+
end
|
14
|
+
|
15
|
+
t.cleanup(phrase)
|
16
|
+
|
17
|
+
puts phrase
|
@@ -0,0 +1,84 @@
|
|
1
|
+
--- # swear-regex: clean
|
2
|
+
'(fuck)+\b': # fuck
|
3
|
+
[truck, shuck, duck, pluck, brush, fudge, flood, fooey, fluff]
|
4
|
+
|
5
|
+
'(fuck)+(ing)+\b': # fucking
|
6
|
+
[trucking, plucking, fiddling, brushing, ducking, fudging, fluffing, futzing]
|
7
|
+
|
8
|
+
'(fuck)+(er+)+\b': # fucker
|
9
|
+
[trucker, plucker, brusher, fiddler, fudger, fluffer, futzer, ducker]
|
10
|
+
|
11
|
+
'(fuck)+(ed)+\b': # fucked
|
12
|
+
[trucked, plucked, brushed, fiddled, fudged, fluffed, futzed, ducked]
|
13
|
+
|
14
|
+
'\b(shit)+\b': # shit
|
15
|
+
[slit, spit, print, split, shin, pit, bit, click, stick]
|
16
|
+
|
17
|
+
'\b(shit)+(t+er)+\b': # shitter
|
18
|
+
[spitter, printer, splitter, sinner, pitter, clicker, sticker]
|
19
|
+
|
20
|
+
'\b(shit)+(t+ing)+\b': # shitting
|
21
|
+
[spitting, printing, splitting, shining, biting, clicking, sticking]
|
22
|
+
|
23
|
+
'\b(sh)+(itt+ed|at)+\b': # shitted
|
24
|
+
[slitted, printed, splitted, spat, bit, clicked, stuck]
|
25
|
+
|
26
|
+
'\b(crap)+\b': # crap
|
27
|
+
[crab, grab, blab, slab, trap, nap, tap, crud, crikey]
|
28
|
+
|
29
|
+
'\b(crap)+(p+y)+\b': # crappy
|
30
|
+
[crabby, grabby, blabby, sloppy, slappy, tappy, cruddy, crikey]
|
31
|
+
|
32
|
+
'\b(crap)+(p+ing)+\b': # crapping
|
33
|
+
[grabbing, blabbing, slapping, tapping, pooping]
|
34
|
+
|
35
|
+
'\b(damn)+\b': # damn
|
36
|
+
[darn, dang, dan, bam, plain, spam, lamb, man]
|
37
|
+
|
38
|
+
'\b(dam)+(m+it|n+it)+\b': # damnit
|
39
|
+
[darnit, dangit]
|
40
|
+
|
41
|
+
'\bhell+\b': # hell
|
42
|
+
[heck, hockey sticks, hey, william tell]
|
43
|
+
|
44
|
+
'\b(ass+)+': # ass
|
45
|
+
[butt, bottom, rear, bass, back, class, blast, wrist, mass, mast, past, hand]
|
46
|
+
|
47
|
+
'\b(ass+)+(es)+\b': # asses
|
48
|
+
[butts, bottoms, rears, basses, backs, classes, blasts, wrists, masses, masts, pasts, hands]
|
49
|
+
|
50
|
+
'\b(pussy)+\b': # pussy
|
51
|
+
[crusty, cat, busy]
|
52
|
+
|
53
|
+
'\b(puss+)+(ies|ys)+\b': # pussies
|
54
|
+
[crusties, cats, daisies, tushies]
|
55
|
+
|
56
|
+
'\b(dick)+\b': # dick (sorry, richard)
|
57
|
+
[trick, pick, stick, brick, click, blink]
|
58
|
+
|
59
|
+
'\b(dick)+(s)+\b': # dicks
|
60
|
+
[tricks, picks, sticks, bricks, clicks, blinks]
|
61
|
+
|
62
|
+
'\b(bitch)+\b': # bitch
|
63
|
+
[snitch, pitch, witch, stitch, quidditch, mitch, rich]
|
64
|
+
|
65
|
+
'\b(bitch)+(es+)+\b': # bitches
|
66
|
+
[snitches, pitches, witches, stitches, mitches, riches]
|
67
|
+
|
68
|
+
'\b(bitch)+i(ed)+\b': # bitched
|
69
|
+
[snitched, pitched, stitched]
|
70
|
+
|
71
|
+
'\b(bitch)+(ing*)+\b': # bitching
|
72
|
+
[pitching, snitching, twitching, complaining, bleaching]
|
73
|
+
|
74
|
+
'\b(cock)+\b': # cock
|
75
|
+
[clock, block, stock, lock, wok, dock, sock]
|
76
|
+
|
77
|
+
'\b(cock)+s+\b': # cocks
|
78
|
+
[clocks, blocks, stocks, locks, woks, docks, socks]
|
79
|
+
|
80
|
+
'\b([kc]unt)+\b': #cunt
|
81
|
+
[punt, stunt, bunt, mutt, club, crazy girl, young]
|
82
|
+
|
83
|
+
'\b([kc]unt)+s+\b': #cunt
|
84
|
+
[punts, stunts, bunts, mutts, clubs, crazy girls, youngs]
|
data/lib/swear-jar.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module SwearJar
|
4
|
+
VERSION = '1.0.0'
|
5
|
+
|
6
|
+
class Translator
|
7
|
+
attr_reader :translations
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
translations_file = File.join(File.dirname(__FILE__), %w[.. data translations.yml])
|
11
|
+
@translations = YAML.load(IO.read(translations_file))
|
12
|
+
end
|
13
|
+
|
14
|
+
def cleanup(string)
|
15
|
+
@translations.keys.each do |swear|
|
16
|
+
regex = Regexp.compile(swear, true)
|
17
|
+
if regex =~ string
|
18
|
+
r = rand(translations[swear].size)
|
19
|
+
string.gsub!(regex, translations[swear][r])
|
20
|
+
end
|
21
|
+
end
|
22
|
+
return string
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
|
2
|
+
require File.expand_path(
|
3
|
+
File.join(File.dirname(__FILE__), %w[.. lib swear_jar]))
|
4
|
+
|
5
|
+
RSpec.configure do |config|
|
6
|
+
# == Mock Framework
|
7
|
+
#
|
8
|
+
# RSpec uses it's own mocking framework by default. If you prefer to
|
9
|
+
# use mocha, flexmock or RR, uncomment the appropriate line:
|
10
|
+
#
|
11
|
+
# config.mock_with :mocha
|
12
|
+
# config.mock_with :flexmock
|
13
|
+
# config.mock_with :rr
|
14
|
+
end
|
15
|
+
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), %w[spec_helper])
|
2
|
+
|
3
|
+
include SwearJar
|
4
|
+
|
5
|
+
describe Translator do
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
@t = Translator.new
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should be instantiated with no arguments" do
|
12
|
+
lambda {Translator.new()}.should_not raise_error
|
13
|
+
lambda {Translator.new("argument")}.should raise_error(ArgumentError)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should take a string as an argument to cleanup method and return a string" do
|
17
|
+
@t.cleanup("somebody").should be_instance_of(String)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should read the yaml dictionary upon instantiation" do
|
21
|
+
@t.translations.should be_instance_of(Hash)
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "cleanup" do
|
25
|
+
it "should clean up bad words" do
|
26
|
+
@t.cleanup("crap").should_not == "crap"
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should not clean up otherwise" do
|
30
|
+
@t.cleanup("dog").should == "dog"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
metadata
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: swear-jar
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 25
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Alex Genco
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-02-04 00:00:00 -08:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: SwearJar can clean up dirty text. Further functionality may come later.
|
23
|
+
email: alexgenco@gmail.com
|
24
|
+
executables: []
|
25
|
+
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files: []
|
29
|
+
|
30
|
+
files:
|
31
|
+
- README.mkd
|
32
|
+
- Rakefile
|
33
|
+
- bin/swear-jar
|
34
|
+
- data/translations.yml
|
35
|
+
- lib/swear-jar.rb
|
36
|
+
- spec/swear-jar_spec.rb
|
37
|
+
- spec/spec_helper.rb
|
38
|
+
has_rdoc: true
|
39
|
+
homepage:
|
40
|
+
licenses: []
|
41
|
+
|
42
|
+
post_install_message:
|
43
|
+
rdoc_options: []
|
44
|
+
|
45
|
+
require_paths:
|
46
|
+
- lib
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
none: false
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
hash: 3
|
53
|
+
segments:
|
54
|
+
- 0
|
55
|
+
version: "0"
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 3
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
version: "0"
|
65
|
+
requirements: []
|
66
|
+
|
67
|
+
rubyforge_project:
|
68
|
+
rubygems_version: 1.6.2
|
69
|
+
signing_key:
|
70
|
+
specification_version: 3
|
71
|
+
summary: SwearJar can clean up dirty text. Further functionality may come later.
|
72
|
+
test_files: []
|
73
|
+
|