module ContactPage

Find the contact

Attributes

Public Instance Methods

contact_page(url) click to toggle source

Looks for contact page. Gets page if available. If no contact link is available, it will blind test '../contact'. Returns nil if nothing can be found.

# File lib/gimme_poc/contactpage.rb, line 18
def contact_page(url)
  LogMessages.looking_for_contact_page
  @contact_link = link_with_href(/contact|Contact/)
  contact_test_page = merged_link('../contact')
  case
  when !contact_link.nil?
    LogMessages.found_contact_link
    get(merged_link(@contact_link))
  else
    LogMessages.no_contact_link
    get(orig_domain(url)) if blind_test(contact_test_page).nil?
  end
end
english_contact_page(url) click to toggle source

Looks for english page. Gets page if available then looks for english contact page.

If no english link is available, it will blind test '../en' and '../english'. Returns nil if nothing can be found.

# File lib/gimme_poc/contactpage.rb, line 39
def english_contact_page(url)
  LogMessages.looking_for_english_page
  english_link = @page.link_with(href: %r{en\/|english|English})
  test_en_page = merged_link('../en')
  test_english_page = merged_link('../english')

  case
  when !english_link.nil?
    LogMessages.found_english_link
    get(merged_link(english_link.uri))
  else
    blind_test(test_en_page) || blind_test(test_english_page)
    LogMessages.restarting
    contact_page(url)
  end
end
go_to_contact_page(url) click to toggle source

Scans for contact page. If it doesn't work on the first try, It will look for english versions and try again. Processes left to right.

Returns nil if no contact page can be found.

# File lib/gimme_poc/contactpage.rb, line 10
def go_to_contact_page(url)
  contact_page(url) || english_contact_page(url)
end