Class: NFAgent::Config

Inherits:
SVUtil::Config
  • Object
show all
Defined in:
lib/nfagent/config.rb

Constant Summary collapse

@@test_mode =
false

Class Method Summary collapse

Class Method Details

.process_optionsObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/nfagent/config.rb', line 52

def process_options
  parse_options do |opts|
    opts.on("-k", "--client-key [key]", "Service client key") do |key|
      Config.client_key = key
      end
    opts.on("-l", "--debug-log [log-file]", "Debug Log File") do |log|
      Config.log_file = log
    end
    opts.on("-D", "--dump-dir [dir]", "Dump directory for failed chunks") do |dir|
      Config.dump_dir = dir
    end
    opts.on("-T", "--test", "Run connection tests") do
      @@test_mode = true
    end
    opts.on("-P", "--parse", "Parse locally before submitting") do
      Config.parse_locally = true
    end
  end
end

.test_mode?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/nfagent/config.rb', line 7

def self.test_mode?
  @@test_mode
end

.validateObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/nfagent/config.rb', line 31

def validate
  unless dump_dir and File.exists?(dump_dir) and File.directory?(dump_dir)
    raise "Dump dir (#{dump_dir}) must exist and be a directory"
  end
  # Mode
  unless %w(normal multi).include?(mode)
    raise "Invalid mode: must be one of 'normal' or 'multi'"
  end
  if mode == 'multi' && mapper.blank?
    raise "Multi mode requires a mapper to be set"
  end
  if mode == 'multi' && parse != 'locally'
    raise "Multi mode requires that parsing be done locally (set parse = 'locally')"
  end
  # Parse
  unless %w(remotely locally).include?(parse)
    raise "Invalid parse option: Must be one of 'remotely' or 'locally'"
  end
  super
end