airship-ruby 1.1.5 → 1.1.6
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/airship-ruby.gemspec +1 -1
- data/lib/airship-ruby.rb +44 -18
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d64943505df97e925d93c86d754852868385b1b7
|
4
|
+
data.tar.gz: c6092d944cbdb7f09f8c69dca03646d629747a57
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c21eaa03cde9ab5b96f799a25b4fa57611f6bdaa1b23257403b17a44ad4cde557f536581e93545ba63e9bf63bb3db25603ec5d559b72610935f75a6b7fd4c15
|
7
|
+
data.tar.gz: 7fffa2fec753f365d37028a235aa7760911d6b38abbdaa42f3a5fc75c6e81bbf1186a83f50b7d945bf59f3f45944ddc75e0d4442d44f3bb6adde418bbe0ced38
|
data/airship-ruby.gemspec
CHANGED
data/lib/airship-ruby.rb
CHANGED
@@ -98,11 +98,11 @@ class Airship
|
|
98
98
|
"additionalProperties" => false,
|
99
99
|
},
|
100
100
|
},
|
101
|
-
"required" => ["id"
|
101
|
+
"required" => ["id"],
|
102
102
|
"additionalProperties" => false,
|
103
103
|
},
|
104
104
|
},
|
105
|
-
"required" => ["id"
|
105
|
+
"required" => ["id"],
|
106
106
|
"additionalProperties" => false,
|
107
107
|
}
|
108
108
|
|
@@ -213,6 +213,8 @@ class Airship
|
|
213
213
|
end
|
214
214
|
|
215
215
|
def enabled?(control_short_name, object, default_value=false)
|
216
|
+
object = self._shallow_copy(object)
|
217
|
+
|
216
218
|
validation_errors = JSON::Validator.fully_validate(SCHEMA, object)
|
217
219
|
if validation_errors.size > 0
|
218
220
|
puts validation_errors[0]
|
@@ -221,9 +223,7 @@ class Airship
|
|
221
223
|
|
222
224
|
object = self._clone_object(object)
|
223
225
|
|
224
|
-
|
225
|
-
object['type'] = 'User'
|
226
|
-
end
|
226
|
+
self._maybe_add_fields(object)
|
227
227
|
|
228
228
|
error = self._validate_nesting(object) || self._validate_anonymous(object) || self._maybe_transform_id(object)
|
229
229
|
|
@@ -277,6 +277,8 @@ class Airship
|
|
277
277
|
end
|
278
278
|
|
279
279
|
def variation(control_short_name, object, default_value=nil)
|
280
|
+
object = self._shallow_copy(object)
|
281
|
+
|
280
282
|
validation_errors = JSON::Validator.fully_validate(SCHEMA, object)
|
281
283
|
if validation_errors.size > 0
|
282
284
|
puts validation_errors[0]
|
@@ -285,9 +287,7 @@ class Airship
|
|
285
287
|
|
286
288
|
object = self._clone_object(object)
|
287
289
|
|
288
|
-
|
289
|
-
object['type'] = 'User'
|
290
|
-
end
|
290
|
+
self._maybe_add_fields(object)
|
291
291
|
|
292
292
|
error = self._validate_nesting(object) || self._validate_anonymous(object) || self._maybe_transform_id(object)
|
293
293
|
|
@@ -341,6 +341,8 @@ class Airship
|
|
341
341
|
end
|
342
342
|
|
343
343
|
def eligible?(control_short_name, object, default_value=false)
|
344
|
+
object = self._shallow_copy(object)
|
345
|
+
|
344
346
|
validation_errors = JSON::Validator.fully_validate(SCHEMA, object)
|
345
347
|
if validation_errors.size > 0
|
346
348
|
puts validation_errors[0]
|
@@ -349,9 +351,7 @@ class Airship
|
|
349
351
|
|
350
352
|
object = self._clone_object(object)
|
351
353
|
|
352
|
-
|
353
|
-
object['type'] = 'User'
|
354
|
-
end
|
354
|
+
self._maybe_add_fields(object)
|
355
355
|
|
356
356
|
error = self._validate_nesting(object) || self._validate_anonymous(object) || self._maybe_transform_id(object)
|
357
357
|
|
@@ -406,14 +406,16 @@ class Airship
|
|
406
406
|
|
407
407
|
protected
|
408
408
|
|
409
|
-
def
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
409
|
+
def _shallow_copy(object)
|
410
|
+
copy = {}
|
411
|
+
if object.is_a?(Hash)
|
412
|
+
object.each do |key, value|
|
413
|
+
copy[key.to_s] = self._shallow_copy(value)
|
414
|
+
end
|
415
|
+
else
|
416
|
+
return object
|
414
417
|
end
|
415
|
-
|
416
|
-
stats['sdk_env_id'] = @gating_info['env']['id']
|
418
|
+
copy
|
417
419
|
end
|
418
420
|
|
419
421
|
def _get_gating_info_map(gating_info)
|
@@ -981,4 +983,28 @@ class Airship
|
|
981
983
|
|
982
984
|
nil
|
983
985
|
end
|
986
|
+
|
987
|
+
def _enrich_with_metadata(control_short_name, stats)
|
988
|
+
control_info = @gating_info_map[control_short_name]
|
989
|
+
|
990
|
+
if !control_info.nil?
|
991
|
+
stats['sdk_gate_control_id'] = control_info['id']
|
992
|
+
end
|
993
|
+
|
994
|
+
stats['sdk_env_id'] = @gating_info['env']['id']
|
995
|
+
end
|
996
|
+
|
997
|
+
def _maybe_add_fields(object)
|
998
|
+
if object['type'].nil?
|
999
|
+
object['type'] = 'User'
|
1000
|
+
end
|
1001
|
+
|
1002
|
+
if object['display_name'].nil?
|
1003
|
+
object['display_name'] = object['id'].to_s
|
1004
|
+
end
|
1005
|
+
|
1006
|
+
if !object['group'].nil? && object['group']['display_name'].nil?
|
1007
|
+
object['group']['display_name'] = object['group']['id'].to_s
|
1008
|
+
end
|
1009
|
+
end
|
984
1010
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: airship-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Airship Dev Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|