Class: Applitools::EyesBaseConfiguration
Constant Summary
collapse
- DEFAULT_CONFIG =
{
branch_name: ENV['APPLITOOLS_BRANCH'] || '',
parent_branch_name: ENV['APPLITOOLS_PARENT_BRANCH'] || '',
baseline_branch_name: ENV['APPLITOOLS_BASELINE_BRANCH'] || '',
save_diffs: false,
server_url: 'https://eyessdk.applitools.com',
api_key: ENV['APPLITOOLS_API_KEY'] || '',
match_level: Applitools::MatchLevel::STRICT,
scale: 0,
remainder: 0
}.freeze
Instance Attribute Summary
#config_hash, #validation_errors
Class Method Summary
collapse
Instance Method Summary
collapse
#match_level_with_exact
#accessor_methods, #boolean_field, #collect_method, #enum_field, #int_field, #methods_to_delegate, #object_field, #string_field
Constructor Details
Returns a new instance of EyesBaseConfiguration.
30
31
32
33
|
# File 'lib/applitools/core/eyes_base_configuration.rb', line 30
def initialize
super
end
|
Class Method Details
.default_config ⇒ Object
25
26
27
|
# File 'lib/applitools/core/eyes_base_configuration.rb', line 25
def default_config
DEFAULT_CONFIG
end
|
Instance Method Details
#batch ⇒ Object
71
72
73
74
75
76
77
|
# File 'lib/applitools/core/eyes_base_configuration.rb', line 71
def batch
if batch_info.nil?
Applitools::EyesLogger.info 'No batch set'
self.batch_info = BatchInfo.new
end
batch_info
end
|
#batch=(value) ⇒ Object
79
80
81
|
# File 'lib/applitools/core/eyes_base_configuration.rb', line 79
def batch=(value)
self.batch_info = value
end
|
#config_keys ⇒ Object
48
49
50
|
# File 'lib/applitools/core/eyes_base_configuration.rb', line 48
def config_keys
config_hash.keys
end
|
#default_match_settings ⇒ Object
145
146
147
148
149
150
151
152
|
# File 'lib/applitools/core/eyes_base_configuration.rb', line 145
def default_match_settings
{
match_level: match_level,
exact: exact,
scale: scale,
remainder: remainder
}
end
|
#default_match_settings=(value) ⇒ Object
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
# File 'lib/applitools/core/eyes_base_configuration.rb', line 130
def default_match_settings=(value)
Applitools::ArgumentGuard.is_a? value, 'value', Hash
= value.keys - match_level_keys
unless .empty?
raise Applitools::EyesIllegalArgument.new(
"Pasiing extra keys is prohibited! Passed extra keys: #{}"
)
end
result = default_match_settings.merge!(value)
(self.match_level, self.exact) = match_level_with_exact(result[:match_level], result[:exact])
self.scale = result[:scale]
self.remainder = result[:remainder]
result
end
|
#match_level=(value) ⇒ Object
#match_level_keys ⇒ Object
154
155
156
|
# File 'lib/applitools/core/eyes_base_configuration.rb', line 154
def match_level_keys
%w(match_level exact scale remainder).map(&:to_sym)
end
|
#merge(other_config) ⇒ Object
35
36
37
38
39
40
|
# File 'lib/applitools/core/eyes_base_configuration.rb', line 35
def merge(other_config)
return if self.object_id == other_config.object_id
(config_keys + other_config. config_keys).uniq do |k|
merge_key(other_config, k)
end
end
|
#merge_key(other_config, key) ⇒ Object
42
43
44
45
46
|
# File 'lib/applitools/core/eyes_base_configuration.rb', line 42
def merge_key(other_config, key)
return unless other_config.send("defined_#{key}?")
return unless self.respond_to? "#{key}="
self.send("#{key}=", other_config.send(key))
end
|
#set_default_match_settings(value, exact_options = {}) ⇒ Object
126
127
128
|
# File 'lib/applitools/core/eyes_base_configuration.rb', line 126
def set_default_match_settings(value, exact_options = {})
(self.match_level, self.exact) = match_level_with_exact(value, exact_options)
end
|
#set_proxy(uri, user = nil, password = nil) ⇒ Object
116
117
118
|
# File 'lib/applitools/core/eyes_base_configuration.rb', line 116
def set_proxy(uri, user = nil, password = nil)
self.proxy = Applitools::Connectivity::Proxy.new(uri, user, password)
end
|
#short_description ⇒ Object
112
113
114
|
# File 'lib/applitools/core/eyes_base_configuration.rb', line 112
def short_description
"#{test_name} of #{app_name}"
end
|
#to_s ⇒ Object
52
53
54
55
56
|
# File 'lib/applitools/core/eyes_base_configuration.rb', line 52
def to_s
config_keys.map do |k|
"#{k} = #{send(k)}"
end.join("\n")
end
|
#valid? ⇒ Boolean
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/applitools/core/eyes_base_configuration.rb', line 58
def valid?
validation_errors.clear
validation_errors[:app_name] = ':app_name is required' unless app_name
validation_errors[:test_name] = ':test_name is required' unless test_name
validation_errors[:app_name] = ':app_name is required' if app_name && app_name.empty?
validation_errors[:test_name] = ':test_name is required' if test_name && test_name.empty?
return true if validation_errors.keys.size.zero?
false
end
|