Class: Zander::Sites
- Inherits:
-
Object
- Object
- Zander::Sites
- Defined in:
- lib/zander/sites.rb
Constant Summary collapse
- IMPLICIT_WAIT =
10
- YAML_URL =
'URL'
- YAML_ACTIONS =
'ACTIONS'
- LOG_FILE =
‘log.txt’
STDOUT
Instance Attribute Summary collapse
-
#sites ⇒ Object
readonly
Returns the value of attribute sites.
Instance Method Summary collapse
- #add_actions(yaml_file) ⇒ Object
- #get_abbr_to_s ⇒ Object
- #get_site(url) ⇒ Object
-
#initialize(yaml_file, steps = nil) ⇒ Sites
constructor
A new instance of Sites.
- #set_log_level(level) ⇒ Object
Constructor Details
#initialize(yaml_file, steps = nil) ⇒ Sites
Returns a new instance of Sites.
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 |
# File 'lib/zander/sites.rb', line 10 def initialize(yaml_file, steps = nil) @sites_yaml_file = yaml_file @log = Logger.new(LOG_FILE,10,1024000) @log.level = Logger::DEBUG @sites = Array.new ### FIREFOX PROFILE profile = Selenium::WebDriver::Firefox::Profile.new profile['browser.download.dir'] = '/Users/sc/Desktop/appeals/HCFA_AND_POTF' profile['browser.download.folderList'] = 2 profile['browser.helperApps.neverAsk.saveToDisk'] = "application/pdf" profile['browser.download.alertOnEXEOpen'] = false profile['browser.download.manager.showWhenStarting'] = false profile['browser.download.manager.focusWhenStarting'] = false profile['browser.helperApps.alwaysAsk.force'] = false profile['browser.download.manager.alertOnEXEOpen'] = false profile['browser.download.manager.closeWhenDone'] = false profile['browser.download.manager.showAlertOnComplete'] = false profile['browser.download.manager.useWindow'] = false profile['browser.download.manager.showWhenStarting'] = false profile['services.sync.prefs.sync.browser.download.manager.showWhenStarting'] = false profile['pdfjs.disabled'] = true ## END FIREFOX PROFILE @driver = Selenium::WebDriver.for :firefox, :profile => profile @driver.manage.timeouts.implicit_wait = IMPLICIT_WAIT @log.debug("Selenium timeouts set to #{IMPLICIT_WAIT} seconds") yaml = YAML::load(File.read(@sites_yaml_file)) if yaml.has_key? 'WEBSITES' yaml['WEBSITES'].each_with_index do |site, index| if steps == nil @log.debug("Create Site #{site}") @sites.push(Site.new(parent: self, hash: site, driver: @driver, log: @log)) else if steps.include?(index) @log.debug("Create Site #{site}") @sites.push(Site.new(parent: self, hash: site, driver: @driver, log: @log)) end end end end end |
Instance Attribute Details
#sites ⇒ Object (readonly)
Returns the value of attribute sites.
8 9 10 |
# File 'lib/zander/sites.rb', line 8 def sites @sites end |
Instance Method Details
#add_actions(yaml_file) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/zander/sites.rb', line 67 def add_actions(yaml_file) yaml = YAML::load(File.read(yaml_file)) if yaml.has_key? 'WEBSITES' yaml['WEBSITES'].each do |website| if website.has_key?(YAML_URL) && website.has_key?(YAML_ACTIONS) site = self.get_site(website[YAML_URL]) if site != nil @log.debug("Add #{website[YAML_ACTIONS]}") site.add_actions(website[YAML_ACTIONS]) else @log.error("Error:: '#{website[YAML_URL]}' in #{yaml_file} was not in #{@sites_yaml_file}") end else @log.error("#{yaml_file} doesn't contain a #{YAML_URL} array") end end else @log.error("#{yaml_file} doesn't contain a WEBSITES array") end end |
#get_abbr_to_s ⇒ Object
63 64 65 |
# File 'lib/zander/sites.rb', line 63 def get_abbr_to_s "<#{self.class.name}:0x#{'%x'%(self.object_id<<1)} ...>" end |
#get_site(url) ⇒ Object
56 57 58 59 60 61 |
# File 'lib/zander/sites.rb', line 56 def get_site(url) @sites.each do |site| return site if site.url == url end nil end |
#set_log_level(level) ⇒ Object
52 53 54 |
# File 'lib/zander/sites.rb', line 52 def set_log_level(level) @log.level = level end |