/usr/lib/ruby/vendor_ruby/database_cleaner/generic/truncation.rb is in ruby-database-cleaner 1.3.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | module DatabaseCleaner
module Generic
module Truncation
def initialize(opts={})
if !opts.empty? && !(opts.keys - [:only, :except, :pre_count, :reset_ids, :cache_tables]).empty?
raise ArgumentError, "The only valid options are :only, :except, :pre_count, :reset_ids or :cache_tables. You specified #{opts.keys.join(',')}."
end
if opts.has_key?(:only) && opts.has_key?(:except)
raise ArgumentError, "You may only specify either :only or :except. Doing both doesn't really make sense does it?"
end
@only = opts[:only]
@tables_to_exclude = Array( (opts[:except] || []).dup ).flatten
@tables_to_exclude += migration_storage_names
@pre_count = opts[:pre_count]
@reset_ids = opts[:reset_ids]
@cache_tables = opts.has_key?(:cache_tables) ? !!opts[:cache_tables] : true
end
def start
#included for compatability reasons, do nothing if you don't need to
end
def clean
raise NotImplementedError
end
private
def tables_to_truncate
raise NotImplementedError
end
# overwrite in subclasses
# default implementation given because migration storage need not be present
def migration_storage_names
%w[]
end
end
end
end
|