Sha256: fa2ccf389083712ae8d811332395e804bd421d3504e3dca891445db192cda62d

Contents?: true

Size: 756 Bytes

Versions: 6

Compression:

Stored size: 756 Bytes

Contents

require "active_support/core_ext/class/attribute"

module Ddr
  module Antivirus
    class Scanner
      
      # Instance of scanner adapter
      attr_reader :adapter

      def self.scan(path)
        new { |scanner| return scanner.scan(path) }
      end

      def initialize
        @adapter = Ddr::Antivirus::Adapters.get_adapter
        yield self if block_given?
      end

      def scan(path)
        result = adapter.scan(path)
        raise Ddr::Antivirus::VirusFoundError, result if result.has_virus?
        logger.error("Antivirus scanner error (#{result.version})") if result.error?
        logger.info(result.to_s)
        result
      end

      private

        def logger
          Ddr::Antivirus.logger
        end

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ddr-antivirus-1.3.3 lib/ddr/antivirus/scanner.rb
ddr-antivirus-1.3.2 lib/ddr/antivirus/scanner.rb
ddr-antivirus-1.3.1 lib/ddr/antivirus/scanner.rb
ddr-antivirus-1.3.0 lib/ddr/antivirus/scanner.rb
ddr-antivirus-1.2.1 lib/ddr/antivirus/scanner.rb
ddr-antivirus-1.2.0 lib/ddr/antivirus/scanner.rb