splitclient-rb 4.0.0 → 4.1.0.pre.rc1
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/CHANGES.txt +3 -0
- data/NEWS +4 -0
- data/lib/engine/matchers/contains_all_matcher.rb +17 -0
- data/lib/engine/matchers/contains_any_matcher.rb +15 -0
- data/lib/engine/matchers/contains_matcher.rb +20 -0
- data/lib/engine/matchers/ends_with_matcher.rb +20 -0
- data/lib/engine/matchers/part_of_set_matcher.rb +19 -0
- data/lib/engine/matchers/set_matcher.rb +18 -0
- data/lib/engine/matchers/starts_with_matcher.rb +20 -0
- data/lib/engine/parser/condition.rb +43 -0
- data/lib/splitclient-rb/version.rb +1 -1
- data/lib/splitclient-rb.rb +7 -0
- metadata +11 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1940b82d90766ec3641b0b5e271f8d8d67026fd
|
4
|
+
data.tar.gz: 410da73bb3192cbde8b947226e72063bf8b9348b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7602038ddcd42020c1207825f2b07a4dcaaa4900ec99c14a5aacf0e55d907972a37f7205b1aa103c77f44be8c8b9f85bd5822af11efa8944fb0aa7113dc15a9
|
7
|
+
data.tar.gz: 194de0eb97cf2fdc6a7df31cadd76569e8f9334dc9a4503734ba3e91c8b4f916a9202f6f6e8c22702c4641fcea4110f585c15b3d2f7cb4bafcaf4f6d37518719
|
data/CHANGES.txt
CHANGED
data/NEWS
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
module SplitIoClient
|
2
|
+
class ContainsAllMatcher < SetMatcher
|
3
|
+
def self.matcher_type
|
4
|
+
'CONTAINS_ALL'.freeze
|
5
|
+
end
|
6
|
+
|
7
|
+
def initialize(attribute, remote_array)
|
8
|
+
super(attribute, remote_array)
|
9
|
+
end
|
10
|
+
|
11
|
+
def match?(_key, data)
|
12
|
+
return false if @remote_set.empty?
|
13
|
+
|
14
|
+
@remote_set.subset? local_set(data, @attribute)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module SplitIoClient
|
2
|
+
class ContainsAnyMatcher < SetMatcher
|
3
|
+
def self.matcher_type
|
4
|
+
'CONTAINS_ANY'.freeze
|
5
|
+
end
|
6
|
+
|
7
|
+
def initialize(attribute, remote_array)
|
8
|
+
super(attribute, remote_array)
|
9
|
+
end
|
10
|
+
|
11
|
+
def match?(_key, data)
|
12
|
+
local_set(data, @attribute).intersect? @remote_set
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module SplitIoClient
|
2
|
+
class ContainsMatcher
|
3
|
+
def self.matcher_type
|
4
|
+
'CONTAINS_WITH'.freeze
|
5
|
+
end
|
6
|
+
|
7
|
+
def initialize(attribute, substr_list)
|
8
|
+
@attribute = attribute
|
9
|
+
@substr_list = substr_list
|
10
|
+
end
|
11
|
+
|
12
|
+
def match?(_key, data)
|
13
|
+
value = data.fetch(@attribute) { |attr| data[attr.to_s] || data[attr.to_sym] }
|
14
|
+
|
15
|
+
return false if @substr_list.empty?
|
16
|
+
|
17
|
+
@substr_list.any? { |substr| value.include? substr }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module SplitIoClient
|
2
|
+
class EndsWithMatcher
|
3
|
+
def self.matcher_type
|
4
|
+
'ENDS_WITH'.freeze
|
5
|
+
end
|
6
|
+
|
7
|
+
def initialize(attribute, suffix_list)
|
8
|
+
@attribute = attribute
|
9
|
+
@suffix_list = suffix_list
|
10
|
+
end
|
11
|
+
|
12
|
+
def match?(_key, data)
|
13
|
+
value = data.fetch(@attribute) { |attr| data[attr.to_s] || data[attr.to_sym] }
|
14
|
+
|
15
|
+
return false if @suffix_list.empty?
|
16
|
+
|
17
|
+
@suffix_list.any? { |suffix| value.end_with? suffix }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module SplitIoClient
|
2
|
+
class PartOfSetMatcher < SetMatcher
|
3
|
+
def self.matcher_type
|
4
|
+
'PART_OF_SET'.freeze
|
5
|
+
end
|
6
|
+
|
7
|
+
def initialize(attribute, remote_array)
|
8
|
+
super(attribute, remote_array)
|
9
|
+
end
|
10
|
+
|
11
|
+
def match?(_key, data)
|
12
|
+
@local_set = local_set(data, @attribute)
|
13
|
+
|
14
|
+
return false if @local_set.empty?
|
15
|
+
|
16
|
+
@local_set.subset? @remote_set
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module SplitIoClient
|
2
|
+
class SetMatcher
|
3
|
+
protected
|
4
|
+
|
5
|
+
def initialize(attribute, remote_array)
|
6
|
+
@attribute = attribute
|
7
|
+
@remote_set = remote_array.to_set
|
8
|
+
end
|
9
|
+
|
10
|
+
def local_set(data, attribute)
|
11
|
+
data = data.fetch(attribute) { |attr| data[attr.to_s] || data[attr.to_sym] }
|
12
|
+
# Allow user to pass individual elements as well
|
13
|
+
local_array = data.kind_of?(Array) ? data : [data]
|
14
|
+
|
15
|
+
local_array.to_set
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module SplitIoClient
|
2
|
+
class StartsWithMatcher
|
3
|
+
def self.matcher_type
|
4
|
+
'STARTS_WITH'.freeze
|
5
|
+
end
|
6
|
+
|
7
|
+
def initialize(attribute, prefix_list)
|
8
|
+
@attribute = attribute
|
9
|
+
@prefix_list = prefix_list
|
10
|
+
end
|
11
|
+
|
12
|
+
def match?(_key, data)
|
13
|
+
value = data.fetch(@attribute) { |attr| data[attr.to_s] || data[attr.to_sym] }
|
14
|
+
|
15
|
+
return false if @prefix_list.empty?
|
16
|
+
|
17
|
+
@prefix_list.any? { |prefix| value.start_with? prefix }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -108,6 +108,49 @@ module SplitIoClient
|
|
108
108
|
BetweenMatcher.new(attribute: attribute, start_value: start_value, end_value: end_value, data_type: data_type)
|
109
109
|
end
|
110
110
|
|
111
|
+
|
112
|
+
def matcher_part_of_set(params)
|
113
|
+
PartOfSetMatcher.new(
|
114
|
+
params[:matcher][:keySelector][:attribute],
|
115
|
+
params[:matcher][:whitelistMatcherData][:whitelist]
|
116
|
+
)
|
117
|
+
end
|
118
|
+
|
119
|
+
def matcher_contains_all(params)
|
120
|
+
ContainsAllMatcher.new(
|
121
|
+
params[:matcher][:keySelector][:attribute],
|
122
|
+
params[:matcher][:whitelistMatcherData][:whitelist]
|
123
|
+
)
|
124
|
+
end
|
125
|
+
|
126
|
+
def matcher_contains_any(params)
|
127
|
+
ContainsAnyMatcher.new(
|
128
|
+
params[:matcher][:keySelector][:attribute],
|
129
|
+
params[:matcher][:whitelistMatcherData][:whitelist]
|
130
|
+
)
|
131
|
+
end
|
132
|
+
|
133
|
+
def matcher_starts_with(params)
|
134
|
+
StartsWithMatcher.new(
|
135
|
+
params[:matcher][:keySelector][:attribute],
|
136
|
+
params[:matcher][:whitelistMatcherData][:whitelist]
|
137
|
+
)
|
138
|
+
end
|
139
|
+
|
140
|
+
def matcher_contains(params)
|
141
|
+
ContainsMatcher.new(
|
142
|
+
params[:matcher][:keySelector][:attribute],
|
143
|
+
params[:matcher][:whitelistMatcherData][:whitelist]
|
144
|
+
)
|
145
|
+
end
|
146
|
+
|
147
|
+
def matcher_ends_with(params)
|
148
|
+
EndsWithMatcher.new(
|
149
|
+
params[:matcher][:keySelector][:attribute],
|
150
|
+
params[:matcher][:whitelistMatcherData][:whitelist]
|
151
|
+
)
|
152
|
+
end
|
153
|
+
|
111
154
|
#
|
112
155
|
# @return [object] the negate value for this condition
|
113
156
|
def negate
|
data/lib/splitclient-rb.rb
CHANGED
@@ -51,6 +51,13 @@ require 'engine/matchers/equal_to_matcher'
|
|
51
51
|
require 'engine/matchers/greater_than_or_equal_to_matcher'
|
52
52
|
require 'engine/matchers/less_than_or_equal_to_matcher'
|
53
53
|
require 'engine/matchers/between_matcher'
|
54
|
+
require 'engine/matchers/set_matcher'
|
55
|
+
require 'engine/matchers/part_of_set_matcher'
|
56
|
+
require 'engine/matchers/contains_any_matcher'
|
57
|
+
require 'engine/matchers/contains_all_matcher'
|
58
|
+
require 'engine/matchers/starts_with_matcher'
|
59
|
+
require 'engine/matchers/ends_with_matcher'
|
60
|
+
require 'engine/matchers/contains_matcher'
|
54
61
|
require 'engine/evaluator/splitter'
|
55
62
|
require 'engine/metrics/metrics'
|
56
63
|
require 'engine/metrics/binary_search_latency_tracker'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: splitclient-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.1.0.pre.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Split Software
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -309,10 +309,17 @@ files:
|
|
309
309
|
- lib/engine/matchers/between_matcher.rb
|
310
310
|
- lib/engine/matchers/combiners.rb
|
311
311
|
- lib/engine/matchers/combining_matcher.rb
|
312
|
+
- lib/engine/matchers/contains_all_matcher.rb
|
313
|
+
- lib/engine/matchers/contains_any_matcher.rb
|
314
|
+
- lib/engine/matchers/contains_matcher.rb
|
315
|
+
- lib/engine/matchers/ends_with_matcher.rb
|
312
316
|
- lib/engine/matchers/equal_to_matcher.rb
|
313
317
|
- lib/engine/matchers/greater_than_or_equal_to_matcher.rb
|
314
318
|
- lib/engine/matchers/less_than_or_equal_to_matcher.rb
|
315
319
|
- lib/engine/matchers/negation_matcher.rb
|
320
|
+
- lib/engine/matchers/part_of_set_matcher.rb
|
321
|
+
- lib/engine/matchers/set_matcher.rb
|
322
|
+
- lib/engine/matchers/starts_with_matcher.rb
|
316
323
|
- lib/engine/matchers/user_defined_segment_matcher.rb
|
317
324
|
- lib/engine/matchers/whitelist_matcher.rb
|
318
325
|
- lib/engine/metrics/binary_search_latency_tracker.rb
|
@@ -359,9 +366,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
359
366
|
version: '0'
|
360
367
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
361
368
|
requirements:
|
362
|
-
- - "
|
369
|
+
- - ">"
|
363
370
|
- !ruby/object:Gem::Version
|
364
|
-
version:
|
371
|
+
version: 1.3.1
|
365
372
|
requirements: []
|
366
373
|
rubyforge_project:
|
367
374
|
rubygems_version: 2.5.2
|