Module: Ddr::Antivirus

Defined in:
lib/ddr/antivirus.rb,
lib/ddr/antivirus/scanner.rb,
lib/ddr/antivirus/version.rb,
lib/ddr/antivirus/scan_result.rb,
lib/ddr/antivirus/scanner_adapter.rb,
lib/ddr/antivirus/adapters/null_scanner_adapter.rb,
lib/ddr/antivirus/adapters/clamd_scanner_adapter.rb

Defined Under Namespace

Classes: ClamdScannerAdapter, Error, NullScannerAdapter, ResultError, ScanResult, Scanner, ScannerAdapter, ScannerError, VirusFoundError

Constant Summary collapse

VERSION =
"2.1.1"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.loggerObject

Returns the value of attribute logger.



27
28
29
# File 'lib/ddr/antivirus.rb', line 27

def logger
  @logger
end

.scanner_adapterObject

Returns the value of attribute scanner_adapter.



27
28
29
# File 'lib/ddr/antivirus.rb', line 27

def scanner_adapter
  @scanner_adapter
end

Class Method Details

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



29
30
31
# File 'lib/ddr/antivirus.rb', line 29

def configure
  yield self
end

.get_adapterClass

Returns the scanner adapter class.

Returns:

  • (Class)

    the scanner adapter class



50
51
52
53
54
55
56
57
# File 'lib/ddr/antivirus.rb', line 50

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

.scan(path) ⇒ Object



33
34
35
# File 'lib/ddr/antivirus.rb', line 33

def scan(path)
  Scanner.scan(path)
end

.scannerObject



37
38
39
40
# File 'lib/ddr/antivirus.rb', line 37

def scanner
  s = Scanner.new
  block_given? ? yield(s) : s
end

.test_mode!Object



42
43
44
45
46
47
# File 'lib/ddr/antivirus.rb', line 42

def test_mode!
  configure do |config|
    config.logger = Logger.new(File::NULL)
    config.scanner_adapter = :null
  end
end