kameleoon-client-ruby 2.0.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/kameleoon/client.rb +277 -260
- data/lib/kameleoon/configuration/feature_flag.rb +13 -24
- data/lib/kameleoon/configuration/rule.rb +17 -5
- data/lib/kameleoon/configuration/settings.rb +20 -0
- data/lib/kameleoon/cookie.rb +3 -3
- data/lib/kameleoon/data/browser.rb +33 -0
- data/lib/kameleoon/data/conversion.rb +26 -0
- data/lib/kameleoon/data/custom_data.rb +53 -0
- data/lib/kameleoon/data/data.rb +35 -0
- data/lib/kameleoon/data/device.rb +26 -0
- data/lib/kameleoon/data/page_view.rb +31 -0
- data/lib/kameleoon/data/user_agent.rb +14 -0
- data/lib/kameleoon/hybrid/manager.rb +60 -0
- data/lib/kameleoon/network/activity_event.rb +31 -0
- data/lib/kameleoon/network/experiment_event.rb +35 -0
- data/lib/kameleoon/network/uri_helper.rb +36 -0
- data/lib/kameleoon/network/url_provider.rb +71 -0
- data/lib/kameleoon/real_time/real_time_configuration_service.rb +98 -0
- data/lib/kameleoon/real_time/real_time_event.rb +22 -0
- data/lib/kameleoon/real_time/sse_client.rb +111 -0
- data/lib/kameleoon/real_time/sse_message.rb +23 -0
- data/lib/kameleoon/real_time/sse_request.rb +59 -0
- data/lib/kameleoon/request.rb +5 -19
- data/lib/kameleoon/storage/cache.rb +84 -0
- data/lib/kameleoon/storage/cache_factory.rb +23 -0
- data/lib/kameleoon/targeting/condition.rb +41 -12
- data/lib/kameleoon/targeting/condition_factory.rb +35 -12
- data/lib/kameleoon/targeting/conditions/browser_condition.rb +71 -0
- data/lib/kameleoon/targeting/conditions/conversion_condition.rb +21 -0
- data/lib/kameleoon/targeting/conditions/custom_datum.rb +64 -34
- data/lib/kameleoon/targeting/conditions/device_condition.rb +21 -0
- data/lib/kameleoon/targeting/conditions/exclusive_experiment.rb +0 -12
- data/lib/kameleoon/targeting/conditions/page_title_condition.rb +21 -0
- data/lib/kameleoon/targeting/conditions/page_url_condition.rb +21 -0
- data/lib/kameleoon/targeting/conditions/sdk_language_condition.rb +65 -0
- data/lib/kameleoon/targeting/conditions/string_value_condition.rb +40 -0
- data/lib/kameleoon/targeting/conditions/target_experiment.rb +5 -9
- data/lib/kameleoon/targeting/conditions/unknown_condition.rb +15 -0
- data/lib/kameleoon/targeting/conditions/visitor_code_condition.rb +16 -0
- data/lib/kameleoon/targeting/models.rb +0 -24
- data/lib/kameleoon/utils.rb +1 -1
- data/lib/kameleoon/version.rb +28 -1
- metadata +45 -4
- data/lib/kameleoon/configuration/feature_flag_v2.rb +0 -30
- data/lib/kameleoon/data.rb +0 -169
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'kameleoon/data/data'
|
4
|
+
|
5
|
+
module Kameleoon
|
6
|
+
# @api private
|
7
|
+
module Targeting
|
8
|
+
# ConversionCondition is a condition for checking targeting of conversions of visitor
|
9
|
+
class ConversionCondition < Condition
|
10
|
+
def initialize(json_condition)
|
11
|
+
super(json_condition)
|
12
|
+
@goal_id = json_condition['goalId']
|
13
|
+
end
|
14
|
+
|
15
|
+
def check(list_data)
|
16
|
+
conversion = get_last_targeting_data(list_data, Kameleoon::DataType::CONVERSION)
|
17
|
+
conversion && (@goal_id.nil? || @goal_id == conversion.goal_id)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'set'
|
4
|
+
require 'json'
|
3
5
|
require 'kameleoon/targeting/condition'
|
4
6
|
require 'kameleoon/exceptions'
|
5
7
|
|
@@ -9,55 +11,83 @@ module Kameleoon
|
|
9
11
|
class CustomDatum < Condition
|
10
12
|
include Kameleoon::Exception
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
-
|
14
|
+
class << self
|
15
|
+
def op_match(values, value)
|
16
|
+
re = Regexp.new(value.to_s)
|
17
|
+
values.any? { |v| re.match(v) }
|
18
|
+
end
|
15
19
|
|
16
|
-
|
17
|
-
|
20
|
+
def op_contains(values, value)
|
21
|
+
values.any? { |v| v.to_s.include? value.to_s }
|
18
22
|
end
|
19
23
|
|
20
|
-
|
24
|
+
def op_exact(values, value)
|
25
|
+
values.include? value.to_s
|
26
|
+
end
|
21
27
|
|
22
|
-
|
28
|
+
def op_equal(values, value)
|
29
|
+
values.any? { |v| v.to_f == value.to_f }
|
30
|
+
end
|
23
31
|
|
24
|
-
|
32
|
+
def op_greater(values, value)
|
33
|
+
values.any? { |v| v.to_f > value.to_f }
|
34
|
+
end
|
35
|
+
|
36
|
+
def op_lower(values, value)
|
37
|
+
values.any? { |v| v.to_f < value.to_f }
|
38
|
+
end
|
39
|
+
|
40
|
+
def op_is_true(values, _value)
|
41
|
+
values.any? { |v| v.to_s == 'true' }
|
42
|
+
end
|
25
43
|
|
26
|
-
|
27
|
-
|
44
|
+
def op_is_false(values, _value)
|
45
|
+
values.any? { |v| v.to_s == 'false' }
|
28
46
|
end
|
29
47
|
|
30
|
-
|
48
|
+
def op_among_values(values, value)
|
49
|
+
all_matches = JSON.parse(value.to_s).map(&:to_s).to_set
|
50
|
+
values.any? { |v| all_matches.include?(v) }
|
51
|
+
end
|
31
52
|
end
|
32
53
|
|
33
|
-
|
54
|
+
@@op = {
|
55
|
+
Operator::REGULAR_EXPRESSION => method(:op_match),
|
56
|
+
Operator::CONTAINS => method(:op_contains),
|
57
|
+
Operator::EXACT => method(:op_exact),
|
58
|
+
Operator::EQUAL => method(:op_equal),
|
59
|
+
Operator::GREATER => method(:op_greater),
|
60
|
+
Operator::LOWER => method(:op_lower),
|
61
|
+
Operator::IS_TRUE => method(:op_is_true),
|
62
|
+
Operator::IS_FALSE => method(:op_is_false),
|
63
|
+
Operator::AMONG_VALUES => method(:op_among_values)
|
64
|
+
}
|
65
|
+
|
66
|
+
def initialize(json_condition)
|
67
|
+
super(json_condition)
|
68
|
+
|
69
|
+
if json_condition['valueMatchType'].nil?
|
70
|
+
raise Exception::NotFound.new('valueMatchType'), 'valueMatchType missed'
|
71
|
+
end
|
72
|
+
|
73
|
+
@type = ConditionType::CUSTOM_DATUM
|
74
|
+
@index = json_condition['customDataIndex']
|
75
|
+
@operator = json_condition['valueMatchType']
|
76
|
+
@value = json_condition['value']
|
77
|
+
end
|
78
|
+
|
79
|
+
def check(list_data)
|
34
80
|
is_targeted = false
|
35
|
-
custom_data =
|
81
|
+
custom_data = list_data.select { |data| data.instance == DataType::CUSTOM && data.id == @index }.last
|
36
82
|
if custom_data.nil?
|
37
83
|
is_targeted = (@operator == Operator::UNDEFINED.to_s)
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
is_targeted = !Regexp.new(@value.to_s).match(custom_data.value.to_s).nil?
|
42
|
-
when Operator::CONTAINS.to_s
|
43
|
-
is_targeted = custom_data.value.to_s.include? @value
|
44
|
-
when Operator::EXACT.to_s
|
45
|
-
is_targeted = custom_data.value.to_s == @value.to_s
|
46
|
-
when Operator::EQUAL.to_s
|
47
|
-
is_targeted = custom_data.value.to_f == @value.to_f
|
48
|
-
when Operator::GREATER.to_s
|
49
|
-
is_targeted = custom_data.value.to_f > @value.to_f
|
50
|
-
when Operator::LOWER.to_s
|
51
|
-
is_targeted = custom_data.value.to_f < @value.to_f
|
52
|
-
when Operator::IS_TRUE.to_s
|
53
|
-
is_targeted = custom_data.value == 'true'
|
54
|
-
when Operator::IS_FALSE.to_s
|
55
|
-
is_targeted = custom_data.value == 'false'
|
56
|
-
when Operator::AMONG_VALUES.to_s
|
57
|
-
is_targeted = @value.scan(/"([^"]*)"/).flatten.include?(custom_data.value)
|
58
|
-
else
|
84
|
+
elsif @operator != Operator::UNDEFINED.to_s
|
85
|
+
@operation = @@op[@operator]
|
86
|
+
unless @operation
|
59
87
|
raise KameleoonError.new("Undefined operator #{@operator}"), "Undefined operator #{@operator}"
|
60
88
|
end
|
89
|
+
|
90
|
+
is_targeted = @operation.call(custom_data.values, @value)
|
61
91
|
end
|
62
92
|
is_targeted
|
63
93
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'kameleoon/data/data'
|
4
|
+
|
5
|
+
module Kameleoon
|
6
|
+
# @api private
|
7
|
+
module Targeting
|
8
|
+
# DeviceCondition is a condition for checking device type
|
9
|
+
class DeviceCondition < Condition
|
10
|
+
def initialize(json_condition)
|
11
|
+
super(json_condition)
|
12
|
+
@device_type = json_condition['device']
|
13
|
+
end
|
14
|
+
|
15
|
+
def check(list_data)
|
16
|
+
device = get_last_targeting_data(list_data, Kameleoon::DataType::DEVICE)
|
17
|
+
device && @device_type == device.device_type
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -1,24 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'kameleoon/targeting/condition'
|
4
|
-
require 'kameleoon/exceptions'
|
5
4
|
|
6
5
|
module Kameleoon
|
7
6
|
# @api private
|
8
7
|
module Targeting
|
9
8
|
# ExclusiveExperiment represents an instance of Exclusive Experiment condition in user account
|
10
9
|
class ExclusiveExperiment < Condition
|
11
|
-
include Kameleoon::Exception
|
12
|
-
|
13
|
-
def initialize(json_condition)
|
14
|
-
if json_condition['targetingType'].nil?
|
15
|
-
raise Exception::NotFoundError.new('targetingType'), 'targetingType missed'
|
16
|
-
end
|
17
|
-
|
18
|
-
@type = json_condition['targetingType']
|
19
|
-
@include = true
|
20
|
-
end
|
21
|
-
|
22
10
|
def check(data)
|
23
11
|
experiment_id = data.experiment_id
|
24
12
|
storage = data.storage
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'kameleoon/data/data'
|
4
|
+
require_relative 'string_value_condition'
|
5
|
+
|
6
|
+
module Kameleoon
|
7
|
+
# @api private
|
8
|
+
module Targeting
|
9
|
+
# PageTitleCondition is a condition for checking title of a page
|
10
|
+
class PageTitleCondition < StringValueCondition
|
11
|
+
def initialize(json_condition)
|
12
|
+
super(json_condition, json_condition['title'])
|
13
|
+
end
|
14
|
+
|
15
|
+
def check(list_data)
|
16
|
+
page_view = get_last_targeting_data(list_data, Kameleoon::DataType::PAGE_VIEW)
|
17
|
+
page_view && check_targeting(page_view.title)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'kameleoon/data/data'
|
4
|
+
require_relative 'string_value_condition'
|
5
|
+
|
6
|
+
module Kameleoon
|
7
|
+
# @api private
|
8
|
+
module Targeting
|
9
|
+
# PageUrlCondition is a condition for checking url of a page
|
10
|
+
class PageUrlCondition < StringValueCondition
|
11
|
+
def initialize(json_condition)
|
12
|
+
super(json_condition, json_condition['url'])
|
13
|
+
end
|
14
|
+
|
15
|
+
def check(list_data)
|
16
|
+
page_view = get_last_targeting_data(list_data, Kameleoon::DataType::PAGE_VIEW)
|
17
|
+
page_view && check_targeting(page_view.url)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'kameleoon/data/data'
|
4
|
+
require 'kameleoon/version'
|
5
|
+
|
6
|
+
module Kameleoon
|
7
|
+
# @api private
|
8
|
+
module Targeting
|
9
|
+
# Helper class for containing sdk information
|
10
|
+
class SdkInfo
|
11
|
+
attr_reader :language, :version
|
12
|
+
|
13
|
+
def initialize(language, version)
|
14
|
+
@language = language
|
15
|
+
@version = version
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# SdkLanguageCondition is a condition for checking targeting sdk type and version
|
20
|
+
class SdkLanguageCondition < Condition
|
21
|
+
def initialize(json_condition)
|
22
|
+
super(json_condition)
|
23
|
+
@sdk_language = json_condition['sdkLanguage']
|
24
|
+
@version = json_condition['version']
|
25
|
+
@operator = json_condition['versionMatchType']
|
26
|
+
end
|
27
|
+
|
28
|
+
def check(data)
|
29
|
+
data.is_a?(SdkInfo) && check_targeting(data)
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def check_targeting(sdk_info)
|
35
|
+
return false if @sdk_language != sdk_info.language
|
36
|
+
|
37
|
+
return true if @version.nil?
|
38
|
+
|
39
|
+
version_components_condition = SdkVersion.get_version_components(@version)
|
40
|
+
version_components_sdk_info = SdkVersion.get_version_components(sdk_info.version)
|
41
|
+
|
42
|
+
return false if version_components_condition.nil? || version_components_sdk_info.nil?
|
43
|
+
|
44
|
+
major_condition, minor_condition, patch_condition = version_components_condition
|
45
|
+
major_sdk, minor_sdk, patch_sdk = version_components_sdk_info
|
46
|
+
|
47
|
+
case @operator
|
48
|
+
when Operator::EQUAL
|
49
|
+
major_sdk == major_condition && minor_sdk == minor_condition && patch_sdk == patch_condition
|
50
|
+
when Operator::GREATER
|
51
|
+
major_sdk > major_condition ||
|
52
|
+
(major_sdk == major_condition && minor_sdk > minor_condition) ||
|
53
|
+
(major_sdk == major_condition && minor_sdk == minor_condition && patch_sdk > patch_condition)
|
54
|
+
when Operator::LOWER
|
55
|
+
major_sdk < major_condition ||
|
56
|
+
(major_sdk == major_condition && minor_sdk < minor_condition) ||
|
57
|
+
(major_sdk == major_condition && minor_sdk == minor_condition && patch_sdk < patch_condition)
|
58
|
+
else
|
59
|
+
puts "Unexpected comparing operation for SdkLanguage condition: #{@operator}"
|
60
|
+
false
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'kameleoon/targeting/condition'
|
4
|
+
|
5
|
+
module Kameleoon
|
6
|
+
# @api private
|
7
|
+
module Targeting
|
8
|
+
# StringValueCondition is a base class for all conditions where string comparison happens
|
9
|
+
class StringValueCondition < Condition
|
10
|
+
def initialize(json_condition, value)
|
11
|
+
super(json_condition)
|
12
|
+
@condition_value = value
|
13
|
+
@operator = json_condition['matchType']
|
14
|
+
end
|
15
|
+
|
16
|
+
def check(data)
|
17
|
+
data.is_a?(String) && check_targeting(data)
|
18
|
+
end
|
19
|
+
|
20
|
+
protected
|
21
|
+
|
22
|
+
def check_targeting(value)
|
23
|
+
return false if value.nil?
|
24
|
+
|
25
|
+
case @operator
|
26
|
+
when Operator::EXACT
|
27
|
+
value == @condition_value
|
28
|
+
when Operator::CONTAINS
|
29
|
+
value.include?(@condition_value)
|
30
|
+
when Operator::REGULAR_EXPRESSION
|
31
|
+
pattern = Regexp.new(@condition_value)
|
32
|
+
pattern.match?(value)
|
33
|
+
else
|
34
|
+
puts "Unexpected comparing operation for #{@type} condition: #{@operator}"
|
35
|
+
false
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -13,16 +13,12 @@ module Kameleoon
|
|
13
13
|
def initialize(json_condition)
|
14
14
|
super(json_condition)
|
15
15
|
|
16
|
-
if json_condition['experiment'].nil?
|
17
|
-
raise Exception::NotFoundError.new('experiment'), 'experiment missed'
|
18
|
-
end
|
19
|
-
|
20
|
-
@experiment = json_condition['experiment']
|
21
|
-
|
16
|
+
raise Exception::NotFound.new('experiment'), 'experiment missed' if json_condition['experiment'].nil?
|
22
17
|
if json_condition['variationMatchType'].nil?
|
23
|
-
raise Exception::
|
18
|
+
raise Exception::NotFound.new('variationMatchType'), 'variationMatchType missed'
|
24
19
|
end
|
25
20
|
|
21
|
+
@experiment = json_condition['experiment']
|
26
22
|
@operator = json_condition['variationMatchType']
|
27
23
|
@variation = json_condition['variation']
|
28
24
|
end
|
@@ -32,9 +28,9 @@ module Kameleoon
|
|
32
28
|
variation_storage_exist = !variation_storage.nil? && !variation_storage.empty?
|
33
29
|
saved_variation = variation_storage[@experiment] unless variation_storage.nil?
|
34
30
|
case @operator
|
35
|
-
when Operator::EXACT
|
31
|
+
when Operator::EXACT
|
36
32
|
is_targeted = variation_storage_exist && saved_variation == @variation
|
37
|
-
when Operator::ANY
|
33
|
+
when Operator::ANY
|
38
34
|
is_targeted = variation_storage_exist
|
39
35
|
end
|
40
36
|
is_targeted
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'kameleoon/targeting/condition'
|
4
|
+
|
5
|
+
module Kameleoon
|
6
|
+
# @api private
|
7
|
+
module Targeting
|
8
|
+
# UnknownCondition represents not defined condition, always returns that visitor is targeted (true)
|
9
|
+
class UnknownCondition < Condition
|
10
|
+
def check(_data)
|
11
|
+
true
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'kameleoon/data/data'
|
4
|
+
require_relative 'string_value_condition'
|
5
|
+
|
6
|
+
module Kameleoon
|
7
|
+
# @api private
|
8
|
+
module Targeting
|
9
|
+
# VisitorCodeCondition is a condition for checking of targeting by visitor code
|
10
|
+
class VisitorCodeCondition < StringValueCondition
|
11
|
+
def initialize(json_condition)
|
12
|
+
super(json_condition, json_condition['visitorCode'])
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -133,29 +133,5 @@ module Kameleoon
|
|
133
133
|
Marshal.load(Marshal.dump(is_targeted)) # Deep copy
|
134
134
|
end
|
135
135
|
end
|
136
|
-
|
137
|
-
module DataType
|
138
|
-
CUSTOM = 'CUSTOM'
|
139
|
-
end
|
140
|
-
|
141
|
-
module ConditionType
|
142
|
-
CUSTOM_DATUM = 'CUSTOM_DATUM'
|
143
|
-
TARGET_EXPERIMENT = 'TARGET_EXPERIMENT'
|
144
|
-
EXCLUSIVE_EXPERIMENT = 'EXCLUSIVE_EXPERIMENT'
|
145
|
-
end
|
146
|
-
|
147
|
-
module Operator
|
148
|
-
UNDEFINED = 'UNDEFINED'
|
149
|
-
CONTAINS = 'CONTAINS'
|
150
|
-
EXACT = 'EXACT'
|
151
|
-
MATCH = 'REGULAR_EXPRESSION'
|
152
|
-
LOWER = 'LOWER'
|
153
|
-
EQUAL = 'EQUAL'
|
154
|
-
GREATER = 'GREATER'
|
155
|
-
IS_TRUE = 'TRUE'
|
156
|
-
IS_FALSE = 'FALSE'
|
157
|
-
AMONG_VALUES = 'AMONG_VALUES'
|
158
|
-
ANY = 'ANY'
|
159
|
-
end
|
160
136
|
end
|
161
137
|
end
|
data/lib/kameleoon/utils.rb
CHANGED
data/lib/kameleoon/version.rb
CHANGED
@@ -1,5 +1,32 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Kameleoon
|
4
|
-
|
4
|
+
SDK_NAME = 'RUBY'
|
5
|
+
SDK_VERSION = '2.1.1'
|
6
|
+
|
7
|
+
# SdkManager is a helper method for fetching / obtaining version of SDK from string
|
8
|
+
class SdkVersion
|
9
|
+
def self.get_version_components(version_string)
|
10
|
+
versions = [0, 0, 0]
|
11
|
+
|
12
|
+
version_parts = version_string.split('.')
|
13
|
+
version_parts.each_with_index do |part, i|
|
14
|
+
versions[i] = Integer(part)
|
15
|
+
rescue ArgumentError
|
16
|
+
puts "Invalid version component, index: #{i}, value: #{part}"
|
17
|
+
return nil
|
18
|
+
end
|
19
|
+
versions
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.get_float_version(version_string)
|
23
|
+
version_components = get_version_components(version_string)
|
24
|
+
|
25
|
+
return Float::NAN if version_components.nil?
|
26
|
+
|
27
|
+
major = version_components[0]
|
28
|
+
minor = version_components[1]
|
29
|
+
"#{major}.#{minor}".to_f
|
30
|
+
end
|
31
|
+
end
|
5
32
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kameleoon-client-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kameleoon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: em-http-request
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.7'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rest-client
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.1'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.1'
|
55
69
|
description: Kameleoon Client Ruby Software Development Kit
|
56
70
|
email:
|
57
71
|
- sdk@kameleoon.com
|
@@ -64,23 +78,50 @@ files:
|
|
64
78
|
- lib/kameleoon/client.rb
|
65
79
|
- lib/kameleoon/configuration/experiment.rb
|
66
80
|
- lib/kameleoon/configuration/feature_flag.rb
|
67
|
-
- lib/kameleoon/configuration/feature_flag_v2.rb
|
68
81
|
- lib/kameleoon/configuration/rule.rb
|
82
|
+
- lib/kameleoon/configuration/settings.rb
|
69
83
|
- lib/kameleoon/configuration/variable.rb
|
70
84
|
- lib/kameleoon/configuration/variation.rb
|
71
85
|
- lib/kameleoon/configuration/variation_exposition.rb
|
72
86
|
- lib/kameleoon/cookie.rb
|
73
|
-
- lib/kameleoon/data.rb
|
87
|
+
- lib/kameleoon/data/browser.rb
|
88
|
+
- lib/kameleoon/data/conversion.rb
|
89
|
+
- lib/kameleoon/data/custom_data.rb
|
90
|
+
- lib/kameleoon/data/data.rb
|
91
|
+
- lib/kameleoon/data/device.rb
|
92
|
+
- lib/kameleoon/data/page_view.rb
|
93
|
+
- lib/kameleoon/data/user_agent.rb
|
74
94
|
- lib/kameleoon/exceptions.rb
|
75
95
|
- lib/kameleoon/factory.rb
|
96
|
+
- lib/kameleoon/hybrid/manager.rb
|
97
|
+
- lib/kameleoon/network/activity_event.rb
|
98
|
+
- lib/kameleoon/network/experiment_event.rb
|
99
|
+
- lib/kameleoon/network/uri_helper.rb
|
100
|
+
- lib/kameleoon/network/url_provider.rb
|
101
|
+
- lib/kameleoon/real_time/real_time_configuration_service.rb
|
102
|
+
- lib/kameleoon/real_time/real_time_event.rb
|
103
|
+
- lib/kameleoon/real_time/sse_client.rb
|
104
|
+
- lib/kameleoon/real_time/sse_message.rb
|
105
|
+
- lib/kameleoon/real_time/sse_request.rb
|
76
106
|
- lib/kameleoon/request.rb
|
107
|
+
- lib/kameleoon/storage/cache.rb
|
108
|
+
- lib/kameleoon/storage/cache_factory.rb
|
77
109
|
- lib/kameleoon/storage/variation_storage.rb
|
78
110
|
- lib/kameleoon/storage/visitor_variation.rb
|
79
111
|
- lib/kameleoon/targeting/condition.rb
|
80
112
|
- lib/kameleoon/targeting/condition_factory.rb
|
113
|
+
- lib/kameleoon/targeting/conditions/browser_condition.rb
|
114
|
+
- lib/kameleoon/targeting/conditions/conversion_condition.rb
|
81
115
|
- lib/kameleoon/targeting/conditions/custom_datum.rb
|
116
|
+
- lib/kameleoon/targeting/conditions/device_condition.rb
|
82
117
|
- lib/kameleoon/targeting/conditions/exclusive_experiment.rb
|
118
|
+
- lib/kameleoon/targeting/conditions/page_title_condition.rb
|
119
|
+
- lib/kameleoon/targeting/conditions/page_url_condition.rb
|
120
|
+
- lib/kameleoon/targeting/conditions/sdk_language_condition.rb
|
121
|
+
- lib/kameleoon/targeting/conditions/string_value_condition.rb
|
83
122
|
- lib/kameleoon/targeting/conditions/target_experiment.rb
|
123
|
+
- lib/kameleoon/targeting/conditions/unknown_condition.rb
|
124
|
+
- lib/kameleoon/targeting/conditions/visitor_code_condition.rb
|
84
125
|
- lib/kameleoon/targeting/models.rb
|
85
126
|
- lib/kameleoon/targeting/tree_builder.rb
|
86
127
|
- lib/kameleoon/utils.rb
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'rule'
|
4
|
-
require_relative 'variation'
|
5
|
-
|
6
|
-
module Kameleoon
|
7
|
-
# Module which contains all internal data of SDK
|
8
|
-
module Configuration
|
9
|
-
# Class for manage all feature flags v2 with rules
|
10
|
-
class FeatureFlagV2
|
11
|
-
attr_accessor :id, :feature_key, :variations, :default_variation_key, :rules
|
12
|
-
|
13
|
-
def self.create_from_array(array)
|
14
|
-
array&.map { |it| FeatureFlagV2.new(it) }
|
15
|
-
end
|
16
|
-
|
17
|
-
def initialize(hash)
|
18
|
-
@id = hash['id']
|
19
|
-
@feature_key = hash['featureKey']
|
20
|
-
@default_variation_key = hash['defaultVariationKey']
|
21
|
-
@variations = Variation.create_from_array(hash['variations'])
|
22
|
-
@rules = Rule.create_from_array(hash['rules'])
|
23
|
-
end
|
24
|
-
|
25
|
-
def get_variation_key(key)
|
26
|
-
variations.select { |v| v.key == key }.first
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|