Class: OptionValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/option_validator.rb

Overview

checks if all required arguments are specified and if their values are correct

  • $Author$

  • $Rev$

  • $LastChangedDate$

Instance Method Summary collapse

Constructor Details

#initializeOptionValidator

Returns a new instance of OptionValidator.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/option_validator.rb', line 8

def initialize
  storage = ['memory','sqlite']
  language = ['german','english']

  if ($config['crawler']['stopwords'].nil?) then
    $config['crawler']['stopwords'] = File.dirname(__FILE__) +"/stoplist/#{$config['language']}/stopwords.txt"
  end

  unless(language.include?($config['language']))
    $logger.error('language must be english or german')
    exit
  end
  unless(storage.include?($config['storage']))
    $logger.error('storage must be memory or sqlite')
    exit
  end
  unless($config['crawler']['docs'].size>0)
    $logger.error('doc types must be specified')
    exit
  end
  unless (File.exists?($config['crawler']['stopwords']))
    $logger.error('stopwords file does not exist')
    exit
  end
  
  unless (directory_exists?($config['crawler']['docpath']))
    $logger.error('docpath does not exist')
  end
  
  unless (base_directory_exists?($config['search_generator']['search_data_file']))
    $logger.error('path to the search data file does not exits. Please create the directory first')
  end
  
  unless (base_directory_exists?($config['search_generator']['output_frequency_to']))
    $logger.error('path to the frequency file does not exits. Please create the directory first')
  end
end