Created
November 2, 2009 11:23
-
-
Save kornysietsma/224098 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
selenium.browser.name=*firefox | |
selenium.port=4444 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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