Class: Kontrast::Configuration
- Inherits:
-
Object
- Object
- Kontrast::Configuration
- Defined in:
- lib/kontrast/configuration.rb
Instance Attribute Summary collapse
-
#_after_gallery ⇒ Object
Returns the value of attribute _after_gallery.
-
#_after_run ⇒ Object
Returns the value of attribute _after_run.
-
#_after_screenshot ⇒ Object
Returns the value of attribute _after_screenshot.
-
#_before_gallery ⇒ Object
Returns the value of attribute _before_gallery.
-
#_before_run ⇒ Object
Returns the value of attribute _before_run.
-
#_before_screenshot ⇒ Object
Returns the value of attribute _before_screenshot.
-
#aws_bucket ⇒ Object
Returns the value of attribute aws_bucket.
-
#aws_key ⇒ Object
Returns the value of attribute aws_key.
-
#aws_secret ⇒ Object
Returns the value of attribute aws_secret.
-
#browser_driver ⇒ Object
Returns the value of attribute browser_driver.
-
#browser_profile ⇒ Object
Returns the value of attribute browser_profile.
-
#current_node ⇒ Object
Returns the value of attribute current_node.
-
#distortion_metric ⇒ Object
Returns the value of attribute distortion_metric.
-
#fail_build ⇒ Object
Returns the value of attribute fail_build.
-
#highlight_color ⇒ Object
Returns the value of attribute highlight_color.
-
#local_path ⇒ Object
Returns the value of attribute local_path.
-
#lowlight_color ⇒ Object
Returns the value of attribute lowlight_color.
-
#oauth_token_from_response ⇒ Object
Returns the value of attribute oauth_token_from_response.
-
#oauth_token_url ⇒ Object
Returns the value of attribute oauth_token_url.
-
#production_domain ⇒ Object
Returns the value of attribute production_domain.
-
#production_oauth_app_secret ⇒ Object
Returns the value of attribute production_oauth_app_secret.
-
#production_oauth_app_uid ⇒ Object
Returns the value of attribute production_oauth_app_uid.
-
#remote_path ⇒ Object
Returns the value of attribute remote_path.
-
#run_parallel ⇒ Object
Returns the value of attribute run_parallel.
-
#test_domain ⇒ Object
Returns the value of attribute test_domain.
-
#test_oauth_app_proc ⇒ Object
Returns the value of attribute test_oauth_app_proc.
-
#test_oauth_app_secret ⇒ Object
Returns the value of attribute test_oauth_app_secret.
-
#test_oauth_app_uid ⇒ Object
Returns the value of attribute test_oauth_app_uid.
-
#total_nodes ⇒ Object
Returns the value of attribute total_nodes.
-
#workers_pool_size ⇒ Object
Returns the value of attribute workers_pool_size.
Instance Method Summary collapse
- #after_gallery(diffs = nil, gallery = nil, &block) ⇒ Object
- #after_run(&block) ⇒ Object
- #after_screenshot(test_driver = nil, production_driver = nil, current_test = nil, &block) ⇒ Object
- #api_endpoints(group_name) {|Kontrast.api_endpoint_test_builder| ... } ⇒ Object
- #before_gallery(&block) ⇒ Object
- #before_run(&block) ⇒ Object
- #before_screenshot(test_driver = nil, production_driver = nil, current_test = nil, &block) ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #pages(width, url_params = {}) {|Kontrast.page_test_builder| ... } ⇒ Object
- #validate ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/kontrast/configuration.rb', line 40 def initialize # Set defaults @browser_driver = "firefox" @browser_profile = {} @run_parallel = false @total_nodes = 1 @current_node = 0 @distortion_metric = "MeanAbsoluteErrorMetric" @highlight_color = "blue" @lowlight_color = "rgba(255, 255, 255, 0.3)" @fail_build = false end |
Instance Attribute Details
#_after_gallery ⇒ Object
Returns the value of attribute _after_gallery.
29 30 31 |
# File 'lib/kontrast/configuration.rb', line 29 def _after_gallery @_after_gallery end |
#_after_run ⇒ Object
Returns the value of attribute _after_run.
29 30 31 |
# File 'lib/kontrast/configuration.rb', line 29 def _after_run @_after_run end |
#_after_screenshot ⇒ Object
Returns the value of attribute _after_screenshot.
29 30 31 |
# File 'lib/kontrast/configuration.rb', line 29 def _after_screenshot @_after_screenshot end |
#_before_gallery ⇒ Object
Returns the value of attribute _before_gallery.
29 30 31 |
# File 'lib/kontrast/configuration.rb', line 29 def _before_gallery @_before_gallery end |
#_before_run ⇒ Object
Returns the value of attribute _before_run.
29 30 31 |
# File 'lib/kontrast/configuration.rb', line 29 def _before_run @_before_run end |
#_before_screenshot ⇒ Object
Returns the value of attribute _before_screenshot.
29 30 31 |
# File 'lib/kontrast/configuration.rb', line 29 def _before_screenshot @_before_screenshot end |
#aws_bucket ⇒ Object
Returns the value of attribute aws_bucket.
31 32 33 |
# File 'lib/kontrast/configuration.rb', line 31 def aws_bucket @aws_bucket end |
#aws_key ⇒ Object
Returns the value of attribute aws_key.
31 32 33 |
# File 'lib/kontrast/configuration.rb', line 31 def aws_key @aws_key end |
#aws_secret ⇒ Object
Returns the value of attribute aws_secret.
31 32 33 |
# File 'lib/kontrast/configuration.rb', line 31 def aws_secret @aws_secret end |
#browser_driver ⇒ Object
Returns the value of attribute browser_driver.
33 34 35 |
# File 'lib/kontrast/configuration.rb', line 33 def browser_driver @browser_driver end |
#browser_profile ⇒ Object
Returns the value of attribute browser_profile.
33 34 35 |
# File 'lib/kontrast/configuration.rb', line 33 def browser_profile @browser_profile end |
#current_node ⇒ Object
Returns the value of attribute current_node.
28 29 30 |
# File 'lib/kontrast/configuration.rb', line 28 def current_node @current_node end |
#distortion_metric ⇒ Object
Returns the value of attribute distortion_metric.
30 31 32 |
# File 'lib/kontrast/configuration.rb', line 30 def distortion_metric @distortion_metric end |
#fail_build ⇒ Object
Returns the value of attribute fail_build.
34 35 36 |
# File 'lib/kontrast/configuration.rb', line 34 def fail_build @fail_build end |
#highlight_color ⇒ Object
Returns the value of attribute highlight_color.
30 31 32 |
# File 'lib/kontrast/configuration.rb', line 30 def highlight_color @highlight_color end |
#local_path ⇒ Object
Returns the value of attribute local_path.
31 32 33 |
# File 'lib/kontrast/configuration.rb', line 31 def local_path @local_path end |
#lowlight_color ⇒ Object
Returns the value of attribute lowlight_color.
30 31 32 |
# File 'lib/kontrast/configuration.rb', line 30 def lowlight_color @lowlight_color end |
#oauth_token_from_response ⇒ Object
Returns the value of attribute oauth_token_from_response.
36 37 38 |
# File 'lib/kontrast/configuration.rb', line 36 def oauth_token_from_response @oauth_token_from_response end |
#oauth_token_url ⇒ Object
Returns the value of attribute oauth_token_url.
36 37 38 |
# File 'lib/kontrast/configuration.rb', line 36 def oauth_token_url @oauth_token_url end |
#production_domain ⇒ Object
Returns the value of attribute production_domain.
32 33 34 |
# File 'lib/kontrast/configuration.rb', line 32 def production_domain @production_domain end |
#production_oauth_app_secret ⇒ Object
Returns the value of attribute production_oauth_app_secret.
36 37 38 |
# File 'lib/kontrast/configuration.rb', line 36 def production_oauth_app_secret @production_oauth_app_secret end |
#production_oauth_app_uid ⇒ Object
Returns the value of attribute production_oauth_app_uid.
36 37 38 |
# File 'lib/kontrast/configuration.rb', line 36 def production_oauth_app_uid @production_oauth_app_uid end |
#remote_path ⇒ Object
Returns the value of attribute remote_path.
31 32 33 |
# File 'lib/kontrast/configuration.rb', line 31 def remote_path @remote_path end |
#run_parallel ⇒ Object
Returns the value of attribute run_parallel.
28 29 30 |
# File 'lib/kontrast/configuration.rb', line 28 def run_parallel @run_parallel end |
#test_domain ⇒ Object
Returns the value of attribute test_domain.
32 33 34 |
# File 'lib/kontrast/configuration.rb', line 32 def test_domain @test_domain end |
#test_oauth_app_proc ⇒ Object
Returns the value of attribute test_oauth_app_proc.
36 37 38 |
# File 'lib/kontrast/configuration.rb', line 36 def test_oauth_app_proc @test_oauth_app_proc end |
#test_oauth_app_secret ⇒ Object
Returns the value of attribute test_oauth_app_secret.
36 37 38 |
# File 'lib/kontrast/configuration.rb', line 36 def test_oauth_app_secret @test_oauth_app_secret end |
#test_oauth_app_uid ⇒ Object
Returns the value of attribute test_oauth_app_uid.
36 37 38 |
# File 'lib/kontrast/configuration.rb', line 36 def test_oauth_app_uid @test_oauth_app_uid end |
#total_nodes ⇒ Object
Returns the value of attribute total_nodes.
28 29 30 |
# File 'lib/kontrast/configuration.rb', line 28 def total_nodes @total_nodes end |
#workers_pool_size ⇒ Object
Returns the value of attribute workers_pool_size.
35 36 37 |
# File 'lib/kontrast/configuration.rb', line 35 def workers_pool_size @workers_pool_size end |
Instance Method Details
#after_gallery(diffs = nil, gallery = nil, &block) ⇒ Object
116 117 118 119 120 121 122 |
# File 'lib/kontrast/configuration.rb', line 116 def after_gallery(diffs = nil, gallery = nil, &block) if block_given? @_after_gallery = block else @_after_gallery.call(diffs, gallery) if @_after_gallery end end |
#after_run(&block) ⇒ Object
100 101 102 103 104 105 106 |
# File 'lib/kontrast/configuration.rb', line 100 def after_run(&block) if block_given? @_after_run = block else @_after_run.call if @_after_run end end |
#after_screenshot(test_driver = nil, production_driver = nil, current_test = nil, &block) ⇒ Object
132 133 134 135 136 137 138 |
# File 'lib/kontrast/configuration.rb', line 132 def after_screenshot(test_driver = nil, production_driver = nil, current_test = nil, &block) if block_given? @_after_screenshot = block else @_after_screenshot.call(test_driver, production_driver, current_test) if @_after_screenshot end end |
#api_endpoints(group_name) {|Kontrast.api_endpoint_test_builder| ... } ⇒ Object
84 85 86 87 88 89 90 |
# File 'lib/kontrast/configuration.rb', line 84 def api_endpoints(group_name) if !block_given? raise ConfigurationException.new("You must pass a block to the api_endpoints config option.") end Kontrast.api_endpoint_test_builder.prefix = group_name yield(Kontrast.api_endpoint_test_builder) end |
#before_gallery(&block) ⇒ Object
108 109 110 111 112 113 114 |
# File 'lib/kontrast/configuration.rb', line 108 def before_gallery(&block) if block_given? @_before_gallery = block else @_before_gallery.call if @_before_gallery end end |
#before_run(&block) ⇒ Object
92 93 94 95 96 97 98 |
# File 'lib/kontrast/configuration.rb', line 92 def before_run(&block) if block_given? @_before_run = block else @_before_run.call if @_before_run end end |
#before_screenshot(test_driver = nil, production_driver = nil, current_test = nil, &block) ⇒ Object
124 125 126 127 128 129 130 |
# File 'lib/kontrast/configuration.rb', line 124 def before_screenshot(test_driver = nil, production_driver = nil, current_test = nil, &block) if block_given? @_before_screenshot = block else @_before_screenshot.call(test_driver, production_driver, current_test) if @_before_screenshot end end |
#pages(width, url_params = {}) {|Kontrast.page_test_builder| ... } ⇒ Object
75 76 77 78 79 80 81 82 |
# File 'lib/kontrast/configuration.rb', line 75 def pages(width, url_params = {}) if !block_given? raise ConfigurationException.new("You must pass a block to the pages config option.") end Kontrast.page_test_builder.prefix = width Kontrast.page_test_builder.url_params = url_params yield(Kontrast.page_test_builder) end |
#validate ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/kontrast/configuration.rb', line 56 def validate # Check that Kontrast has everything it needs to proceed check_nil_vars(["test_domain", "production_domain"]) if Kontrast.page_test_suite.nil? && Kontrast.api_endpoint_test_suite.nil? raise ConfigurationException.new("Kontrast has no tests to run.") end # If remote, check for more options if @run_parallel check_nil_vars(["aws_bucket", "aws_key", "aws_secret"]) check_nil_vars(["local_path", "remote_path"]) # Make sure total nodes is >= 1 so we don't get divide by 0 errors if @total_nodes < 1 raise ConfigurationException.new("total_nodes cannot be less than 1.") end end end |