bad_words 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.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "rake/testtask"
2
+
3
+ Rake::TestTask.new do |t|
4
+ t.libs << "lib"
5
+ t.test_files = Dir["test/**/*_test.rb"]
6
+ end
data/bad_words.gemspec ADDED
@@ -0,0 +1,10 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "bad_words"
3
+ s.version = "0.1.0"
4
+ s.description = "A simple gem to clean string of bad words!"
5
+ s.summary = "Bad Words"
6
+ s.author = "Alessandro Neri"
7
+ s.email = "alessandro.neri@gmail.com"
8
+ s.homepage = "http://www.abril.com.br"
9
+ s.files = Dir["{lib/**/*.rb,README.rdoc,test/**/*.rb,Rakefile,*.gemspec}"]
10
+ end
data/lib/bad_words.rb ADDED
@@ -0,0 +1,32 @@
1
+ module BadWords
2
+
3
+ #Str: String a ser limpa
4
+ #Nivel 1: retira palavras de baixo calão.
5
+ #Nivel 2 : Retira palavras bloqueadas {exemplo nome de concorrente, nome dos nosso jornalistas}
6
+ #Nivel 3: Retira os dois modelos acima
7
+ def self.make_clean(str, nivel)
8
+ words = ""
9
+ if nivel == 1 or nivel == 3
10
+ words << generate_bad_words
11
+ end
12
+ if nivel == 2 or nivel == 3
13
+ words << generate_block_words
14
+ end
15
+ clean_string(str, words.split(' '))
16
+ end
17
+
18
+ def self.clean_string(str, bad_words)
19
+ str_broken = str.downcase.split(' ')
20
+ bad_words.any? { |bw| str_broken.include?(bw) }
21
+ (str_broken - bad_words).join(' ')
22
+ end
23
+
24
+ def self.generate_bad_words
25
+ "foo bar baz"
26
+ end
27
+
28
+ def self.generate_block_words
29
+ "uol globo ig"
30
+ end
31
+
32
+ end
@@ -0,0 +1,8 @@
1
+ require "test/unit"
2
+ require "bad_words"
3
+
4
+ class BadWordsTest < Test::Unit::TestCase
5
+ def test_make_clean
6
+ assert_equal "good", BadWords.make_clean("foo good iG", 3)
7
+ end
8
+ end
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bad_words
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Alessandro Neri
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-05-04 00:00:00 -03:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: A simple gem to clean string of bad words!
23
+ email: alessandro.neri@gmail.com
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files: []
29
+
30
+ files:
31
+ - lib/bad_words.rb
32
+ - test/bad_words_test.rb
33
+ - Rakefile
34
+ - bad_words.gemspec
35
+ has_rdoc: true
36
+ homepage: http://www.abril.com.br
37
+ licenses: []
38
+
39
+ post_install_message:
40
+ rdoc_options: []
41
+
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ hash: 3
50
+ segments:
51
+ - 0
52
+ version: "0"
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ hash: 3
59
+ segments:
60
+ - 0
61
+ version: "0"
62
+ requirements: []
63
+
64
+ rubyforge_project:
65
+ rubygems_version: 1.4.2
66
+ signing_key:
67
+ specification_version: 3
68
+ summary: Bad Words
69
+ test_files: []
70
+