Sha256: ed2c6b280d131a9c93939aef39ca46cedb2cdae98f8f70b095f5eb856bded634

Contents?: true

Size: 744 Bytes

Versions: 41

Compression:

Stored size: 744 Bytes

Contents

require 'database_cleaner/redis/base'
require 'database_cleaner/generic/truncation'

module DatabaseCleaner
  module Redis
    class Truncation
      include ::DatabaseCleaner::Redis::Base
      include ::DatabaseCleaner::Generic::Truncation

      def clean
        if @only
          @only.each do |term|
            connection.keys(term).each { |k| connection.del k }
          end
        elsif @tables_to_exclude
          keys_except = []
          @tables_to_exclude.each { |term| keys_except += connection.keys(term) }
          connection.keys.each { |k| connection.del(k) unless keys_except.include?(k) }
        else
          connection.flushdb
        end
        connection.quit unless url == :default
      end
    end
  end
end

Version data entries

41 entries across 36 versions & 5 rubygems

Version Path
database_cleaner-1.8.5 adapters/database_cleaner-redis/lib/database_cleaner/redis/truncation.rb
database_cleaner-redis-2.0.0.beta lib/database_cleaner/redis/truncation.rb
database_cleaner-1.8.4 adapters/database_cleaner-redis/lib/database_cleaner/redis/truncation.rb
database_cleaner-1.8.3 adapters/database_cleaner-redis/lib/database_cleaner/redis/truncation.rb
database_cleaner-1.8.2 adapters/database_cleaner-redis/lib/database_cleaner/redis/truncation.rb
database_cleaner-1.8.1 adapters/database_cleaner-redis/lib/database_cleaner/redis/truncation.rb
database_cleaner-1.8.0 adapters/database_cleaner-redis/lib/database_cleaner/redis/truncation.rb
database_cleaner-redis-1.8.0 lib/database_cleaner/redis/truncation.rb
database_cleaner-1.8.0.beta adapters/database_cleaner-redis/lib/database_cleaner/redis/truncation.rb
database_cleaner-redis-1.8.0.beta lib/database_cleaner/redis/truncation.rb
database_cleaner-1.7.0 lib/database_cleaner/redis/truncation.rb
database_cleaner-1.6.2 lib/database_cleaner/redis/truncation.rb
database_cleaner-1.6.1 lib/database_cleaner/redis/truncation.rb
database_cleaner-1.6.0 lib/database_cleaner/redis/truncation.rb
autocompl-0.2.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/database_cleaner-1.5.3/lib/database_cleaner/redis/truncation.rb
autocompl-0.2.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/database_cleaner-1.5.3/lib/database_cleaner/redis/truncation.rb
autocompl-0.2.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/database_cleaner-1.5.3/lib/database_cleaner/redis/truncation.rb
autocompl-0.1.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/database_cleaner-1.5.3/lib/database_cleaner/redis/truncation.rb
autocompl-0.1.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/database_cleaner-1.5.3/lib/database_cleaner/redis/truncation.rb
autocompl-0.1.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/database_cleaner-1.5.3/lib/database_cleaner/redis/truncation.rb