Module: Clamby
- Defined in:
- lib/clamby.rb,
lib/clamby/error.rb,
lib/clamby/command.rb,
lib/clamby/version.rb
Defined Under Namespace
Classes: ClamscanClientError, ClamscanMissing, Command, Error, FileNotFound, VirusDetected
Constant Summary
collapse
- DEFAULT_CONFIG =
{
:check => true,
:daemonize => false,
:config_file => nil,
:error_clamscan_missing => true,
:error_clamscan_client_error => false,
:error_file_missing => true,
:error_file_virus => false,
:fdpass => false,
:stream => false,
:output_level => 'medium',
:datadir => nil,
:executable_path_clamscan => 'clamscan',
:executable_path_clamdscan => 'clamdscan',
:executable_path_freshclam => 'freshclam',
}.freeze
- VERSION =
"1.6.6"
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.config ⇒ Object
Returns the value of attribute config.
29
30
31
|
# File 'lib/clamby.rb', line 29
def config
@config
end
|
.valid_config_keys ⇒ Object
Returns the value of attribute valid_config_keys.
30
31
32
|
# File 'lib/clamby.rb', line 30
def valid_config_keys
@valid_config_keys
end
|
Class Method Details
33
34
35
36
37
38
39
40
|
# File 'lib/clamby.rb', line 33
def self.configure(opts = {})
if opts.delete(:silence_output)
warn ':silence_output config is deprecated. Use :output_level => "off" instead.'
opts[:output_level] = 'off'
end
opts.each {|k,v| config[k.to_sym] = v if valid_config_keys.include? k.to_sym}
end
|
.daemonize? ⇒ Boolean
67
68
69
|
# File 'lib/clamby.rb', line 67
def self.daemonize?
!! config[:daemonize]
end
|
.safe?(path) ⇒ Boolean
42
43
44
45
46
|
# File 'lib/clamby.rb', line 42
def self.safe?(path)
value = virus?(path)
return nil if value.nil?
! value
end
|
.scanner_exists? ⇒ Boolean
53
54
55
56
57
58
59
60
61
|
# File 'lib/clamby.rb', line 53
def self.scanner_exists?
return true unless config[:check]
scanner = Command.clamscan_version
return true if scanner
return false unless config[:error_clamscan_missing]
raise Clamby::ClamscanMissing.new("#{Command.scan_executable} not found. Check your installation and path.")
end
|
.virus?(path) ⇒ Boolean
48
49
50
51
|
# File 'lib/clamby.rb', line 48
def self.virus?(path)
return nil unless scanner_exists?
Command.scan path
end
|