splitclient-rb 3.0.2 → 3.0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ae8492b8f79d39cda6b4c52bb8300c8d7374fef4
4
- data.tar.gz: '09129f27b81bd42cea7731786f62b4bffdbc5c96'
3
+ metadata.gz: 7e08e6cff298e8ae24d7bcbb6053436d4c34a6ca
4
+ data.tar.gz: d0f646830d6a88634a8eb2410e0f13244d37787a
5
5
  SHA512:
6
- metadata.gz: b5595aecddeef4d878fd02f7748b0e8a97cfe9870495f8e0fee0198ec7db71673c379f995154e80f1f6cc34a6c411c047f6cacf76a3204d4c9681baf566687bd
7
- data.tar.gz: fc242d04f2fd5fb1590239d212da8e427a47cc9f0d2cd069c107b84d78fa64e47d10e05049b81e54bd4a8c00503f47885c4238b8c89c9818b1b493c002b1b3e0
6
+ metadata.gz: b027d1352a234b285a3cbca7b98a0a5872301826c70c466b4c37882c18349796edc12170a8e29fc09732649db4e544b1214b16e73058b323ba8373069db948e8
7
+ data.tar.gz: cf8875450e1f6cfe70fc626f10fa8fb209b9e00aeda40454e3be134b5b7453215360e5dea2be20eb0cc09f16a039bfc5b9b33e5228d52cbee5a6c1ee11f2fe19
data/CHANGES.txt CHANGED
@@ -1,3 +1,6 @@
1
+ 3.0.3
2
+ - Fix nil ref in manager
3
+
1
4
  3.0.2
2
5
  - add ability to provide different bucketing/matching keys
3
6
 
@@ -24,6 +24,10 @@ module SplitIoClient
24
24
  @adapter.find_in_map(namespace_key('splits'), name)
25
25
  end
26
26
 
27
+ def list_splits()
28
+ @adapter[namespace_key('splits')]
29
+ end
30
+
27
31
  def set_change_number(since)
28
32
  @adapter[namespace_key('last_change')] = since
29
33
  end
@@ -15,9 +15,10 @@ module SplitIoClient
15
15
  # @param api_key [String] the API key for your split account
16
16
  #
17
17
  # @return [SplitIoManager] split.io client instance
18
- def initialize(api_key, config = {}, adapter = nil, localhost_mode = false)
18
+ def initialize(api_key, config = {}, adapter = nil, splits_repository = nil, localhost_mode = false)
19
19
  @localhost_mode_features = []
20
20
  @config = config
21
+ @splits_repository = splits_repository
21
22
  @localhost_mode = localhost_mode
22
23
  if @localhost_mode
23
24
  load_localhost_mode_features
@@ -47,27 +48,55 @@ module SplitIoClient
47
48
  #
48
49
  # @returns [object] array of splits
49
50
  def splits
50
- return load_localhost_mode_features if @localhost_mode
51
- if @adapter
52
- @adapter.parsed_splits.splits.map do |split|
53
- data = split.data
54
- treatments = split.data[:conditions] && split.data[:conditions][0][:partitions] \
55
- ? split.data[:conditions][0][:partitions].map{ |partition| partition[:treatment] }
56
- : []
57
- {
58
- name: data[:name],
59
- traffic_type_name: data[:trafficTypeName],
60
- killed: data[:killed],
61
- treatments: treatments,
62
- change_number: data[:changeNumber]
63
- }
64
- end
65
- else
66
- @localhost_mode_features
51
+
52
+ return @localhost_mode_features if @localhost_mode
53
+ return nil if @splits_repository.nil?
54
+
55
+ splits = @splits_repository.list_splits
56
+ ret = []
57
+ splits.keys.each do |key|
58
+
59
+ split = splits.get(key)
60
+ ret << build_split_view(key, split)
67
61
  end
62
+
63
+ ret
68
64
  end
65
+
66
+ #
67
+ # method to get a split view
68
+ #
69
+ # @returns a split view
70
+ def split(split_name)
71
+
72
+ if @localhost_mode
73
+ return @localhost_mode_features.find {|x| x[:feature] == split_name}
74
+ end
75
+
76
+ if @splits_repository
77
+
78
+ split = @splits_repository.get_split(split_name)
79
+
80
+ build_split_view(split_name, split) if split
81
+ end
82
+ end
83
+
84
+ def build_split_view(name, split)
85
+ treatments = split[:conditions] && split[:conditions][0][:partitions] \
86
+ ? split[:conditions][0][:partitions].map{ |partition| partition[:treatment] }
87
+ : []
88
+ {
89
+ name: name,
90
+ traffic_type_name: split[:trafficTypeName],
91
+ killed: split[:killed],
92
+ treatments: treatments,
93
+ change_number: split[:changeNumber]
94
+ }
95
+ end
96
+
69
97
  end
70
98
 
99
+
71
100
  class SplitClient < NoMethodError
72
101
  #
73
102
  # constant that defines the localhost mode
@@ -269,7 +298,7 @@ module SplitIoClient
269
298
  end
270
299
 
271
300
  def init_manager
272
- SplitManager.new(@api_key, @config, @adapter, @localhost_mode)
301
+ SplitManager.new(@api_key, @config, @adapter, @splits_repository, @localhost_mode)
273
302
  end
274
303
  end
275
304
  end
@@ -1,3 +1,3 @@
1
1
  module SplitIoClient
2
- VERSION = '3.0.2'
2
+ VERSION = '3.0.3-rc1'
3
3
  end
@@ -34,5 +34,5 @@ Gem::Specification.new do |spec|
34
34
  spec.add_runtime_dependency "faraday"
35
35
  spec.add_runtime_dependency "faraday-http-cache"
36
36
  spec.add_runtime_dependency "faraday_middleware"
37
- spec.add_runtime_dependency "net-http-persistent"
37
+ spec.add_runtime_dependency "net-http-persistent", "<= 2.9.4"
38
38
  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: 3.0.2
4
+ version: 3.0.3.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: 2016-10-05 00:00:00.000000000 Z
11
+ date: 2016-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -210,16 +210,16 @@ dependencies:
210
210
  name: net-http-persistent
211
211
  requirement: !ruby/object:Gem::Requirement
212
212
  requirements:
213
- - - ">="
213
+ - - "<="
214
214
  - !ruby/object:Gem::Version
215
- version: '0'
215
+ version: 2.9.4
216
216
  type: :runtime
217
217
  prerelease: false
218
218
  version_requirements: !ruby/object:Gem::Requirement
219
219
  requirements:
220
- - - ">="
220
+ - - "<="
221
221
  - !ruby/object:Gem::Version
222
- version: '0'
222
+ version: 2.9.4
223
223
  description: Ruby client for using split SDK.
224
224
  email:
225
225
  - pato@split.io
@@ -293,12 +293,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
293
293
  version: '0'
294
294
  required_rubygems_version: !ruby/object:Gem::Requirement
295
295
  requirements:
296
- - - ">="
296
+ - - ">"
297
297
  - !ruby/object:Gem::Version
298
- version: '0'
298
+ version: 1.3.1
299
299
  requirements: []
300
300
  rubyforge_project:
301
- rubygems_version: 2.5.2
301
+ rubygems_version: 2.4.6
302
302
  signing_key:
303
303
  specification_version: 4
304
304
  summary: Ruby client for split SDK.