Sha256: c58b6540fda56eaa61bc301105b17388dc1f26aa62df49f90d0d133ee27a5f91

Contents?: true

Size: 750 Bytes

Versions: 7

Compression:

Stored size: 750 Bytes

Contents

module WitchDoctor
  class Antivirus
    RESULTS = ['Clean', 'VirusInfected', 'FileDownloadError']
    attr_reader :resource, :mount_point

    def initialize(resource, mount_point)
      @resource = resource
      @mount_point = mount_point.to_s
    end

    def latest_scan
      resource
        .virus_scans
        .select { |vs| vs.mount_point == mount_point }
        .last
    end

    def checked?
      latest_scan.scan_result.present?
    end

    def infected?
      !clean? && !error?
    end

    def error?
      throw :file_not_scanned unless checked?
      latest_scan.scan_result == 'FileDownloadError'
    end

    def clean?
      throw :file_not_scanned unless checked?
      latest_scan.scan_result == 'Clean'
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
witch_doctor-0.4.0 lib/witch_doctor/antivirus.rb
witch_doctor-0.3.0 lib/witch_doctor/antivirus.rb
witch_doctor-0.2.0 lib/witch_doctor/antivirus.rb
witch_doctor-0.1.2 lib/witch_doctor/antivirus.rb
witch_doctor-0.1.1.1 lib/witch_doctor/antivirus.rb
witch_doctor-0.1.0 lib/witch_doctor/antivirus.rb
witch_doctor-0.0.3 lib/witch_doctor/antivirus.rb