Class: Magnesium::Config
- Inherits:
-
Object
- Object
- Magnesium::Config
- Defined in:
- lib/magnesium/support/config.rb
Class Method Summary collapse
-
.check_config ⇒ Object
check config.
- .config ⇒ Object
-
.set_browser(value, proxy) ⇒ Object
browser modify.
-
.set_log_path(path) ⇒ Object
log.
- .set_mail_from_account(value) ⇒ Object
-
.set_mail_start(start) ⇒ Object
mail.
- .set_mail_to_account(value) ⇒ Object
- .set_performance_result_path(path) ⇒ Object
-
.set_performance_start(start) ⇒ Object
performance.
- .set_screenshot_result_path(path) ⇒ Object
-
.set_screenshot_start(start) ⇒ Object
screenshot.
-
.set_temp_path(path) ⇒ Object
temp.
- .set_testlink_database(database) ⇒ Object
- .set_testlink_db_account(username) ⇒ Object
- .set_testlink_db_pwd(password) ⇒ Object
-
.set_testlink_host(host) ⇒ Object
testlink modify.
- .set_testlink_host_account(username) ⇒ Object
- .set_testlink_host_pwd(password) ⇒ Object
- .set_testlink_install_path(path) ⇒ Object
- .set_wait_start(start) ⇒ Object
- .set_wait_value(value) ⇒ Object
- .show ⇒ Object
Class Method Details
.check_config ⇒ Object
check config
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# 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 ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/magnesium/support/config.rb', line 10 def self.config() begin file_path = File.("../../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) ⇒ Object
browser modify
129 130 131 132 133 |
# File 'lib/magnesium/support/config.rb', line 129 def self.set_browser(value,proxy) file_path = File.("../../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) ⇒ Object
log
244 245 246 247 248 249 250 251 252 |
# File 'lib/magnesium/support/config.rb', line 244 def self.set_log_path(path) begin file_path = File.("../../config.xml",__FILE__) modify_attribute(@file_path,"config/optional/log","path",path) rescue error #ensure end end |
.set_mail_from_account(value) ⇒ Object
265 266 267 268 269 270 271 272 273 |
# File 'lib/magnesium/support/config.rb', line 265 def self.set_mail_from_account(value) begin file_path = File.("../../config.xml",__FILE__) modify_attribute(file_path,"config/optional/mail","fromaccount",value) rescue error #ensure end end |
.set_mail_start(start) ⇒ Object
255 256 257 258 259 260 261 262 263 |
# File 'lib/magnesium/support/config.rb', line 255 def self.set_mail_start(start) begin file_path = File.("../../config.xml",__FILE__) modify_attribute(file_path,"config/optional/mail","isstart",start) rescue error #ensure end end |
.set_mail_to_account(value) ⇒ Object
275 276 277 278 279 280 281 282 283 |
# File 'lib/magnesium/support/config.rb', line 275 def self.set_mail_to_account(value) begin file_path = File.("../../config.xml",__FILE__) modify_attribute(file_path,"config/optional/mail","toaccount",value) rescue error #ensure end end |
.set_performance_result_path(path) ⇒ Object
317 318 319 320 321 322 323 324 325 |
# File 'lib/magnesium/support/config.rb', line 317 def self.set_performance_result_path(path) begin file_path = File.("../../config.xml",__FILE__) modify_attribute(file_path,"config/optional/performance","path",path) rescue error #ensure end end |
.set_performance_start(start) ⇒ Object
performance
307 308 309 310 311 312 313 314 315 |
# File 'lib/magnesium/support/config.rb', line 307 def self.set_performance_start(start) begin file_path = File.("../../config.xml",__FILE__) modify_attribute(file_path,"config/optional/performance","isstart",start) rescue error #ensure end end |
.set_screenshot_result_path(path) ⇒ Object
296 297 298 299 300 301 302 303 304 |
# File 'lib/magnesium/support/config.rb', line 296 def self.set_screenshot_result_path(path) begin file_path = File.("../../config.xml",__FILE__) modify_attribute(file_path,"config/optional/screenshot","path",path) rescue error #ensure end end |
.set_screenshot_start(start) ⇒ Object
screenshot
286 287 288 289 290 291 292 293 294 |
# File 'lib/magnesium/support/config.rb', line 286 def self.set_screenshot_start(start) begin file_path = File.("../../config.xml",__FILE__) modify_attribute(file_path,"config/optional/screenshot","isstart",start) rescue error #ensure end end |
.set_temp_path(path) ⇒ Object
temp
233 234 235 236 237 238 239 240 241 |
# File 'lib/magnesium/support/config.rb', line 233 def self.set_temp_path(path) begin file_path = File.("../../config.xml",__FILE__) modify_attribute(file_path,"config/basic/temp","path",path) rescue error #ensure end end |
.set_testlink_database(database) ⇒ Object
212 213 214 215 216 217 218 219 220 |
# File 'lib/magnesium/support/config.rb', line 212 def self.set_testlink_database(database) begin file_path = File.("../../config.xml",__FILE__) modify_attribute(file_path,"config/basic/testlink","database",database) rescue error #ensure end end |
.set_testlink_db_account(username) ⇒ Object
181 182 183 184 185 186 187 188 189 |
# File 'lib/magnesium/support/config.rb', line 181 def self.set_testlink_db_account(username) begin file_path = File.("../../config.xml",__FILE_) modify_attribute(file_path,"config/basic/testlink","db_account",username) rescue error #ensure end end |
.set_testlink_db_pwd(password) ⇒ Object
201 202 203 204 205 206 207 208 209 |
# File 'lib/magnesium/support/config.rb', line 201 def self.set_testlink_db_pwd(password) begin file_path = File.("../../config.xml",__FILE__) modify_attribute(file_path,"config/basic/testlink","db_pwd",password) rescue error #ensure end end |
.set_testlink_host(host) ⇒ Object
testlink modify
161 162 163 164 165 166 167 168 169 |
# File 'lib/magnesium/support/config.rb', line 161 def self.set_testlink_host(host) begin file_path = File.("../../config.xml",__FILE__) modify_attribute(file_path,"config/basic/testlink","host",host) rescue error #ensure end end |
.set_testlink_host_account(username) ⇒ Object
171 172 173 174 175 176 177 178 179 |
# File 'lib/magnesium/support/config.rb', line 171 def self.set_testlink_host_account(username) begin file_path = File.("../../config.xml",__FILE_) modify_attribute(file_path,"config/basic/testlink","host_account",username) rescue error #ensure end end |
.set_testlink_host_pwd(password) ⇒ Object
191 192 193 194 195 196 197 198 199 |
# File 'lib/magnesium/support/config.rb', line 191 def self.set_testlink_host_pwd(password) begin file_path = File.("../../config.xml",__FILE__) modify_attribute(file_path,"config/basic/testlink","host_pwd",password) rescue error #ensure end end |
.set_testlink_install_path(path) ⇒ Object
222 223 224 225 226 227 228 229 230 |
# File 'lib/magnesium/support/config.rb', line 222 def self.set_testlink_install_path(path) begin file_path = File.("../../config.xml",__FILE__) modify_attribute(file_path,"config/basic/testlink","install_path",path) rescue error #ensure end end |
.set_wait_start(start) ⇒ Object
327 328 329 330 331 332 333 334 335 |
# File 'lib/magnesium/support/config.rb', line 327 def self.set_wait_start(start) begin file_path = File.("../../config.xml",__FILE__) modify_attribute(file_path,"config/optional/wait","isstart",start) rescue error #ensure end end |
.set_wait_value(value) ⇒ Object
337 338 339 340 341 342 343 344 345 346 |
# File 'lib/magnesium/support/config.rb', line 337 def self.set_wait_value(value) begin file_path = File.("../../config.xml",__FILE__) modify_attribute(file_path,"config/optional/wait","value",value) rescue error #ensure end end |
.show ⇒ Object
348 349 350 351 352 353 354 355 356 357 358 359 |
# File 'lib/magnesium/support/config.rb', line 348 def self.show begin file_path = File.("../../config.xml",__FILE__) file = openXML(file_path) puts 'M: Let\'s review the config file.' puts '............................................................' puts file rescue error #ensure end end |