Sha256: 63536513a28cb7d508ab16752d577499b1a6bacee8dbb10a2a5bad0ac62d8c41
Contents?: true
Size: 1.37 KB
Versions: 1
Compression:
Stored size: 1.37 KB
Contents
require "logger" require_relative "antivirus/version" 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 Error < ::StandardError; end class VirusFoundError < Error; end class ScannerError < Error; end 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ddr-antivirus-2.0.0.rc1 | lib/ddr/antivirus.rb |