Sha256: a0c9e520b4abe6eae2973aa8d3dd6aa5f579759ec341cffa1b2271a5f4f26d85
Contents?: true
Size: 1.3 KB
Versions: 3
Compression:
Stored size: 1.3 KB
Contents
require "logger" require_relative "antivirus/version" require_relative "antivirus/exceptions" require_relative "antivirus/scanner" require_relative "antivirus/scan_result" require_relative "antivirus/scanner_adapter" require_relative "antivirus/adapters/null_scanner_adapter" module Ddr module Antivirus class << self attr_accessor :logger, :scanner_adapter def configure yield self end def scan(path) Scanner.scan(path) end def scanner s = Scanner.new block_given? ? yield(s) : s end def test_mode! configure do |config| config.logger = Logger.new(File::NULL) config.scanner_adapter = :null end end # @return [Class] the scanner adapter class def get_adapter if scanner_adapter.nil? raise Error, "`Ddr::Antivirus.scanner_adapter` is not configured." end require_relative "antivirus/adapters/#{scanner_adapter}_scanner_adapter" adapter_name = scanner_adapter.to_s.capitalize + "ScannerAdapter" self.const_get(adapter_name, false) end end self.logger = if defined?(Rails) && Rails.logger Rails.logger else Logger.new(STDERR) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ddr-antivirus-3.0.0 | lib/ddr/antivirus.rb |
ddr-antivirus-3.0.0.rc1 | lib/ddr/antivirus.rb |
ddr-antivirus-2.2.0 | lib/ddr/antivirus.rb |