class Configuration

Attributes

DESKTOP[RW]
IMAGE_THRESHOLD[R]
LOGGED_IN[RW]
LOGIN[R]
LOGIN_CONFIRM[R]
LOGIN_CONFIRM_CHECK[R]
LOGIN_URI[R]
PASS_DOM_ID[R]
PASS_VALUE[R]
SCREEN_RESOLUTION[R]
URI_THRESHOLD[R]
USER_DOM_ID[R]
USER_VALUE[R]
ignored[RW]
prod[RW]
scraped[RW]
stage[RW]
to_be_scraped[RW]

Public Class Methods

new() click to toggle source
# File lib/config.rb, line 14
def initialize
        @stage = ""
        @prod  = ""
        @ignored = ["ignore_me", "not_important_url_prefix",".css", ".pdf", ".js", ".jpg", ".png", "video/pop", "user/logout", "?", "=", "#"]
        @SCREEN_RESOLUTION = {:desktop => [1400,800], :iPadAir => [1024,768], :iphone6 => [375,667]}
        @IMAGE_THRESHOLD = 0
        @LOGIN = true
        @LOGIN_URI = 'user/login' # http://example.com/login
        @USER_DOM_ID = 'edit-name'
        @USER_VALUE = 'melchisalins'
        @PASS_DOM_ID = 'edit-pass'
        @PASS_VALUE = 'secret_password'
        @LOGIN_CONFIRM = false
        @LOGIN_CONFIRM_CHECK = 'homepage-onsite-team'
        @bad_links = []
        @to_be_scraped = []
        @scraped = []
        @LOGGED_IN = false
end

Public Instance Methods

all_good?() click to toggle source
# File lib/config.rb, line 34
def all_good?
        begin
                # Fixes scheme of the URL if not present. This is needed by Selenium
                return_value = false
                if @stage.length <= 0 && @prod.length <= 0
                        puts "Stage and Production URL missing."
                        return_value = false
                        return return_value
                else
                        @stage = fix_scheme(@stage) if URI.parse(@stage).scheme == nil
                        @prod  = fix_scheme(@prod)  if URI.parse(@prod).scheme == nil
                        return_value = true
                end

                if @LOGIN && @LOGIN_URI.nil? == false && @USER_DOM_ID.nil? == false && @USER_VALUE.nil? == false && @PASS_DOM_ID.nil? == false && @PASS_VALUE.nil? == false
                        return_value = true
                else
                        puts "Please configure LOGIN parameters"
                        return_value = false
                        return return_value
                end

                if @LOGIN_CONFIRM && @LOGIN_CONFIRM_CHECK
                        return_value = true
                elsif @LOGIN_CONFIRM == false
                        return_value = true
                else
                        puts "Please configure LOGIN_CONFIRM_CHECK value"
                        return_value = false
                        return return_value
                end

                return return_value
        rescue Exception => e
                puts e
                return false
        end
end