Sha256: 05ee71ac656fa735b6807c06ae6a90d4e894bd7c672a78172dfff4a7e98ec33c

Contents?: true

Size: 565 Bytes

Versions: 2

Compression:

Stored size: 565 Bytes

Contents

require 'yaml'
require 'fuzzy_hash'
require 'bloomfilter'

class Swearjar
  class Tester
    
    def initialize(config_file)
      data = YAML.load_file
      
      @tester = FuzzyHash.new
      
      data['regex'].each do |pattern, type|
        @tester[Regexp.new(pattern)] = type
      end
      
      data['simple'].each do |test, type|
        @tester[test] = type
      end
      
    end
    
    def scan(string, &block)
      string.scan(/\b[\b]+\b/, &block)
    end

    def profane?(string)
      scan(string) {|w| return true}
    end
    
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
swearjar-0.0.2 lib/swearjar/tester.rb
swearjar-0.0.1 lib/swearjar/tester.rb