#
# gpconfig.rb
# Provides contents of a goprint.cfg file as a properties hash.
#
# Copyright (c) 2003-2014 GoPrint Systems, Inc.  All rights reserved.
#

def loadProperties(propertiesFilename)
	# Create a new hash for the properties
	properties = Hash.new
	# Open the properties file
	propertiesFile = File.open(propertiesFilename, 'r')
	# Read each line of the properties file
	propertiesFile.read.each_line { |line|
		# Trim any white space at the beginning or end
		line.strip!
		# Skip lines which start with a '#'
		if (line[0] != ?#)
			# Find the '=' location
			i = line.index('=')
			if (i)
				# '=' found, set the property value
				propertyName = line[0..i - 1].strip
				properties[propertyName] = line[i + 1..-1].strip
				properties[propertyName] = nil if properties[propertyName].length == 0
			else
				# '=' not found, set the property to nil
				properties[line] = nil
			end
		end }
	# Return the properties
	properties
end
