Class: Configuration
- Inherits:
-
Object
- Object
- Configuration
- Defined in:
- lib/config.rb
Instance Attribute Summary collapse
-
#bad_links ⇒ Object
Returns the value of attribute bad_links.
-
#DESKTOP ⇒ Object
Returns the value of attribute DESKTOP.
-
#ignored ⇒ Object
Returns the value of attribute ignored.
-
#IMAGE_THRESHOLD ⇒ Object
readonly
Returns the value of attribute IMAGE_THRESHOLD.
-
#LOGGED_IN ⇒ Object
Returns the value of attribute LOGGED_IN.
-
#LOGIN ⇒ Object
readonly
Returns the value of attribute LOGIN.
-
#LOGIN_CONFIRM ⇒ Object
readonly
Returns the value of attribute LOGIN_CONFIRM.
-
#LOGIN_CONFIRM_CHECK ⇒ Object
readonly
Returns the value of attribute LOGIN_CONFIRM_CHECK.
-
#LOGIN_URI ⇒ Object
readonly
Returns the value of attribute LOGIN_URI.
-
#PASS_DOM_ID ⇒ Object
readonly
Returns the value of attribute PASS_DOM_ID.
-
#PASS_VALUE ⇒ Object
readonly
Returns the value of attribute PASS_VALUE.
-
#prod ⇒ Object
Returns the value of attribute prod.
-
#scraped ⇒ Object
Returns the value of attribute scraped.
-
#SCREEN_RESOLUTION ⇒ Object
readonly
Returns the value of attribute SCREEN_RESOLUTION.
-
#stage ⇒ Object
Returns the value of attribute stage.
-
#to_be_scraped ⇒ Object
Returns the value of attribute to_be_scraped.
-
#URI_THRESHOLD ⇒ Object
readonly
Returns the value of attribute URI_THRESHOLD.
-
#USER_DOM_ID ⇒ Object
readonly
Returns the value of attribute USER_DOM_ID.
-
#USER_VALUE ⇒ Object
readonly
Returns the value of attribute USER_VALUE.
Instance Method Summary collapse
- #all_good? ⇒ Boolean
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# 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 |
Instance Attribute Details
#bad_links ⇒ Object
Returns the value of attribute bad_links.
7 8 9 |
# File 'lib/config.rb', line 7 def bad_links @bad_links end |
#DESKTOP ⇒ Object
Returns the value of attribute DESKTOP.
6 7 8 |
# File 'lib/config.rb', line 6 def DESKTOP @DESKTOP end |
#ignored ⇒ Object
Returns the value of attribute ignored.
6 7 8 |
# File 'lib/config.rb', line 6 def ignored @ignored end |
#IMAGE_THRESHOLD ⇒ Object (readonly)
Returns the value of attribute IMAGE_THRESHOLD.
11 12 13 |
# File 'lib/config.rb', line 11 def IMAGE_THRESHOLD @IMAGE_THRESHOLD end |
#LOGGED_IN ⇒ Object
Returns the value of attribute LOGGED_IN.
7 8 9 |
# File 'lib/config.rb', line 7 def LOGGED_IN @LOGGED_IN end |
#LOGIN ⇒ Object (readonly)
Returns the value of attribute LOGIN.
10 11 12 |
# File 'lib/config.rb', line 10 def LOGIN @LOGIN end |
#LOGIN_CONFIRM ⇒ Object (readonly)
Returns the value of attribute LOGIN_CONFIRM.
10 11 12 |
# File 'lib/config.rb', line 10 def LOGIN_CONFIRM @LOGIN_CONFIRM end |
#LOGIN_CONFIRM_CHECK ⇒ Object (readonly)
Returns the value of attribute LOGIN_CONFIRM_CHECK.
10 11 12 |
# File 'lib/config.rb', line 10 def LOGIN_CONFIRM_CHECK @LOGIN_CONFIRM_CHECK end |
#LOGIN_URI ⇒ Object (readonly)
Returns the value of attribute LOGIN_URI.
8 9 10 |
# File 'lib/config.rb', line 8 def LOGIN_URI @LOGIN_URI end |
#PASS_DOM_ID ⇒ Object (readonly)
Returns the value of attribute PASS_DOM_ID.
9 10 11 |
# File 'lib/config.rb', line 9 def PASS_DOM_ID @PASS_DOM_ID end |
#PASS_VALUE ⇒ Object (readonly)
Returns the value of attribute PASS_VALUE.
9 10 11 |
# File 'lib/config.rb', line 9 def PASS_VALUE @PASS_VALUE end |
#prod ⇒ Object
Returns the value of attribute prod.
6 7 8 |
# File 'lib/config.rb', line 6 def prod @prod end |
#scraped ⇒ Object
Returns the value of attribute scraped.
7 8 9 |
# File 'lib/config.rb', line 7 def scraped @scraped end |
#SCREEN_RESOLUTION ⇒ Object (readonly)
Returns the value of attribute SCREEN_RESOLUTION.
12 13 14 |
# File 'lib/config.rb', line 12 def SCREEN_RESOLUTION @SCREEN_RESOLUTION end |
#stage ⇒ Object
Returns the value of attribute stage.
6 7 8 |
# File 'lib/config.rb', line 6 def stage @stage end |
#to_be_scraped ⇒ Object
Returns the value of attribute to_be_scraped.
6 7 8 |
# File 'lib/config.rb', line 6 def to_be_scraped @to_be_scraped end |
#URI_THRESHOLD ⇒ Object (readonly)
Returns the value of attribute URI_THRESHOLD.
11 12 13 |
# File 'lib/config.rb', line 11 def URI_THRESHOLD @URI_THRESHOLD end |
#USER_DOM_ID ⇒ Object (readonly)
Returns the value of attribute USER_DOM_ID.
8 9 10 |
# File 'lib/config.rb', line 8 def USER_DOM_ID @USER_DOM_ID end |
#USER_VALUE ⇒ Object (readonly)
Returns the value of attribute USER_VALUE.
8 9 10 |
# File 'lib/config.rb', line 8 def USER_VALUE @USER_VALUE end |
Instance Method Details
#all_good? ⇒ Boolean
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 |
# 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 |