profanalyzer 0.2.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  History.txt
2
2
  Manifest.txt
3
- README.txt
3
+ README.markdown
4
4
  Rakefile
5
5
  config/list.yml
6
6
  lib/profanalyzer.rb
@@ -1,8 +1,8 @@
1
- = profanalyzer
1
+ # profanalyzer
2
2
 
3
3
  * http://profanalyzer.rubyforge.org/
4
4
 
5
- == DESCRIPTION:
5
+ ## Description
6
6
 
7
7
  Profanalyzer has one purpose: analyze a block of text for profanity. It is able to filter profane words as well.
8
8
 
@@ -12,7 +12,7 @@ The Profanalyzer will default to a tolerance of of 2, which will kick back the a
12
12
 
13
13
  Lastly, it allows for custom substitutions! For example, the filter at the website http://www.fark.com/ turns the word "fuck" into "fark", and "shit" into "shiat". You can specify these if you want.
14
14
 
15
- == FEATURES/PROBLEMS:
15
+ ## FEATURES/PROBLEMS:
16
16
 
17
17
  * Tolerance-based filtering
18
18
  * Switch between checking all words, racist terms, sexual words, or some
@@ -20,7 +20,7 @@ Lastly, it allows for custom substitutions! For example, the filter at the websi
20
20
  * Custom substitutions
21
21
  * Boolean-based profanity checking (skipping the filtering)
22
22
 
23
- == SYNOPSIS:
23
+ ## SYNOPSIS:
24
24
 
25
25
  Out of the box, you can simply use Profanalyzer.filter and
26
26
  Profanalyzer.profane?:
@@ -54,15 +54,20 @@ Lastly, you can add custom substitutions:
54
54
  Profanalyzer.filter("fuck") #==> "fark"
55
55
 
56
56
 
57
- == REQUIREMENTS:
57
+ ## Requirements
58
58
 
59
59
  hoe - a gem for building gems, which I used for profanalyzer.
60
60
 
61
- == INSTALL:
61
+ ## Contributors
62
+
63
+ * Michael Edgar <adgar@carboni.ca>
64
+ * Thomas Hanley <tjhanley.com@gmail.com>
65
+
66
+ ## Installation
62
67
 
63
68
  sudo gem install profanalyzer
64
69
 
65
- == LICENSE:
70
+ ## License
66
71
 
67
72
  (The MIT License)
68
73
 
@@ -85,4 +90,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
85
90
  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
86
91
  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
87
92
  TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
88
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
93
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile CHANGED
@@ -5,10 +5,10 @@ require 'hoe'
5
5
  require './lib/profanalyzer.rb'
6
6
 
7
7
  Hoe.new('profanalyzer', Profanalyzer::VERSION) do |p|
8
- # p.rubyforge_name = 'profanalyzerx' # if different than lowercase project name
8
+ p.rubyforge_name = 'profanalyzer' # if different than lowercase project name
9
9
  p.developer('Michael J. Edgar', 'edgar@triqweb.com')
10
10
  p.remote_rdoc_dir = ''
11
-
11
+ p.summary = "Analyzes a block of text for profanity. It is able to filter profane words as well."
12
12
  desc 'Post your blog announcement to blogger.'
13
13
  task :post_blogger do
14
14
  require 'blogger'
@@ -19,12 +19,16 @@ Hoe.new('profanalyzer', Profanalyzer::VERSION) do |p|
19
19
  config['blogs'].each do |site|
20
20
  next unless site['url'] =~ /www\.blogger\.com/
21
21
  acc = Blogger::Account.new(site['user'],site['password'])
22
- post = Blogger::Post.new(:title => title, :content => body, :categories => p.blog_categories)
22
+ post = Blogger::Post.new(:title => title, :content => body, :categories => p.blog_categories, :formatter => :rdiscount)
23
23
  acc.post(site['blog_id'], post)
24
- # Expect resp.code == 200 and resp.message == 'OK' for a successful.
24
+
25
25
  end
26
26
  end
27
27
  end
28
+ desc 'Pushes rdocs to carbonica'
29
+ task :carbonica => :redocs do
30
+ sh "scp -r doc/ adgar@carboni.ca@carboni.ca:/var/www/html/projects/#{p.name}/"
31
+ end
28
32
  end
29
33
 
30
34
  # vim: syntax=Ruby
@@ -98,7 +98,7 @@ require 'yaml'
98
98
  # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
99
99
  class Profanalyzer
100
100
 
101
- VERSION = "0.2.1"
101
+ VERSION = "1.0.0"
102
102
 
103
103
  @@full_list = YAML::load_file(File.dirname(__FILE__)+"/../config/list.yml")
104
104
  @@racist_list = @@full_list.select {|w| w[:racist]}
@@ -165,7 +165,7 @@ class Profanalyzer
165
165
  end
166
166
  banned_words = self.forbidden_words_from_settings
167
167
  banned_words.each do |word|
168
- if str =~ /#{word}/
168
+ if str =~ /\b#{word}\b/i
169
169
  @@settings = oldsettings if oldsettings
170
170
  return true
171
171
  end
@@ -205,17 +205,38 @@ class Profanalyzer
205
205
  retstr = str
206
206
 
207
207
  @@settings[:custom_subs].each do |k,v|
208
- retstr.gsub!(/#{k.to_s}/,v.to_s)
208
+ retstr.gsub!(/\b#{k.to_s}\b/i,v.to_s)
209
209
  end
210
210
 
211
211
  banned_words = Profanalyzer.forbidden_words_from_settings
212
212
  banned_words.each do |word|
213
- retstr.gsub!(/#{word}/,
213
+ retstr.gsub!(/\b#{word}\b/i,
214
214
  "#!$%@&!$%@%@&!$#!$%@&!$%@%@&!#!$%@&!$%@%@&!"[0..(word.length-1)])
215
215
  end
216
216
  @@settings = oldsettings if oldsettings
217
217
  retstr
218
- end
218
+ end
219
+
220
+ def self.strip(*args)
221
+ str = args[0]
222
+ if (args.size > 1 && args[1].is_a?(Hash))
223
+ oldsettings = @@settings
224
+ self.update_settings_from_hash args[1]
225
+ end
226
+
227
+ retstr = str
228
+
229
+ @@settings[:custom_subs].each do |k,v|
230
+ retstr.gsub!(/\b#{k.to_s}\b/i,v.to_s)
231
+ end
232
+
233
+ banned_words = Profanalyzer.forbidden_words_from_settings
234
+ banned_words.each do |word|
235
+ retstr.gsub!(/\b#{word}\b/i,"")
236
+ end
237
+ @@settings = oldsettings if oldsettings
238
+ retstr
239
+ end
219
240
 
220
241
  # Sets Profanalyzer's tolerance. Value should be an integer such that
221
242
  # 0 <= T <= 5.
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: profanalyzer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 0
8
+ - 0
9
+ version: 1.0.0
5
10
  platform: ruby
6
11
  authors:
7
12
  - Michael J. Edgar
@@ -9,20 +14,52 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2009-03-25 00:00:00 -04:00
17
+ date: 2010-04-06 00:00:00 -04:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
- name: hoe
21
+ name: rubyforge
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 2
29
+ - 0
30
+ - 2
31
+ version: 2.0.2
17
32
  type: :development
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: gemcutter
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
20
38
  requirements:
21
39
  - - ">="
22
40
  - !ruby/object:Gem::Version
23
- version: 1.11.0
24
- version:
25
- description: "Profanalyzer has one purpose: analyze a block of text for profanity. It is able to filter profane words as well. What sets it slightly apart from other filters is that it classifies each blocked word as \"profane\", \"racist\", or \"sexual\" - although right now, each word is considered \"profane\". It also rates each word on a scale from 0-5, which is based on my subjective opinion, as well as whether the word is commonly used in non-profane situations, such as \"ass\" in \"assess\". The Profanalyzer will default to a tolerance of of 2, which will kick back the arguably non-profane words. It will also test against all words, including racist or sexual words. Lastly, it allows for custom substitutions! For example, the filter at the website http://www.fark.com/ turns the word \"fuck\" into \"fark\", and \"shit\" into \"shiat\". You can specify these if you want."
41
+ segments:
42
+ - 0
43
+ - 2
44
+ - 1
45
+ version: 0.2.1
46
+ type: :development
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: hoe
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ segments:
56
+ - 2
57
+ - 5
58
+ - 0
59
+ version: 2.5.0
60
+ type: :development
61
+ version_requirements: *id003
62
+ description: ""
26
63
  email:
27
64
  - edgar@triqweb.com
28
65
  executables: []
@@ -32,18 +69,19 @@ extensions: []
32
69
  extra_rdoc_files:
33
70
  - History.txt
34
71
  - Manifest.txt
35
- - README.txt
36
72
  files:
37
73
  - History.txt
38
74
  - Manifest.txt
39
- - README.txt
75
+ - README.markdown
40
76
  - Rakefile
41
77
  - config/list.yml
42
78
  - lib/profanalyzer.rb
43
79
  - test/test_profanalyzer.rb
44
80
  - test/test_profanalyzer_advanced.rb
45
81
  has_rdoc: true
46
- homepage: http://profanalyzer.rubyforge.org/
82
+ homepage:
83
+ licenses: []
84
+
47
85
  post_install_message:
48
86
  rdoc_options:
49
87
  - --main
@@ -54,21 +92,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
54
92
  requirements:
55
93
  - - ">="
56
94
  - !ruby/object:Gem::Version
95
+ segments:
96
+ - 0
57
97
  version: "0"
58
- version:
59
98
  required_rubygems_version: !ruby/object:Gem::Requirement
60
99
  requirements:
61
100
  - - ">="
62
101
  - !ruby/object:Gem::Version
102
+ segments:
103
+ - 0
63
104
  version: "0"
64
- version:
65
105
  requirements: []
66
106
 
67
107
  rubyforge_project: profanalyzer
68
- rubygems_version: 1.3.1
108
+ rubygems_version: 1.3.6
69
109
  signing_key:
70
- specification_version: 2
71
- summary: "Profanalyzer has one purpose: analyze a block of text for profanity"
110
+ specification_version: 3
111
+ summary: Analyzes a block of text for profanity. It is able to filter profane words as well.
72
112
  test_files:
73
113
  - test/test_profanalyzer.rb
74
114
  - test/test_profanalyzer_advanced.rb