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
-
.logger ⇒ Object
Returns the value of attribute logger.
-
.scanner_adapter ⇒ Object
Returns the value of attribute scanner_adapter.
Class Method Summary collapse
- .configure {|_self| ... } ⇒ Object
-
.get_adapter ⇒ Class
The scanner adapter class.
- .scan(path) ⇒ Object
- .scanner ⇒ Object
- .test_mode! ⇒ Object
Class Attribute Details
.logger ⇒ Object
Returns the value of attribute logger.
27 28 29 |
# File 'lib/ddr/antivirus.rb', line 27 def logger @logger end |
.scanner_adapter ⇒ Object
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
29 30 31 |
# File 'lib/ddr/antivirus.rb', line 29 def configure yield self end |
.get_adapter ⇒ Class
Returns 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 |
.scanner ⇒ Object
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 |