Class: RubySeleniumConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/RubySelenium.rb

Defined Under Namespace

Classes: SeleniumConfig

Instance Method Summary collapse

Constructor Details

#initialize(config_file) ⇒ RubySeleniumConfig

Returns a new instance of RubySeleniumConfig.



164
165
166
167
168
169
170
# File 'lib/RubySelenium.rb', line 164

def initialize(config_file)
    begin
        @config = File.readlines(config_file)
    rescue
        raise MissingConfigurationFile, "Can't find rubySeleniumConfig.txt file - please check it's in the same directory as your ruby tests" 
    end
end

Instance Method Details

#parse_config_fileObject



172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/RubySelenium.rb', line 172

def parse_config_file
    rem_array = []
    prop_array = []
    @config.each do |line|
        if line.match(/^#/)
            rem_array << line 
        else 
            unless line.match(/^\n$/) then prop_array << line.chomp end
        end
    end
    return prop_array - rem_array
end

#propertiesObject



185
186
187
188
189
190
191
192
193
194
# File 'lib/RubySelenium.rb', line 185

def properties
    config_hash = {}
    parse_config_file.each do |data|
        split = data.split("=")
        property = split[0].gsub(/\s*/, "")
        value = split[1].gsub(/$\s*/, "").gsub(/^\s*/, "")
        config_hash.store(property,SeleniumConfig.new(property, value))
    end
    return config_hash
end