Skip to content

Commit

Permalink
Update parseconfig.rb
Browse files Browse the repository at this point in the history
added the ability to choose a different separator other than '='
  • Loading branch information
nleib committed Jan 22, 2015
1 parent d870747 commit c635d56
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/parseconfig.rb
Expand Up @@ -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()
Expand Down Expand Up @@ -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 = ''
Expand Down

0 comments on commit c635d56

Please sign in to comment.