Sha256: f1162e20e38d0ffb147a0ea44fff4fe323581092f97c514e66ff5a3f4d782d5a

Contents?: true

Size: 811 Bytes

Versions: 3

Compression:

Stored size: 811 Bytes

Contents

require "redis_scanner/version"
require "redis_scanner/engine"
require "redis"

module RedisScanner
  def self.scan(options)
    redis = Redis.new extract_redis_options(options)
    engine = Engine.new redis, options
    result = engine.run
    output_result(result, options)
  end

  def self.output_result(result, options)
    if options[:file]
      File.open(options[:file], "w") do |file|
        result.each { |key, count| file.puts "#{key} #{count}" }
      end
    else
      puts "=========result is========="
      result.each { |key, count| puts "#{key} #{count}" }
      puts "==========================="
    end
  end

  def self.extract_redis_options(options)
    result = {}
    [:host, :port, :socket, :password, :db].each do |key|
      result[key] = options[key]
    end
    result
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
redis_scanner-0.1.2 lib/redis_scanner.rb
redis_scanner-0.1.1 lib/redis_scanner.rb
redis_scanner-0.1.0 lib/redis_scanner.rb