Sha256: 7d6106426236258983ea2473045ca36dddddbd57393df0afd75eb9f67a145bf2

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

require "ddr/antivirus/version"
require "ddr/antivirus/scanner"
require "ddr/antivirus/scan_result"
require "ddr/antivirus/adapters"

require "active_support/core_ext/module/attribute_accessors"

module Ddr
  module Antivirus

    class VirusFoundError < ::StandardError; end

    def self.configure
      yield self
    end

    #
    # Custom logger
    #
    # Defaults to Rails logger if Rails is loaded; otherwise logs to STDERR.
    #
    mattr_accessor :logger do
      if defined?(Rails) && Rails.logger
        Rails.logger
      else 
        require "logger"
        Logger.new(STDERR)    
      end
    end

    #
    # Scanner adapter
    #
    # Defaults to:
    # - :clamav adapter if the 'clamav' gem is installed; 
    # - :clamd adapter if the 'clamdscan' executable is available;
    # - otherwise, the :null adapter.
    #
    mattr_accessor :scanner_adapter do
      begin
        require "clamav"
        :clamav
      rescue LoadError
        if system "which -s clamdscan"
          :clamd
        else
          :null
        end
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ddr-antivirus-1.2.0 lib/ddr/antivirus.rb
ddr-antivirus-1.1.0 lib/ddr/antivirus.rb