From c635d56f95a776ecb20286e91f68d8cfd3be7fb1 Mon Sep 17 00:00:00 2001 From: nleib Date: Thu, 22 Jan 2015 10:37:03 +0200 Subject: [PATCH] Update parseconfig.rb added the ability to choose a different separator other than '=' --- lib/parseconfig.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/parseconfig.rb b/lib/parseconfig.rb index 7a865b9..c270a62 100644 --- a/lib/parseconfig.rb +++ b/lib/parseconfig.rb @@ -28,10 +28,11 @@ class ParseConfig # the config file is 'param = value' then the itializer # will eval "@param = value" # - def initialize(config_file=nil) + def initialize(config_file=nil, separator = '=') @config_file = config_file @params = {} @groups = [] + @splitRegex = '\s*' + separator + '\s*' if(self.config_file) self.validate_config() @@ -65,8 +66,8 @@ def import_config() end unless (/^\#/.match(line)) - if(/\s*=\s*/.match(line)) - param, value = line.split(/\s*=\s*/, 2) + if(/#{@splitRegex}/.match(line)) + param, value = line.split(/#{@splitRegex}/, 2) var_name = "#{param}".chomp.strip value = value.chomp.strip new_value = ''