Class: Stellr::Config

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

Overview

Config

The stellr and stellr-search commands both rely on a YAML file to provide some basic configuration:

:port Port the server should listen to :host Hostname or IP of the server :script Optional ruby file to load during startup. This is the place to load custom code like self made Analyzers you intend to use. :log_level Log level, default is :debug :base_dir Base directory where the server will store index data, log

files and configuration data.

:data_dir Index directory, relative to base_dir. Defaults to data :log_dir Log file directory, relative to base_dir. Defaults to log :conf_dir Configuration directory, relative to base_dir. Defaults to conf. Here stellr will keep the configuration of registered collections, one YAML file per collection. :tmp_dir Temp directory, relative to base_dir. Defaults to tmp

Constant Summary collapse

DEFAULTS =
{ :port           => 9010,
:host           => 'localhost',
:base_dir       => '/var/stellr',
:data_dir       => 'data',
:log_dir        => 'log',
:tmp_dir        => 'tmp',
:conf_dir       => 'conf',
:log_level      => :warn }

Instance Method Summary collapse

Constructor Details

#initialize(config_file = nil, extra_options = {}) ⇒ Config

Configfile search order:

- argument
- /etc/stellr.yml
- +gem_directory+/config/stellr.yml


38
39
40
41
42
# File 'lib/stellr/config.rb', line 38

def initialize( config_file = nil, extra_options = {} )
  load_config config_file
  @config.update extra_options
  @config.each { |k,v| v.untaint } # we trust our config file
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args) ⇒ Object (protected)

Raises:

  • (NameError)


69
70
71
72
# File 'lib/stellr/config.rb', line 69

def method_missing( method_name, *args )
  return @config[method_name] if @config.has_key?( method_name )
  raise NameError.new( "unknown configuration key: #{method_name}" )
end

Instance Method Details

#collection_dirObject



60
61
# File 'lib/stellr/config.rb', line 60

def collection_dir
end

#conf_dirObject



56
57
58
# File 'lib/stellr/config.rb', line 56

def conf_dir
  resolve_directory_name( :conf_dir ) 
end

#data_dirObject



44
45
46
# File 'lib/stellr/config.rb', line 44

def data_dir
  resolve_directory_name( :data_dir )
end

#drb_uriObject



63
64
65
# File 'lib/stellr/config.rb', line 63

def drb_uri
  "druby://#{host}:#{port}"
end

#log_dirObject



48
49
50
# File 'lib/stellr/config.rb', line 48

def log_dir
  resolve_directory_name( :log_dir )
end

#tmp_dirObject



52
53
54
# File 'lib/stellr/config.rb', line 52

def tmp_dir
  resolve_directory_name( :tmp_dir ) 
end