lib/rconf/overrides_language.rb in rconf-1.0.12 vs lib/rconf/overrides_language.rb in rconf-1.0.13
- old
+ new
@@ -83,26 +83,28 @@
overrides.class.class_eval(code)
overrides.instance_eval("@#{key} = #{klass}.new")
end
begin
source.split("\n").each do |o|
- operands = o.gsub(/\s+/, '').split('=')
- if operands.size != 2
- raise "Invalid syntax '#{o}', must be of the form 'key.setting=value'"
- end
+ unless o.start_with?('#') # ignore commented-out lines
+ operands = o.gsub(/\s+/, '').split('=')
+ if operands.size != 2
+ raise "Invalid syntax '#{o}', must be of the form 'key.setting=value'"
+ end
- if operands[1].start_with?('"') || operands[1].start_with?("'")
- # Quoted string
- value = operands[1]
- elsif operands[1] =~ NIL_LITERAL
- # Literal nil
- value = 'nil'
- else
- # Anything else: assume unquoted string
- value = "'#{operands[1]}'"
- end
+ if operands[1].start_with?('"') || operands[1].start_with?("'")
+ # Quoted string
+ value = operands[1]
+ elsif operands[1] =~ NIL_LITERAL
+ # Literal nil
+ value = 'nil'
+ else
+ # Anything else: assume unquoted string
+ value = "'#{operands[1]}'"
+ end
- overrides.instance_eval("@#{operands[0]}=#{value}")
+ overrides.instance_eval("@#{operands[0]}=#{value}")
+ end
end
rescue Exception => e
@overrides = nil
@parse_error = e
end