#!/usr/bin/env ruby require File.expand_path('../../config/boot.rb', __FILE__) require File.expand_path('../../config/environment.rb', __FILE__) def check_hash(hash) any = false if hash.is_a?(Hash) for key, value in hash if value.is_a?(String) begin value.encode('utf-8').match(/.*/) rescue any = true end end end end return any end def check_list_of_lists(list) any = false if list.is_a?(Array) for list2 in list if list2.is_a?(Array) for value in list2 if value.is_a?(String) begin value.encode('utf-8').match(/.*/) rescue any = true end end end end end end return any end errors = 0 for naming in Naming.all if check_hash(naming.reasons) puts "Naming ##{naming.id} has corrupt reasons." errors += 1 end end for user in User.all if check_list_of_lists(user.bonuses) puts "User ##{user.id} has corrupt bonuses." errors += 1 end if check_hash(user.alert) puts "User ##{user.id} has corrupt alert." errors += 1 end end puts "Found #{errors} errors."