class KleosTest::LinksCollector

Public Class Methods

new() click to toggle source
# File lib/kleos_test/links_collector.rb, line 9
def initialize
  @target = get_target_link
end

Public Instance Methods

download_inside_webpage() click to toggle source
# File lib/kleos_test/links_collector.rb, line 41
 def download_inside_webpage
   address = @target.include?('http') ? @target : KleosTest.base_address + @target
   @@inside_downloads += 1
   print "Downloading (#{@@inside_downloads}|#{@@unverified_inside_links.size})\
#{URI::decode(address)}..."
   response = RestClient.get(address)
   puts "OK"
   [response.body, response.code]
 rescue RestClient::ExceptionWithResponse => e
   puts "ERROR"
   [e.response.body, e.response.code]
 rescue URI::InvalidURIError
   puts "ERROR"
   puts "BAD URI"
   ['fake body', 1]
 rescue
   puts "UNKNOWN ERROR"
   ['fake body', 1]
 end
download_outside_webpage(address, counter) click to toggle source
# File lib/kleos_test/links_collector.rb, line 61
 def download_outside_webpage(address, counter)
   print "Downloading (#{counter}|#{@@unverified_outside_links.size - counter})\
#{URI::decode(address)}..."
   response = RestClient.get(address)
   puts "OK"
   response.code
 rescue RestClient::ExceptionWithResponse => e
   puts "ERROR"
   e.response.code
 rescue URI::InvalidURIError
   puts "ERROR"
   puts "BAD URI"
   1
 rescue
   puts "UNKNOWN ERROR"
   1
 end