Class: Hydra::Works::VirusCheckerService
- Inherits:
-
Object
- Object
- Hydra::Works::VirusCheckerService
- Defined in:
- lib/hydra/works/services/virus_checker_service.rb
Overview
Responsible for checking if the given file is a virus. Coordinates with the underlying system virus scanner.
Instance Attribute Summary collapse
-
#original_file ⇒ Object
Returns the value of attribute original_file.
-
#system_virus_scanner ⇒ Object
Returns the value of attribute system_virus_scanner.
Class Method Summary collapse
-
.file_has_virus?(original_file) ⇒ Boolean
True or false result from system_virus_scanner.
Instance Method Summary collapse
-
#file_has_virus? ⇒ Boolean
Default behavior is to raise a validation error and halt the save if a virus is found.
-
#initialize(original_file, system_virus_scanner = Hydra::Works.default_system_virus_scanner) ⇒ VirusCheckerService
constructor
A new instance of VirusCheckerService.
Constructor Details
#initialize(original_file, system_virus_scanner = Hydra::Works.default_system_virus_scanner) ⇒ VirusCheckerService
Returns a new instance of VirusCheckerService.
14 15 16 17 |
# File 'lib/hydra/works/services/virus_checker_service.rb', line 14 def initialize(original_file, system_virus_scanner = Hydra::Works.default_system_virus_scanner) self.original_file = original_file self.system_virus_scanner = system_virus_scanner end |
Instance Attribute Details
#original_file ⇒ Object
Returns the value of attribute original_file.
5 6 7 |
# File 'lib/hydra/works/services/virus_checker_service.rb', line 5 def original_file @original_file end |
#system_virus_scanner ⇒ Object
Returns the value of attribute system_virus_scanner.
5 6 7 |
# File 'lib/hydra/works/services/virus_checker_service.rb', line 5 def system_virus_scanner @system_virus_scanner end |
Class Method Details
.file_has_virus?(original_file) ⇒ Boolean
Returns true or false result from system_virus_scanner.
10 11 12 |
# File 'lib/hydra/works/services/virus_checker_service.rb', line 10 def self.file_has_virus?(original_file) new(original_file).file_has_virus? end |
Instance Method Details
#file_has_virus? ⇒ Boolean
Default behavior is to raise a validation error and halt the save if a virus is found
20 21 22 23 |
# File 'lib/hydra/works/services/virus_checker_service.rb', line 20 def file_has_virus? path = original_file.is_a?(String) ? original_file : local_path_for_file(original_file) system_virus_scanner.infected?(path) end |