splitclient-rb 1.0.0 → 1.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ae476f9f03f55b222d9e4a608078b8bbb24d6aef
4
- data.tar.gz: 083b93df66b440f9516291f936ab648f61fb8a5c
3
+ metadata.gz: d21886d355095f95e8b513b0769afe03e89b532c
4
+ data.tar.gz: ac174313940a5ab346c6e56235ce7e2c24f8df61
5
5
  SHA512:
6
- metadata.gz: c144ff009845e37ab4b78f309aad2868b3b2b623a6f8fc8dfa700b3cf15013377c9291dff649047fbfe22cf9391d9fe8e3a323f64e0c07b15545cdfff7dfc3ec
7
- data.tar.gz: d60c9d6ef4d03553a33cfd3f81441a7fa9821427e60643314666416997f6af96e1374f2aa0b9eddf780f9cbc9ff4fe26829726468cd899dcfb38b35742dfbb36
6
+ metadata.gz: 50a14d46b118a08adfcac8cb56844c5baf7c79ca90bab323bf9b6103b37221bfde29779c3ca44d5c931a9ffac43e6731a12ca2e3060981c7ce5f072e326a0e8e
7
+ data.tar.gz: b63d863d0b8dab1e4dfdea1bffb9d085bf39357f3d679a94c595b9474be7fe93f325c04d3e2abff82ddf78d88faa50a536d15d688ecec60a18150a540e6dd57d
@@ -1,3 +1,8 @@
1
+ 1.0.1
2
+
3
+ - .splits to .split for local env
4
+ - isTreatment was removed from the API.
5
+
1
6
  1.0.0
2
7
 
3
8
  - Support multivariate treatment
data/NEWS CHANGED
@@ -1,3 +1,9 @@
1
+ 1.0.1
2
+
3
+ isTreatment was removed from the API
4
+ local environment file was removed to match the rest of the SDKs. "split".
5
+ No other major updates for this release.
6
+
1
7
  1.0.0
2
8
 
3
9
  No news for this release.
@@ -40,29 +40,6 @@ module SplitIoClient
40
40
  end
41
41
  end
42
42
 
43
- #
44
- # validates the treatment for the provided user key and feature
45
- #
46
- # @param id [string] user id
47
- # @param feature [string] name of the feature that is being validated
48
- # @param treatment [string] value of the treatment for this user key and feature
49
- #
50
- # @return [boolean] true if the user key has valida treatment, false otherwise
51
- def is_treatment?(id, feature, treatment)
52
- is_treatment = false
53
-
54
- if is_localhost_mode?
55
- is_treatment = get_localhost_treatment(feature)
56
- else
57
- begin
58
- is_treatment = (get_treatment(id, feature) == treatment)
59
- rescue
60
- @config.logger.error("MUST NOT throw this error")
61
- end
62
- end
63
- is_treatment
64
- end
65
-
66
43
  #
67
44
  # obtains the treatment for a given feature
68
45
  #
@@ -81,25 +58,30 @@ module SplitIoClient
81
58
  return Treatments::CONTROL
82
59
  end
83
60
 
84
- start = Time.now
85
- result = nil
61
+ if is_localhost_mode?
62
+ result = get_localhost_treatment(feature)
63
+ else
64
+ start = Time.now
65
+ result = nil
86
66
 
87
- begin
88
- result = get_treatment_without_exception_handling(id, feature)
89
- rescue StandardError => error
90
- @config.log_found_exception(__method__.to_s, error)
91
- end
67
+ begin
68
+ result = get_treatment_without_exception_handling(id, feature)
69
+ rescue StandardError => error
70
+ @config.log_found_exception(__method__.to_s, error)
71
+ end
92
72
 
93
- result = result.nil? ? Treatments::CONTROL : result
73
+ result = result.nil? ? Treatments::CONTROL : result
94
74
 
95
- begin
96
- @adapter.impressions.log(id, feature, result, (Time.now.to_f * 1000.0))
97
- latency = (Time.now - start) * 1000.0
98
- if (@adapter.impressions.queue.length >= @adapter.impressions.max_number_of_keys)
99
- @adapter.impressions_producer.wakeup
75
+ begin
76
+ @adapter.impressions.log(id, feature, result, (Time.now.to_f * 1000.0))
77
+ latency = (Time.now - start) * 1000.0
78
+ if (@adapter.impressions.queue.length >= @adapter.impressions.max_number_of_keys)
79
+ @adapter.impressions_producer.wakeup
80
+ end
81
+ rescue StandardError => error
82
+ @config.log_found_exception(__method__.to_s, error)
100
83
  end
101
- rescue StandardError => error
102
- @config.log_found_exception(__method__.to_s, error)
84
+
103
85
  end
104
86
 
105
87
  result
@@ -145,11 +127,12 @@ module SplitIoClient
145
127
  #
146
128
  # @returns [void]
147
129
  def load_localhost_mode_features
148
- splits_file = File.join(Dir.home, ".splits")
130
+ splits_file = File.join(Dir.home, ".split")
149
131
  if File.exists?(splits_file)
150
132
  line_num=0
151
133
  File.open(splits_file).each do |line|
152
- @localhost_mode_features << line.strip unless line.start_with?('#') || line.strip.empty?
134
+ line_data = line.strip.split(" ")
135
+ @localhost_mode_features << {feature: line_data[0], treatment: line_data[1]} unless line.start_with?('#') || line.strip.empty?
153
136
  end
154
137
  end
155
138
  end
@@ -159,7 +142,10 @@ module SplitIoClient
159
142
  #
160
143
  # @return [boolean] true if the feature is available in localhost mode, false otherwise
161
144
  def get_localhost_treatment(feature)
162
- @localhost_mode_features.include?(feature)
145
+ localhost_result = Treatments::CONTROL
146
+ treatment = @localhost_mode_features.select{|h| h[:feature] == feature}.last
147
+ localhost_result = treatment[:treatment] if !treatment.nil?
148
+ localhost_result
163
149
  end
164
150
 
165
151
  private :get_treatment_without_exception_handling, :is_localhost_mode?,
@@ -1,3 +1,3 @@
1
1
  module SplitIoClient
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
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: 1.0.0
4
+ version: 1.0.1
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-29 00:00:00.000000000 Z
11
+ date: 2016-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler