splitclient-rb 1.0.1 → 1.0.2.wip

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d21886d355095f95e8b513b0769afe03e89b532c
4
- data.tar.gz: ac174313940a5ab346c6e56235ce7e2c24f8df61
3
+ metadata.gz: f46338cb5a89aff85d937872dce9f5f7a990b525
4
+ data.tar.gz: 62945d3ff0ccb5d80648949203a3e0bacf42b253
5
5
  SHA512:
6
- metadata.gz: 50a14d46b118a08adfcac8cb56844c5baf7c79ca90bab323bf9b6103b37221bfde29779c3ca44d5c931a9ffac43e6731a12ca2e3060981c7ce5f072e326a0e8e
7
- data.tar.gz: b63d863d0b8dab1e4dfdea1bffb9d085bf39357f3d679a94c595b9474be7fe93f325c04d3e2abff82ddf78d88faa50a536d15d688ecec60a18150a540e6dd57d
6
+ metadata.gz: 09dde7b159dac73686ec33cdbead5de6adf0d7bcdb052c0f3d1ac33ebf21a76eb92887552547e3ebe15b760b3e05f4bf67785c7fdc303b7346c83fd1a0b6ebea
7
+ data.tar.gz: a0da59f65278e4c0a1cff5eb73c41ef2a05f940a6d6571bac63c3ea27ca683434169631c1840f6eedf1c71b03ae4b67dce91ddbe59a43a15695c488dea43893d
@@ -5,6 +5,12 @@ module SplitIoClient
5
5
  #
6
6
  class AllKeysMatcher < NoMethodError
7
7
 
8
+ attr_reader :matcher_type
9
+
10
+ def initialize
11
+ @matcher_type = "ALL_KEYS"
12
+ end
13
+
8
14
  #
9
15
  # evaluates if the key matches the matcher
10
16
  #
@@ -43,4 +49,4 @@ module SplitIoClient
43
49
 
44
50
  end
45
51
 
46
- end
52
+ end
@@ -0,0 +1,48 @@
1
+ module SplitIoClient
2
+
3
+ class BetweenMatcher < NoMethodError
4
+
5
+ attr_reader :matcher_type
6
+
7
+ def initialize(attribute_hash)
8
+ @matcher_type = "BETWEEN"
9
+ @attribute = attribute_hash[:attribute]
10
+ @start_value = attribute_hash[:start_value]
11
+ @end_value = attribute_hash[:end_value]
12
+ @data_type = attribute_hash[:data_type]
13
+ end
14
+
15
+ def match?(attributes)
16
+ matches = false
17
+ if (!attributes.nil? && attributes.key?(@attribute.to_sym))
18
+ param_value = get_formatted_value(attributes[@attribute.to_sym])
19
+ matches = ((param_value >= @start_value) && (param_value <= @end_value))
20
+ end
21
+ end
22
+
23
+ def equals?(obj)
24
+ if obj.nil?
25
+ false
26
+ elsif !obj.instance_of?(BetweenMatcher)
27
+ false
28
+ elsif self.equal?(obj)
29
+ true
30
+ else
31
+ false
32
+ end
33
+ end
34
+
35
+ private
36
+ def get_formatted_value(value)
37
+ case @data_type
38
+ when "NUMBER"
39
+ return value
40
+ when "DATETIME"
41
+ return ::Utilities.to_milis_zero_out_from_seconds value
42
+ else
43
+ @logger.error('Invalid data type')
44
+ end
45
+ end
46
+ end
47
+
48
+ end
@@ -0,0 +1,48 @@
1
+ module SplitIoClient
2
+
3
+ class EqualToMatcher < NoMethodError
4
+
5
+ attr_reader :matcher_type
6
+
7
+ def initialize(attribute_hash)
8
+ @matcher_type = "EQUAL_TO"
9
+ @attribute = attribute_hash[:attribute]
10
+ @value = attribute_hash[:value]
11
+ @data_type = attribute_hash[:data_type]
12
+ end
13
+
14
+ def match?(attributes)
15
+ matches = false
16
+ if (!attributes.nil? && attributes.key?(@attribute.to_sym))
17
+ param_value = get_formatted_value(attributes[@attribute.to_sym])
18
+ matches = (param_value == @value)
19
+ end
20
+ end
21
+
22
+ def equals?(obj)
23
+ if obj.nil?
24
+ false
25
+ elsif !obj.instance_of?(EqualToMatcher)
26
+ false
27
+ elsif self.equal?(obj)
28
+ true
29
+ else
30
+ false
31
+ end
32
+ end
33
+
34
+ private
35
+ def get_formatted_value(value)
36
+ case @data_type
37
+ when "NUMBER"
38
+ return value
39
+ when "DATETIME"
40
+ return ::Utilities.to_milis_zero_out_from_hour value
41
+ else
42
+ @logger.error('Invalid data type')
43
+ end
44
+ end
45
+
46
+ end
47
+
48
+ end
@@ -0,0 +1,48 @@
1
+ module SplitIoClient
2
+
3
+ class GreaterThanOrEqualToMatcher < NoMethodError
4
+
5
+ attr_reader :matcher_type
6
+
7
+ def initialize(attribute_hash)
8
+ @matcher_type = "GREATER_THAN_OR_EQUAL_TO"
9
+ @attribute = attribute_hash[:attribute]
10
+ @value = attribute_hash[:value]
11
+ @data_type = attribute_hash[:data_type]
12
+ end
13
+
14
+ def match?(attributes)
15
+ matches = false
16
+ if (!attributes.nil? && attributes.key?(@attribute.to_sym))
17
+ param_value = get_formatted_value(attributes[@attribute.to_sym])
18
+ matches = (param_value >= @value)
19
+ end
20
+ end
21
+
22
+ def equals?(obj)
23
+ if obj.nil?
24
+ false
25
+ elsif !obj.instance_of?(GreaterThanOrEqualToMatcher)
26
+ false
27
+ elsif self.equal?(obj)
28
+ true
29
+ else
30
+ false
31
+ end
32
+ end
33
+
34
+ private
35
+ def get_formatted_value(value)
36
+ case @data_type
37
+ when "NUMBER"
38
+ return value
39
+ when "DATETIME"
40
+ return ::Utilities.to_milis_zero_out_from_seconds value
41
+ else
42
+ @logger.error('Invalid data type')
43
+ end
44
+ end
45
+
46
+ end
47
+
48
+ end
@@ -0,0 +1,48 @@
1
+ module SplitIoClient
2
+
3
+ class LessThanOrEqualToMatcher < NoMethodError
4
+
5
+ attr_reader :matcher_type
6
+
7
+ def initialize(attribute_hash)
8
+ @matcher_type = "LESS_THAN_OR_EQUAL_TO"
9
+ @attribute = attribute_hash[:attribute]
10
+ @value = attribute_hash[:value]
11
+ @data_type = attribute_hash[:data_type]
12
+ end
13
+
14
+ def match?(attributes)
15
+ matches = false
16
+ if (!attributes.nil? && attributes.key?(@attribute.to_sym))
17
+ param_value = get_formatted_value(attributes[@attribute.to_sym])
18
+ matches = (param_value <= @value)
19
+ end
20
+ end
21
+
22
+ def equals?(obj)
23
+ if obj.nil?
24
+ false
25
+ elsif !obj.instance_of?(LessThanOrEqualToMatcher)
26
+ false
27
+ elsif self.equal?(obj)
28
+ true
29
+ else
30
+ false
31
+ end
32
+ end
33
+
34
+ private
35
+ def get_formatted_value(value)
36
+ case @data_type
37
+ when "NUMBER"
38
+ return value
39
+ when "DATETIME"
40
+ return ::Utilities.to_milis_zero_out_from_seconds value
41
+ else
42
+ @logger.error('Invalid data type')
43
+ end
44
+ end
45
+
46
+ end
47
+
48
+ end
@@ -5,9 +5,12 @@ module SplitIoClient
5
5
  #
6
6
  class UserDefinedSegmentMatcher < NoMethodError
7
7
 
8
+ attr_reader :matcher_type
9
+
8
10
  @segment = nil
9
11
 
10
12
  def initialize(segment)
13
+ @matcher_type = "IN_SEGMENT"
11
14
  unless segment.nil?
12
15
  @segment = segment
13
16
  end
@@ -55,4 +58,4 @@ module SplitIoClient
55
58
 
56
59
  end
57
60
 
58
- end
61
+ end
@@ -5,23 +5,32 @@ module SplitIoClient
5
5
  #
6
6
  class WhitelistMatcher < NoMethodError
7
7
 
8
+ attr_reader :matcher_type
9
+
8
10
  # variable that contains the keys of the whitelist
9
11
  @whitelist = []
10
12
 
11
- def initialize(whitelist)
12
- unless whitelist.nil?
13
- @whitelist = whitelist
13
+ def initialize(whitelist_data)
14
+ if whitelist_data.instance_of? Array
15
+ @whitelist = whitelist_data unless whitelist_data.nil?
16
+ elsif whitelist_data.instance_of? Hash
17
+ @matcher_type = "ATTR_WHITELIST"
18
+ @attribute = whitelist_data[:attribute]
19
+ @whitelist = whitelist_data[:value] unless whitelist_data[:value].nil?
14
20
  end
15
21
  end
16
22
 
17
- #
18
- # evaluates if the key matches the matcher
19
- #
20
- # @param key [string] key value to be matched
21
- #
22
- # @return [boolean] evaluation of the key against the whitelist
23
- def match?(key)
24
- @whitelist.include?(key)
23
+ def match?(whitelist_data)
24
+ matches = false
25
+ if !(@matcher_type == "ATTR_WHITELIST")
26
+ matches = @whitelist.include?(whitelist_data)
27
+ else
28
+ if (!whitelist_data.nil? && whitelist_data.key?(@attribute.to_sym))
29
+ value = whitelist_data[@attribute.to_sym]
30
+ matches = @whitelist.include?(value)
31
+ end
32
+ end
33
+ matches
25
34
  end
26
35
 
27
36
  #
@@ -52,4 +61,4 @@ module SplitIoClient
52
61
 
53
62
  end
54
63
 
55
- end
64
+ end
@@ -34,22 +34,75 @@ module SplitIoClient
34
34
  @data[:matcherGroup][:matchers]
35
35
  end
36
36
 
37
+ #
38
+ # @return [object] the segment for this condition in case it has a segment matcher
39
+ def matcher_segment
40
+ result = nil
41
+ if self.matcher == 'IN_SEGMENT'
42
+ result = (@data[:matcherGroup][:matchers].first[:userDefinedSegmentMatcherData])[:segmentName]
43
+ end
44
+ result
45
+ end
46
+
37
47
  #
38
48
  # @return [object] the whitelist for this condition in case it has a whitelist matcher
39
49
  def matcher_whitelist
40
50
  result = nil
41
51
  if self.matcher == 'WHITELIST'
42
- result = (@data[:matcherGroup][:matchers].first[:whitelistMatcherData])[:whitelist]
52
+ is_user_whitelist = ( (@data[:matcherGroup][:matchers].first[:keySelector]).nil? || (@data[:matcherGroup][:matchers].first[:keySelector])[:attribute].nil? )
53
+ #is_attribute_whitelist? = !is_user_whitelist?
54
+ if is_user_whitelist
55
+ result = (@data[:matcherGroup][:matchers].first[:whitelistMatcherData])[:whitelist]
56
+ else
57
+ attribute = (@data[:matcherGroup][:matchers].first[:keySelector])[:attribute]
58
+ white_list = (@data[:matcherGroup][:matchers].first[:whitelistMatcherData])[:whitelist]
59
+ result = {attribute: attribute, value: white_list}
60
+ end
43
61
  end
44
62
  result
45
63
  end
46
64
 
47
- #
48
- # @return [object] the segment for this condition in case it has a segment matcher
49
- def matcher_segment
65
+ def matcher_equal
50
66
  result = nil
51
- if self.matcher == 'IN_SEGMENT'
52
- result = (@data[:matcherGroup][:matchers].first[:userDefinedSegmentMatcherData])[:segmentName]
67
+ if self.matcher == 'EQUAL_TO'
68
+ attribute = (@data[:matcherGroup][:matchers].first[:keySelector])[:attribute]
69
+ value = (@data[:matcherGroup][:matchers].first[:unaryNumericMatcherData])[:value]
70
+ data_type = (@data[:matcherGroup][:matchers].first[:unaryNumericMatcherData])[:dataType]
71
+ result = {attribute: attribute, value: value, data_type: data_type}
72
+ end
73
+ result
74
+ end
75
+
76
+ def matcher_greater_than_or_equal
77
+ result = nil
78
+ if self.matcher == 'GREATER_THAN_OR_EQUAL_TO'
79
+ attribute = (@data[:matcherGroup][:matchers].first[:keySelector])[:attribute]
80
+ value = (@data[:matcherGroup][:matchers].first[:unaryNumericMatcherData])[:value]
81
+ data_type = (@data[:matcherGroup][:matchers].first[:unaryNumericMatcherData])[:dataType]
82
+ result = {attribute: attribute, value: value, data_type: data_type}
83
+ end
84
+ result
85
+ end
86
+
87
+ def matcher_less_than_or_equal
88
+ result = nil
89
+ if self.matcher == 'LESS_THAN_OR_EQUAL_TO'
90
+ attribute = (@data[:matcherGroup][:matchers].first[:keySelector])[:attribute]
91
+ value = (@data[:matcherGroup][:matchers].first[:unaryNumericMatcherData])[:value]
92
+ data_type = (@data[:matcherGroup][:matchers].first[:unaryNumericMatcherData])[:dataType]
93
+ result = {attribute: attribute, value: value, data_type: data_type}
94
+ end
95
+ result
96
+ end
97
+
98
+ def matcher_between
99
+ result = nil
100
+ if self.matcher == 'BETWEEN'
101
+ attribute = (@data[:matcherGroup][:matchers].first[:keySelector])[:attribute]
102
+ start_value = (@data[:matcherGroup][:matchers].first[:betweenMatcherData])[:start]
103
+ end_value = (@data[:matcherGroup][:matchers].first[:betweenMatcherData])[:end]
104
+ data_type = (@data[:matcherGroup][:matchers].first[:betweenMatcherData])[:dataType]
105
+ result = {attribute: attribute, start_value: start_value, end_value: end_value, data_type: data_type}
53
106
  end
54
107
  result
55
108
  end
@@ -87,4 +140,4 @@ module SplitIoClient
87
140
 
88
141
  end
89
142
 
90
- end
143
+ end
@@ -78,14 +78,16 @@ module SplitIoClient
78
78
  # @param default_treatment [string] default treatment value to be returned
79
79
  #
80
80
  # @return treatment [object] treatment for this user key, split pair
81
- def get_split_treatment(id, name, default_treatment)
81
+ def get_split_treatment(id, name, default_treatment, attributes = nil)
82
82
  split = get_split(name)
83
+ attribute_matchers = ["ATTR_WHITELIST", "EQUAL_TO", "GREATER_THAN_OR_EQUAL_TO", "LESS_THAN_OR_EQUAL_TO", "BETWEEN"]
83
84
 
84
85
  if !split.is_empty? && split.status == 'ACTIVE' && !split.killed?
85
86
  split.conditions.each do |c|
86
87
  unless c.is_empty?
87
88
  matcher = get_matcher_type(c)
88
- if matcher.match?(id)
89
+ matches = attribute_matchers.include?(matcher.matcher_type) ? matcher.match?(attributes) : matcher.match?(id)
90
+ if matches
89
91
  result = Splitter.get_treatment(id, split.seed, c.partitions) #'true match - running split'
90
92
  if result.nil?
91
93
  return default_treatment
@@ -117,6 +119,14 @@ module SplitIoClient
117
119
  final_matcher = segment.is_empty? ? UserDefinedSegmentMatcher.new(nil) : UserDefinedSegmentMatcher.new(segment)
118
120
  when 'WHITELIST'
119
121
  final_matcher = WhitelistMatcher.new(condition.matcher_whitelist)
122
+ when 'EQUAL_TO'
123
+ final_matcher = EqualToMatcher.new(condition.matcher_equal)
124
+ when 'GREATER_THAN_OR_EQUAL_TO'
125
+ final_matcher = GreaterThanOrEqualToMatcher.new(condition.matcher_greater_than_or_equal)
126
+ when 'LESS_THAN_OR_EQUAL_TO'
127
+ final_matcher = LessThanOrEqualToMatcher.new(condition.matcher_less_than_or_equal)
128
+ when 'BETWEEN'
129
+ final_matcher = BetweenMatcher.new(condition.matcher_between)
120
130
  else
121
131
  @logger.error('Invalid matcher type')
122
132
  end
@@ -16,7 +16,12 @@ require 'splitclient-engine/matchers/all_keys_matcher'
16
16
  require 'splitclient-engine/matchers/negation_matcher'
17
17
  require 'splitclient-engine/matchers/user_defined_segment_matcher'
18
18
  require 'splitclient-engine/matchers/whitelist_matcher'
19
+ require 'splitclient-engine/matchers/equal_to_matcher'
20
+ require 'splitclient-engine/matchers/greater_than_or_equal_to_matcher'
21
+ require 'splitclient-engine/matchers/less_than_or_equal_to_matcher'
22
+ require 'splitclient-engine/matchers/between_matcher'
19
23
  require 'splitclient-engine/evaluator/splitter'
20
24
  require 'splitclient-engine/impressions/impressions'
21
25
  require 'splitclient-engine/metrics/metrics'
22
26
  require 'splitclient-engine/metrics/binary_search_latency_tracker'
27
+ require 'splitclient-rb_utilitites'
@@ -47,7 +47,7 @@ module SplitIoClient
47
47
  # @param feature [string] name of the feature that is being validated
48
48
  #
49
49
  # @return [Treatment] treatment constant value
50
- def get_treatment(id, feature)
50
+ def get_treatment(id, feature, attributes = nil)
51
51
  unless id
52
52
  @config.logger.warn('id was null for feature: ' + feature)
53
53
  return Treatments::CONTROL
@@ -65,7 +65,7 @@ module SplitIoClient
65
65
  result = nil
66
66
 
67
67
  begin
68
- result = get_treatment_without_exception_handling(id, feature)
68
+ result = get_treatment_without_exception_handling(id, feature, attributes)
69
69
  rescue StandardError => error
70
70
  @config.log_found_exception(__method__.to_s, error)
71
71
  end
@@ -94,7 +94,7 @@ module SplitIoClient
94
94
  # @param feature [string] name of the feature that is being validated
95
95
  #
96
96
  # @return [Treatment] tretment constant value
97
- def get_treatment_without_exception_handling(id, feature)
97
+ def get_treatment_without_exception_handling(id, feature, attributes = nil)
98
98
  @adapter.parsed_splits.segments = @adapter.parsed_segments
99
99
  split = @adapter.parsed_splits.get_split(feature)
100
100
 
@@ -102,7 +102,7 @@ module SplitIoClient
102
102
  return Treatments::CONTROL
103
103
  else
104
104
  default_treatment = split.data[:defaultTreatment]
105
- return @adapter.parsed_splits.get_split_treatment(id, feature, default_treatment)
105
+ return @adapter.parsed_splits.get_split_treatment(id, feature, default_treatment, attributes)
106
106
  end
107
107
  end
108
108
 
@@ -1,3 +1,3 @@
1
1
  module SplitIoClient
2
- VERSION = '1.0.1'
2
+ VERSION = '1.0.2.wip'
3
3
  end
@@ -0,0 +1,26 @@
1
+ module Utilities
2
+ extend self
3
+
4
+ # Convert String with Time info to its epoch FixNum previously setting to zero the seconds
5
+ def to_epoch value
6
+ parsed = Time.parse(value)
7
+ zeroed = Time.new(parsed.year, parsed.month, parsed.day, parsed.hour, parsed.min, 0, 0)
8
+ zeroed.to_i
9
+ end
10
+
11
+ def to_epoch_milis value
12
+ (to_epoch (value)) * 1000
13
+ end
14
+
15
+ def to_milis_zero_out_from_seconds value
16
+ parsed_value = Time.strptime(value.to_s,'%s').utc
17
+ zeroed = Time.new(parsed_value.year, parsed_value.month, parsed_value.day, parsed_value.hour, parsed_value.min, 0, 0)
18
+ zeroed.to_i*1000
19
+ end
20
+
21
+ def to_milis_zero_out_from_hour value
22
+ parsed_value = Time.strptime(value.to_s,'%s').utc
23
+ zeroed = Time.new(parsed_value.year, parsed_value.month, parsed_value.day, 0, 0, 0, 0)
24
+ zeroed.to_i*1000
25
+ end
26
+ end
@@ -1,4 +1,4 @@
1
- desc "Benchmark the is_treatment? method call in 4 threads"
1
+ desc "Benchmark the get_treatment method call in 4 threads"
2
2
 
3
3
  # Usage:
4
4
  # rake concurrent_benchmark api_key=YOUR_API_KEY base_uri=YOUR_API_BASE_URI [iterations=NUMBER_OF_ITERATIONS] [user_id=A_USER_ID] [feature_id=A_FEATURE_ID]
@@ -34,7 +34,7 @@ def execute
34
34
  4.times do |i|
35
35
  threads << Thread.new do
36
36
  times_per_thread.times do
37
- split_client.is_treatment? user_id, feature_id, "on"
37
+ split_client.get_treatment user_id, feature_id, {attr: 123}
38
38
  end
39
39
  end
40
40
  end
metadata CHANGED
@@ -1,195 +1,195 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: splitclient-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2.wip
5
5
  platform: ruby
6
6
  authors:
7
7
  - Split Software
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-31 00:00:00.000000000 Z
11
+ date: 2016-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.11'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.11'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '10.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: webmock
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: byebug
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: simplecov
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: json
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ~>
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
103
  version: '1.8'
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ~>
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '1.8'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: thread_safe
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - '>='
115
+ - - ">="
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - '>='
122
+ - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: concurrent-ruby
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - '>='
129
+ - - ">="
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - '>='
136
+ - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: faraday
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - '>='
143
+ - - ">="
144
144
  - !ruby/object:Gem::Version
145
145
  version: '0'
146
146
  type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - '>='
150
+ - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: faraday-http-cache
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
- - - '>='
157
+ - - ">="
158
158
  - !ruby/object:Gem::Version
159
159
  version: '0'
160
160
  type: :runtime
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
- - - '>='
164
+ - - ">="
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: faraday_middleware
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
- - - '>='
171
+ - - ">="
172
172
  - !ruby/object:Gem::Version
173
173
  version: '0'
174
174
  type: :runtime
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
- - - '>='
178
+ - - ">="
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: net-http-persistent
183
183
  requirement: !ruby/object:Gem::Requirement
184
184
  requirements:
185
- - - '>='
185
+ - - ">="
186
186
  - !ruby/object:Gem::Version
187
187
  version: '0'
188
188
  type: :runtime
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
- - - '>='
192
+ - - ">="
193
193
  - !ruby/object:Gem::Version
194
194
  version: '0'
195
195
  description: Ruby client for using split SDK.
@@ -199,7 +199,7 @@ executables: []
199
199
  extensions: []
200
200
  extra_rdoc_files: []
201
201
  files:
202
- - .gitignore
202
+ - ".gitignore"
203
203
  - CHANGES.txt
204
204
  - Gemfile
205
205
  - LICENSE
@@ -210,8 +210,12 @@ files:
210
210
  - lib/splitclient-engine/evaluator/splitter.rb
211
211
  - lib/splitclient-engine/impressions/impressions.rb
212
212
  - lib/splitclient-engine/matchers/all_keys_matcher.rb
213
+ - lib/splitclient-engine/matchers/between_matcher.rb
213
214
  - lib/splitclient-engine/matchers/combiners.rb
214
215
  - lib/splitclient-engine/matchers/combining_matcher.rb
216
+ - lib/splitclient-engine/matchers/equal_to_matcher.rb
217
+ - lib/splitclient-engine/matchers/greater_than_or_equal_to_matcher.rb
218
+ - lib/splitclient-engine/matchers/less_than_or_equal_to_matcher.rb
215
219
  - lib/splitclient-engine/matchers/negation_matcher.rb
216
220
  - lib/splitclient-engine/matchers/user_defined_segment_matcher.rb
217
221
  - lib/splitclient-engine/matchers/whitelist_matcher.rb
@@ -229,9 +233,9 @@ files:
229
233
  - lib/splitclient-rb/split_client.rb
230
234
  - lib/splitclient-rb/split_config.rb
231
235
  - lib/splitclient-rb/version.rb
236
+ - lib/splitclient-rb_utilitites.rb
232
237
  - splitclient-rb.gemspec
233
- - tasks/benchmark_is_treatment.rake
234
- - tasks/concurrent_benchmark_is_treatment.rake
238
+ - tasks/benchmark_get_treatment.rake
235
239
  - tasks/console.rake
236
240
  - tasks/rspec.rake
237
241
  homepage: https://github.com/splitio/ruby-client
@@ -244,17 +248,17 @@ require_paths:
244
248
  - lib
245
249
  required_ruby_version: !ruby/object:Gem::Requirement
246
250
  requirements:
247
- - - '>='
251
+ - - ">="
248
252
  - !ruby/object:Gem::Version
249
253
  version: '0'
250
254
  required_rubygems_version: !ruby/object:Gem::Requirement
251
255
  requirements:
252
- - - '>='
256
+ - - ">"
253
257
  - !ruby/object:Gem::Version
254
- version: '0'
258
+ version: 1.3.1
255
259
  requirements: []
256
260
  rubyforge_project:
257
- rubygems_version: 2.0.14
261
+ rubygems_version: 2.2.2
258
262
  signing_key:
259
263
  specification_version: 4
260
264
  summary: Ruby client for split SDK.
@@ -1,37 +0,0 @@
1
- desc "Benchmark the is_treatment? method call"
2
-
3
- # Usage:
4
- # rake benchmark api_key=YOUR_API_KEY base_uri=YOUR_API_BASE_URI [iterations=NUMBER_OF_ITERATIONS] [user_id=A_USER_ID] [feature_id=A_FEATURE_ID]
5
- task :benchmark do
6
- require 'benchmark'
7
- require 'splitclient-rb'
8
-
9
- usage_message = "Usage: rake benchmark api_key=YOUR_API_KEY base_uri=YOUR_API_BASE_URI [iterations=NUMBER_OF_ITERATIONS] [user_id=A_USER_ID] [feature_id=A_FEATURE_ID]"
10
- if validate_params
11
- execute
12
- else
13
- p usage_message
14
- end
15
-
16
- end
17
-
18
- def validate_params
19
- !ENV['api_key'].nil? && !ENV['base_uri'].nil?
20
- end
21
-
22
- def execute
23
- api_key = ENV['api_key'].nil? ? "fake_api_key" : ENV['api_key']
24
- base_uri = ENV['base_uri'].nil? ? "fake/api/" : ENV['base_uri']
25
- iterations = ENV['iterations'].nil? ? 1000000 : ENV['iterations'].to_i
26
- user_id = ENV['user_id'].nil? ? "fake_id_1" : ENV['user_id']
27
- feature_id = ENV['feature_id'].nil? ? "sample_feature" : ENV['feature_id']
28
-
29
- split_client = SplitIoClient::SplitClient.new(api_key, {base_uri: base_uri, logger: Logger.new("/dev/null") })
30
- Benchmark.bm do |bm|
31
- bm.report do
32
- iterations.times do
33
- Benchmark.measure { split_client.is_treatment? user_id, feature_id, "on" }
34
- end
35
- end
36
- end
37
- end