Class: Hydra::Works::VirusScanner
- Inherits:
-
Object
- Object
- Hydra::Works::VirusScanner
- Defined in:
- lib/hydra/works/virus_scanner.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Class Method Summary collapse
Instance Method Summary collapse
- #clam_av_scanner ⇒ Object
- #clamby_scanner ⇒ Boolean
-
#infected? ⇒ Boolean
Override this method to use your own virus checking software.
-
#initialize(file) ⇒ VirusScanner
constructor
A new instance of VirusScanner.
-
#null_scanner ⇒ Object
Always return zero if there’s nothing available to check for viruses.
Constructor Details
#initialize(file) ⇒ VirusScanner
Returns a new instance of VirusScanner.
26 27 28 |
# File 'lib/hydra/works/virus_scanner.rb', line 26 def initialize(file) @file = file end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
18 19 20 |
# File 'lib/hydra/works/virus_scanner.rb', line 18 def file @file end |
Class Method Details
.infected?(file) ⇒ Boolean
22 23 24 |
# File 'lib/hydra/works/virus_scanner.rb', line 22 def self.infected?(file) new(file).infected? end |
Instance Method Details
#clam_av_scanner ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/hydra/works/virus_scanner.rb', line 42 def clam_av_scanner Deprecation.warn(self, "The ClamAV has been replaced by Clamby " \ "as the supported virus scanner for hydra-works. " \ "ClamAV support will be removed in hydra-works 2.0 ") scan_result = ClamAV.instance.method(:scanfile).call(file) return false if scan_result == 0 warning "A virus was found in #{file}: #{scan_result}" true end |
#clamby_scanner ⇒ Boolean
53 54 55 56 57 |
# File 'lib/hydra/works/virus_scanner.rb', line 53 def clamby_scanner scan_result = Clamby.virus?(file) warning("A virus was found in #{file}") if scan_result scan_result end |
#infected? ⇒ Boolean
Override this method to use your own virus checking software
32 33 34 35 36 37 38 39 40 |
# File 'lib/hydra/works/virus_scanner.rb', line 32 def infected? if defined?(Clamby) clamby_scanner elsif defined?(ClamAV) clam_av_scanner else null_scanner end end |
#null_scanner ⇒ Object
Always return zero if there’s nothing available to check for viruses. This means that we assume all files have no viruses because we can’t conclusively say if they have or not.
61 62 63 64 |
# File 'lib/hydra/works/virus_scanner.rb', line 61 def null_scanner warning "Unable to check #{file} for viruses because no virus scanner is defined" false end |