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
-
#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
36 37 38 39 40 41 |
# File 'lib/hydra/works/virus_scanner.rb', line 36 def clam_av_scanner 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 |
#infected? ⇒ Boolean
Override this method to use your own virus checking software
32 33 34 |
# File 'lib/hydra/works/virus_scanner.rb', line 32 def infected? defined?(ClamAV) ? clam_av_scanner : null_scanner 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.
45 46 47 48 |
# File 'lib/hydra/works/virus_scanner.rb', line 45 def null_scanner warning "Unable to check #{file} for viruses because no virus scanner is defined" false end |