Module: Soap

Defined in:
lib/soap.rb,
lib/soap/version.rb

Constant Summary collapse

WORDS =
File.read(File.expand_path('../words.txt', __FILE__)).split("\n")
LETTERS =
{
  'a' => 'a4',
  'b' => 'b6',
  'c' => 'c',
  'd' => 'd',
  'e' => 'e3',
  'f' => 'f',
  'g' => 'g9',
  'h' => 'h',
  'i' => 'i1l',
  'j' => 'j',
  'k' => 'k',
  'l' => 'i1l',
  'm' => 'm',
  'n' => 'n',
  'o' => 'o0',
  'p' => 'p',
  'q' => 'q',
  'r' => 'r',
  's' => 's',
  't' => 't1',
  'u' => 'u',
  'v' => 'v',
  'w' => 'w',
  'x' => 'x',
  'y' => 'y',
  'z' => 'z',
}
CHAR_CLASSES =
LETTERS.inject({}) { |acc,(letter,set_string)| acc[letter] = '['+set_string+']'; acc }
PATTERN =
%r{#{WORDS.map {|word| word.split('').map{|letter|CHAR_CLASSES[letter]}.join('') }.join('|')}}
VERSION =
'1.0.2'

Class Method Summary collapse

Class Method Details

.detect_profanity(test_string) ⇒ Object



33
34
35
# File 'lib/soap.rb', line 33

def self.detect_profanity(test_string)
  not test_string.downcase.match(PATTERN).nil?
end