-
Notifications
You must be signed in to change notification settings - Fork 28
/
changes.patch
111 lines (97 loc) · 9.91 KB
/
changes.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
diff --git a/lib/optimizely/custom_attribute_condition_evaluator.rb b/lib/optimizely/custom_attribute_condition_evaluator.rb
index ab1b7a6..733dac5 100644
--- a/lib/optimizely/custom_attribute_condition_evaluator.rb
+++ b/lib/optimizely/custom_attribute_condition_evaluator.rb
@@ -273,6 +273,11 @@ module Optimizely
end
def semver_equal_evaluator(condition)
+ # Evaluate the given semantic version equal match target version for the user version.
+ # Returns boolean true if the user version is equal to the target version,
+ # false if the user version is not equal to the target version,
+ # nil if the user version or target version is not string type or is nil.
+
target_version = condition['value']
user_version = @user_attributes[condition['name']]
@@ -280,6 +285,11 @@ module Optimizely
end
def semver_greater_than_evaluator(condition)
+ # Evaluate the given semantic version greater than match target version for the user version.
+ # Returns boolean true if the user version is greater than the target version,
+ # false if the user version is less than or equal to the target version,
+ # nil if the user version or target version is not string type or is nil.
+
target_version = condition['value']
user_version = @user_attributes[condition['name']]
@@ -287,6 +297,11 @@ module Optimizely
end
def semver_greater_than_or_equal_evaluator(condition)
+ # Evaluate the given semantic version greater than or equal to match target version for the user version.
+ # Returns boolean true if the user version is greater than or equal to the target version,
+ # false if the user version is less than the target version,
+ # nil if the user version or target version is not string type or is nil.
+
target_version = condition['value']
user_version = @user_attributes[condition['name']]
@@ -294,6 +309,11 @@ module Optimizely
end
def semver_less_than_evaluator(condition)
+ # Evaluate the given semantic version less than match target version for the user version.
+ # Returns boolean true if the user version is less than the target version,
+ # false if the user version is greater than or equal to the target version,
+ # nil if the user version or target version is not string type or is nil.
+
target_version = condition['value']
user_version = @user_attributes[condition['name']]
@@ -301,6 +321,11 @@ module Optimizely
end
def semver_less_than_or_equal_evaluator(condition)
+ # Evaluate the given semantic version less than or equal to match target version for the user version.
+ # Returns boolean true if the user version is less than or equal to the target version,
+ # false if the user version is greater than the target version,
+ # nil if the user version or target version is not string type or is nil.
+
target_version = condition['value']
user_version = @user_attributes[condition['name']]
diff --git a/lib/optimizely/semantic_version.rb b/lib/optimizely/semantic_version.rb
index da8fae3..2d34573 100644
--- a/lib/optimizely/semantic_version.rb
+++ b/lib/optimizely/semantic_version.rb
@@ -27,10 +27,24 @@ module Optimizely
module_function
def pre_release?(target)
+ # Method to check if the given version contains "-"
+ #
+ # target - String representing semantic version
+ #
+ # Returns true if the given version does contain "-"
+ # false if it doesn't
+
target.include? SEMVER_PRE_RELEASE
end
def split_semantic_version(target)
+ # Method to split the given version.
+ #
+ # target - String representing semantic version
+ #
+ # Returns List The array of version split into smaller parts i.e major, minor, patch etc,
+ # Exception if the given version is invalid in format.
+
target_prefix = target
target_suffix = ''
target_parts = []
@@ -65,6 +79,17 @@ module Optimizely
end
def compare_user_version_with_target_version(target_version, user_version)
+ # Evaluate the given exact match condition for the given user attributes.
+ #
+ # target_version - String representing user version
+ # user_version - String representing target version
+
+ # Returns boolean 0 if user version is equal to target version,
+ # 1 if user version is greater than target version,
+ # -1 if user version is less than target version or, in case of exact string match, doesn't
+ # match the target version,
+ # nil if the user version or target version is not string type or is nil.
+
raise InvalidAttributeType unless target_version.is_a? String
raise InvalidAttributeType unless user_version.is_a? String