Sha256: e84de3bc09821b484cdad255ddfb381c6820c908795645544811d7c0dcda96ec

Contents?: true

Size: 958 Bytes

Versions: 1

Compression:

Stored size: 958 Bytes

Contents

require "clamby/version"

module Clamby

  @config = {:check => true}

  @valid_config_keys = @config.keys

  def self.configure(opts = {})
    opts.each {|k,v| @config[k.to_sym] = v if @valid_config_keys.include? k.to_sym}
  end

  def self.scan(path)
  	if self.scanner_exists?
  		if file_exists?(path)
  			scanner = system("clamscan #{path} --no-summary")
			if scanner
				return true
			elsif not scanner
				puts "VIRUS DETECTED on #{Time.now}: #{path}"
				return false
			end
		end
	end
  end

  def self.scanner_exists?
  	if @config[:check]
	  	scanner = system('clamscan')
	  	if not scanner
	  		puts "CLAMSCAN NOT FOUND"
	  		return false
	  	else
	  		return true
	  	end
	else
		return true
	end
  end

  def self.file_exists?(path)
  	if File.file?(path)
  		return true
	else
		puts "FILE NOT FOUND on #{Time.now}: #{path}"
		return false
	end
  end

  def self.update
  	system("freshclam")
  end

  def self.config
    @config
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
clamby-1.0.1 lib/clamby.rb