saintly 0.1.4 → 0.1.5

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/History.txt CHANGED
@@ -14,3 +14,9 @@
14
14
 
15
15
  * Allows are partials, makes it easier to accept plurals
16
16
 
17
+ === 0.1.5 / 2010-07-08
18
+
19
+ * Allows are now regex components. Added matchers to allow *lass (e.g. lass, glass, class) and bass
20
+
21
+
22
+
data/lib/saintly.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  module Saintly
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
 
4
4
  def self.sanitize(text)
5
5
  return if text.nil?
6
- r = Regexp.new(ALLOWED_WORDS.join('|'))
6
+ r = Regexp.new('^(' + ALLOWED_WORDS.join('|') + ')$')
7
7
  text.gsub(exclude_regex){|m| r.match(m).nil? ? '*' * m.length : m }
8
8
  end
9
9
 
@@ -18,7 +18,7 @@ module Saintly
18
18
  end
19
19
 
20
20
 
21
- ALLOWED_WORDS = [ 'glass', 'scunthorpe', 'assume', 'assumption', 'assassin', 'asset', 'assassinate', 'shitake']
21
+ ALLOWED_WORDS = [ '.*lass', 'bass', 'scunthorpe', 'assum.+', 'assassin.*', 'asset.*', 'shitake.*']
22
22
 
23
23
 
24
24
  RESTRICTED_PARTIALS = [
data/test/saintly_test.rb CHANGED
@@ -13,7 +13,7 @@ class SaintlyTest < Test::Unit::TestCase
13
13
  assert_equal '****', Saintly.sanitize('cunt')
14
14
  assert_equal '****', Saintly.sanitize('twat')
15
15
  assert_equal '******', Saintly.sanitize('nigger')
16
-
16
+ assert_equal '*******', Saintly.sanitize('dumbass')
17
17
  end
18
18
  should "sanitize partial words" do
19
19
  assert_equal '*******', Saintly.sanitize('fucking')
@@ -29,16 +29,18 @@ class SaintlyTest < Test::Unit::TestCase
29
29
 
30
30
  should "not sanitize allowed words" do
31
31
  assert_equal 'shitake', Saintly.sanitize('shitake')
32
-
32
+
33
33
  assert_equal 'assassin', Saintly.sanitize('assassin')
34
34
  assert_equal 'assumption', Saintly.sanitize('assumption')
35
35
  assert_equal 'assume', Saintly.sanitize('assume')
36
- assert_equal 'glass', Saintly.sanitize('glass')
36
+ assert_equal 'bass', Saintly.sanitize('bass')
37
37
 
38
38
  assert_equal 'scunthorpe', Saintly.sanitize('scunthorpe')
39
39
  assert_equal 'lightwater', Saintly.sanitize('lightwater')
40
40
 
41
41
  assert_equal 'assets', Saintly.sanitize('assets')
42
+ assert_equal 'glass', Saintly.sanitize('glass')
43
+
42
44
  end
43
45
 
44
46
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: saintly
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 4
10
- version: 0.1.4
9
+ - 5
10
+ version: 0.1.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Justin Coyne
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-08 00:00:00 -05:00
18
+ date: 2010-07-09 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency