Skip to content

Instantly share code, notes, and snippets.

@kornysietsma
Created November 2, 2009 11:23
Show Gist options
  • Save kornysietsma/224098 to your computer and use it in GitHub Desktop.
Save kornysietsma/224098 to your computer and use it in GitHub Desktop.
selenium.browser.name=*firefox
selenium.port=4444
class UserConfig
def initialize
@config = {}
basepath = File.join(File.dirname(__FILE__),"..","..","..")
# COMPUTERNAME works on Windows, and as a manual override
hostname = ENV["COMPUTERNAME"] || `hostname`
propfile = "#{basepath}/config/#{hostname.strip}.properties"
throw "No properties file '#{propfile}'" unless File.exists? propfile
File.open(propfile, 'r') do |properties_file|
properties_file.each_line do |line|
line.strip! if line
next if (line.length == 0 || line[0] == ?# || line[0] == ?=)
parts = line.split('=',2)
key = parts[0].strip
raise "duplicate properties key: #{key}" if @config.has_key? key
if parts.length == 2
@config[key] = parts[1].strip
else
@config[key] = ''
end
end
end
end
def [](key)
@config[key]
end
def has_key?(key)
@config.has_key? key
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment