Class: Applitools::UniversalEyesConfig

Inherits:
Object
  • Object
show all
Includes:
Jsonable
Defined in:
lib/applitools/universal_sdk/universal_eyes_config.rb

Constant Summary collapse

FROM_ORIGINAL_EYES =

23 + 3 + 2 + 11 = 39

[:api_key, :app_name, :batch, :browsers_info, :concurrent_sessions, :debug_screenshots,
  :force_full_page_screenshot, :hide_caret, :hide_scrollbars, :host_app, :host_os, :match_timeout, :proxy,
  :save_failed_tests, :save_new_tests, :scale_ratio, :send_dom, :server_url, :stitch_mode, :test_name,
  :viewport_size, :visual_grid_options, :wait_before_screenshots, :wait_before_capture] + [
  :disabled?, # disabled? => is_disabled
  :stitching_overlap, # SeleniumEyes.stitching_overlap => stitch_overlap
  :dont_fetch_resources # dont_fetch_resources => disable_browser_fetching
] + [
  :layout_breakpoints,
  :scroll_root_element,
] + [
  :environment_name, :branch_name, :default_match_settings, :properties, :parent_branch_name,
  :compare_with_parent_branch, :baseline_env_name, :save_diffs, :session_type, :baseline_branch_name
]
OTHER =

51 - 39 - 2 = 10

[:logs, :remove_session, :remote_events, :display_name, :host_app_info, :host_os_info, :device_info,
:ignore_baseline, :cut, :rotation ]

Instance Method Summary collapse

Methods included from Jsonable

included, #json, #json_data

Constructor Details

#initialize(*args) ⇒ UniversalEyesConfig

Returns a new instance of UniversalEyesConfig.



151
152
153
154
155
156
157
158
159
160
# File 'lib/applitools/universal_sdk/universal_eyes_config.rb', line 151

def initialize(*args)
  options = Applitools::Utils.extract_options! args
  options.keys.select {|k| options[k] && respond_to?("#{k}=") }.each {|k| send("#{k}=", options[k]) }
  # other
  self.connection_timeout = Applitools::Connectivity::ServerConnector::DEFAULT_TIMEOUT
  if 'true'.casecmp(ENV['APPLITOOLS_DONT_CLOSE_BATCHES'] || '') == 0
    self.dont_close_batches = true
    Applitools::EyesLogger.info('APPLITOOLS_DONT_CLOSE_BATCHES environment variable set to true. Doing nothing.')
  end
end

Instance Method Details

#copy_from(what, from) ⇒ Object



170
171
172
173
174
175
176
# File 'lib/applitools/universal_sdk/universal_eyes_config.rb', line 170

def copy_from(what, from)
  if from.respond_to?(what)
    send("#{what.to_s.chomp('?') }=", from.send(what))
  else
    puts "respond_to? #{what} - fail"
  end
end

#from_original_sdk(original_eyes) ⇒ Object



162
163
164
165
166
167
168
# File 'lib/applitools/universal_sdk/universal_eyes_config.rb', line 162

def from_original_sdk(original_eyes)
  FROM_ORIGINAL_EYES.each {|m| copy_from(m, original_eyes) }
  self.agent_id = original_eyes.base_agent_id if original_eyes.respond_to?(:base_agent_id)
  self.agent_id = original_eyes.full_agent_id if original_eyes.respond_to?(:full_agent_id)
  # self.display_name = original_eyes.app_name
  prepare_for_json!
end

#prepare_for_json!Object



178
179
180
181
182
183
184
185
186
# File 'lib/applitools/universal_sdk/universal_eyes_config.rb', line 178

def prepare_for_json!
  self.batch = batch.to_hash if batch.is_a?(Applitools::BatchInfo)
  self.browsers_info = browsers_info.to_hash if browsers_info.is_a?(Applitools::Selenium::BrowsersInfo)
  self.default_match_settings = default_match_settings.to_hash if default_match_settings.is_a?(Applitools::ImageMatchSettings)
  self.proxy = proxy.to_hash if proxy.is_a?(Applitools::Connectivity::Proxy)
  self.viewport_size = viewport_size.to_h if viewport_size.is_a?(Applitools::RectangleSize)
  # require 'pry'
  # binding.pry
end

#to_hashObject



188
189
190
191
192
193
194
195
196
197
198
199
200
201
# File 'lib/applitools/universal_sdk/universal_eyes_config.rb', line 188

def to_hash
  json_data.compact.reject do |_, v|
    case v
      when Array, Hash
        v.empty?
      when Numeric
        v.zero?
      # when FalseClass
      #   true
      else
        false
    end
  end
end