lib/redis_scanner.rb in redis_scanner-0.1.2 vs lib/redis_scanner.rb in redis_scanner-0.1.3
- old
+ new
@@ -1,32 +1,29 @@
require "redis_scanner/version"
+require "redis_scanner/rule"
+require "redis_scanner/pattern"
+require "redis_scanner/redis"
require "redis_scanner/engine"
+require "redis_scanner/formatter"
require "redis"
module RedisScanner
def self.scan(options)
- redis = Redis.new extract_redis_options(options)
+ redis = Redis.new options
engine = Engine.new redis, options
- result = engine.run
- output_result(result, options)
+ patterns = engine.run
+ output_result(patterns, options)
end
- def self.output_result(result, options)
+ def self.output_result(patterns, options)
+ formatter = Formatter.new(options)
+ result = formatter.format patterns
if options[:file]
File.open(options[:file], "w") do |file|
- result.each { |key, count| file.puts "#{key} #{count}" }
+ file.puts result
end
else
- puts "=========result is========="
- result.each { |key, count| puts "#{key} #{count}" }
- puts "==========================="
+ puts result
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