Class: Melissa::Config
- Inherits:
-
Object
- Object
- Melissa::Config
- Defined in:
- lib/melissa/config.rb
Instance Attribute Summary collapse
-
#addr_obj_lib ⇒ Object
Returns the value of attribute addr_obj_lib.
-
#data_path ⇒ Object
Returns the value of attribute data_path.
-
#geo_point_lib ⇒ Object
Returns the value of attribute geo_point_lib.
-
#license ⇒ Object
Returns the value of attribute license.
-
#mode ⇒ Object
Returns the value of attribute mode.
Instance Method Summary collapse
-
#config_path=(config_path) ⇒ Object
you can configure config_path from your code using: Melissa.configure do |config| config.config_path = “/etc/config/melissa” end.
- #home=(home) ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/melissa/config.rb', line 25 def initialize #It is recommended to read the following config options from environment variables #From Melissa Data documentation: #The license string should be entered as an environment variable named #MD_LICENSE. This allows you to update your license string without editing #and recompiling your code self.mode = :live self.home = ENV['MELISSA_HOME'] || '/usr/local/dqs' self.config_path = ENV['MELISSA_CONFIG_PATH'] if ENV['MELISSA_CONFIG_PATH'] @data_path = ENV['MELISSA_DATA_PATH'] if ENV['MELISSA_DATA_PATH'] @addr_obj_lib = ENV['MELISSA_ADDR_OBJ_LIB'] if ENV['MELISSA_ADDR_OBJ_LIB'] @geo_point_lib = ENV['MELISSA_GEO_POINT_LIB'] if ENV['MELISSA_GEO_POINT_LIB'] @license = ENV['MD_LICENSE'] if ENV['MD_LICENSE'] end |
Instance Attribute Details
#addr_obj_lib ⇒ Object
Returns the value of attribute addr_obj_lib.
23 24 25 |
# File 'lib/melissa/config.rb', line 23 def addr_obj_lib @addr_obj_lib end |
#data_path ⇒ Object
Returns the value of attribute data_path.
23 24 25 |
# File 'lib/melissa/config.rb', line 23 def data_path @data_path end |
#geo_point_lib ⇒ Object
Returns the value of attribute geo_point_lib.
23 24 25 |
# File 'lib/melissa/config.rb', line 23 def geo_point_lib @geo_point_lib end |
#license ⇒ Object
Returns the value of attribute license.
23 24 25 |
# File 'lib/melissa/config.rb', line 23 def license @license end |
#mode ⇒ Object
Returns the value of attribute mode.
23 24 25 |
# File 'lib/melissa/config.rb', line 23 def mode @mode end |
Instance Method Details
#config_path=(config_path) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/melissa/config.rb', line 45 def config_path=(config_path) File.open(config_path, 'r') do |fin| fin.each do |line| line.strip! next if line.empty? || line[0] == '#' equal_index = line.index('=') key = line[0, equal_index].strip.downcase value = line[(equal_index+1)..-1].strip send("#{key}=", value) end end rescue Errno::ENOENT raise "Configuration file couldn't be found. We need #{config_path}" end |
#home=(home) ⇒ Object
60 61 62 63 64 |
# File 'lib/melissa/config.rb', line 60 def home=(home) @addr_obj_lib = "#{home}/AddrObj/libmdAddr.so" @geo_point_lib = "#{home}/GeoObj/libmdGeo.so" @data_path = "#{home}/data" end |