class Magnesium::Config
Public Class Methods
check_config()
click to toggle source
check config
# File lib/magnesium/support/config.rb, line 95 def self.check_config flag = true if config["browser"]["value"].nil? puts 'M: Please set browser use add_browser function.' flag = false elsif config["testlink"]["host"].nil? puts '' flag = false elsif config["testlink"]["host_account"].nil? puts '' flag = false elsif config["testlink"]["host_pwd"].nil? puts '' flag = false elsif config["testlink"]["database"].nil? puts '' flag = false elsif config["testlink"]["db_account"].nil? puts '' flag = false elsif config["testlink"]["db_pwd"].nil? puts '' flag = false elsif config["testlink"]["install_path"].nil? puts '' flag = false elsif config["temp"].nil? puts '' flag = false end return flag end
config()
click to toggle source
# File lib/magnesium/support/config.rb, line 10 def self.config() begin file_path = File.expand_path("../../config.xml",__FILE__) @XML = XML.openXML(file_path) doc = XML.new_document(@XML) config = Hash.new #browser hash = Hash.new doc.elements.each("config/basic/browser") do |e| #puts e.attributes["value"] #puts e.attributes["proxy"] hash["value"] = e.attributes["value"] hash["proxy"] = e.attributes["proxy"] end config["browser"] = hash # puts config["browser"] #testlink hash = Hash.new doc.elements.each("config/basic/testlink") do |e| hash["host"] = e.attributes["host"] hash["host_account"] = e.attributes["host_account"] hash["host_pwd"] = e.attributes["host_pwd"] hash["database"] = e.attributes["database"] hash["db_account"] = e.attributes["db_account"] hash["db_pwd"] = e.attributes["db_pwd"] hash["install_path"] = e.attributes["install_path"] end config["testlink"] = hash #temp doc.elements.each("config/basic/temp") do |e| config["temp"] = e.attributes["path"] end #log hash = Hash.new doc.elements.each("config/optioanl/log") do |e| hash["isstart"] = e.attributes["isstart"] hash["path"] = e.attributes["path"] end config["log"] = hash #mail hash = Hash.new doc.elements.each("config/optional/mail") do |e| hash["isstart"] = e.attributes["isstart"] hash["fromacount"] = e.attributes["fromaccount"] hash["toaccount"] = e.attributes["toaccount"] end config["mail"] = hash #screenshot hash = Hash.new doc.elements.each("config/optional/screenshot") do |e| hash["isstart"] = e.attributes["isstart"] hash["path"] = e.attributes["path"] end config["screenshot"] = hash #performance hash = Hash.new doc.elements.each("config/optional/performance") do |e| hash["isstart"] = e.attributes["isstart"] hash["path"] = e.attributes["path"] end config["performance"] = hash #wait hash = Hash.new doc.elements.each("config/optional/wait") do |e| hash["isstart"] = e.attributes["isstart"] hash["value"] = e.attributes["value"] end config["wait"] = hash return config rescue error puts 'test' #ensure # closeXML(@XML) end end
set_browser(value,proxy)
click to toggle source
browser modify
# File lib/magnesium/support/config.rb, line 129 def self.set_browser(value,proxy) file_path = File.expand_path("../../config.xml",__FILE__) modify_attribute(file_path,"config/basic/browser","value",value) modify_attribute(file_path,"config/basic/browser","proxy",proxy) end
set_log_path(path)
click to toggle source
log
# File lib/magnesium/support/config.rb, line 244 def self.set_log_path(path) begin file_path = File.expand_path("../../config.xml",__FILE__) modify_attribute(@file_path,"config/optional/log","path",path) rescue error #ensure end end
set_mail_from_account(value)
click to toggle source
# File lib/magnesium/support/config.rb, line 265 def self.set_mail_from_account(value) begin file_path = File.expand_path("../../config.xml",__FILE__) modify_attribute(file_path,"config/optional/mail","fromaccount",value) rescue error #ensure end end
set_mail_start(start)
click to toggle source
# File lib/magnesium/support/config.rb, line 255 def self.set_mail_start(start) begin file_path = File.expand_path("../../config.xml",__FILE__) modify_attribute(file_path,"config/optional/mail","isstart",start) rescue error #ensure end end
set_mail_to_account(value)
click to toggle source
# File lib/magnesium/support/config.rb, line 275 def self.set_mail_to_account(value) begin file_path = File.expand_path("../../config.xml",__FILE__) modify_attribute(file_path,"config/optional/mail","toaccount",value) rescue error #ensure end end
set_performance_result_path(path)
click to toggle source
# File lib/magnesium/support/config.rb, line 317 def self.set_performance_result_path(path) begin file_path = File.expand_path("../../config.xml",__FILE__) modify_attribute(file_path,"config/optional/performance","path",path) rescue error #ensure end end
set_performance_start(start)
click to toggle source
performance
# File lib/magnesium/support/config.rb, line 307 def self.set_performance_start(start) begin file_path = File.expand_path("../../config.xml",__FILE__) modify_attribute(file_path,"config/optional/performance","isstart",start) rescue error #ensure end end
set_screenshot_result_path(path)
click to toggle source
# File lib/magnesium/support/config.rb, line 296 def self.set_screenshot_result_path(path) begin file_path = File.expand_path("../../config.xml",__FILE__) modify_attribute(file_path,"config/optional/screenshot","path",path) rescue error #ensure end end
set_screenshot_start(start)
click to toggle source
screenshot
# File lib/magnesium/support/config.rb, line 286 def self.set_screenshot_start(start) begin file_path = File.expand_path("../../config.xml",__FILE__) modify_attribute(file_path,"config/optional/screenshot","isstart",start) rescue error #ensure end end
set_temp_path(path)
click to toggle source
temp
# File lib/magnesium/support/config.rb, line 233 def self.set_temp_path(path) begin file_path = File.expand_path("../../config.xml",__FILE__) modify_attribute(file_path,"config/basic/temp","path",path) rescue error #ensure end end
set_testlink_database(database)
click to toggle source
# File lib/magnesium/support/config.rb, line 212 def self.set_testlink_database(database) begin file_path = File.expand_path("../../config.xml",__FILE__) modify_attribute(file_path,"config/basic/testlink","database",database) rescue error #ensure end end
set_testlink_db_account(username)
click to toggle source
# File lib/magnesium/support/config.rb, line 181 def self.set_testlink_db_account(username) begin file_path = File.expand_path("../../config.xml",__FILE_) modify_attribute(file_path,"config/basic/testlink","db_account",username) rescue error #ensure end end
set_testlink_db_pwd(password)
click to toggle source
# File lib/magnesium/support/config.rb, line 201 def self.set_testlink_db_pwd(password) begin file_path = File.expand_path("../../config.xml",__FILE__) modify_attribute(file_path,"config/basic/testlink","db_pwd",password) rescue error #ensure end end
set_testlink_host(host)
click to toggle source
testlink modify
# File lib/magnesium/support/config.rb, line 161 def self.set_testlink_host(host) begin file_path = File.expand_path("../../config.xml",__FILE__) modify_attribute(file_path,"config/basic/testlink","host",host) rescue error #ensure end end
set_testlink_host_account(username)
click to toggle source
# File lib/magnesium/support/config.rb, line 171 def self.set_testlink_host_account(username) begin file_path = File.expand_path("../../config.xml",__FILE_) modify_attribute(file_path,"config/basic/testlink","host_account",username) rescue error #ensure end end
set_testlink_host_pwd(password)
click to toggle source
# File lib/magnesium/support/config.rb, line 191 def self.set_testlink_host_pwd(password) begin file_path = File.expand_path("../../config.xml",__FILE__) modify_attribute(file_path,"config/basic/testlink","host_pwd",password) rescue error #ensure end end
set_testlink_install_path(path)
click to toggle source
# File lib/magnesium/support/config.rb, line 222 def self.set_testlink_install_path(path) begin file_path = File.expand_path("../../config.xml",__FILE__) modify_attribute(file_path,"config/basic/testlink","install_path",path) rescue error #ensure end end
set_wait_start(start)
click to toggle source
# File lib/magnesium/support/config.rb, line 327 def self.set_wait_start(start) begin file_path = File.expand_path("../../config.xml",__FILE__) modify_attribute(file_path,"config/optional/wait","isstart",start) rescue error #ensure end end
set_wait_value(value)
click to toggle source
# File lib/magnesium/support/config.rb, line 337 def self.set_wait_value(value) begin file_path = File.expand_path("../../config.xml",__FILE__) modify_attribute(file_path,"config/optional/wait","value",value) rescue error #ensure end end
show()
click to toggle source
# File lib/magnesium/support/config.rb, line 348 def self.show begin file_path = File.expand_path("../../config.xml",__FILE__) file = openXML(file_path) puts 'M: Let\'s review the config file.' puts '............................................................' puts file rescue error #ensure end end