airship-ruby 1.1.2 → 1.1.3
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 +76 -11
- 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: 577e120e2dd12d0d8d355f21adfe8d2bf93145c7
|
4
|
+
data.tar.gz: 563b3918684b1be0d36dc40642a8257fd90fc40c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94df167af112babb0fd21241767a8c4d21339b16e91dbbeea280517f082a25391fea23608979a79af2c1f7313cbe711f1d08d637325c82a82fae17119cd2443f
|
7
|
+
data.tar.gz: 6f20a23eabb5b79d0b5b0be0078605035197a58c7b3712b922770ea6bebbd843429e868fcbce12e5867ac0b53331fb15919fc3b1c279c43550ac84f2275d92c7
|
data/airship-ruby.gemspec
CHANGED
data/lib/airship-ruby.rb
CHANGED
@@ -21,7 +21,7 @@ class Airship
|
|
21
21
|
"type" => "boolean",
|
22
22
|
},
|
23
23
|
"id" => {
|
24
|
-
"type" => "string",
|
24
|
+
"type" => ["string", "integer"],
|
25
25
|
"maxLength" => 250,
|
26
26
|
"minLength" => 1,
|
27
27
|
},
|
@@ -64,7 +64,7 @@ class Airship
|
|
64
64
|
"enum" => [true],
|
65
65
|
},
|
66
66
|
"id" => {
|
67
|
-
"type" => "string",
|
67
|
+
"type" => ["string", "integer"],
|
68
68
|
"maxLength" => 250,
|
69
69
|
"minLength" => 1,
|
70
70
|
},
|
@@ -99,7 +99,7 @@ class Airship
|
|
99
99
|
"additionalProperties" => false,
|
100
100
|
},
|
101
101
|
},
|
102
|
-
"required" => ["
|
102
|
+
"required" => ["id", "display_name"],
|
103
103
|
"additionalProperties" => false,
|
104
104
|
}
|
105
105
|
|
@@ -177,7 +177,7 @@ class Airship
|
|
177
177
|
@gate_stats_upload_batch_interval = 60
|
178
178
|
|
179
179
|
@gate_stats_watcher = nil
|
180
|
-
@gate_stats_last_task_scheduled_timestamp =
|
180
|
+
@gate_stats_last_task_scheduled_timestamp = 0
|
181
181
|
|
182
182
|
@gate_stats_uploader_tasks = []
|
183
183
|
|
@@ -215,7 +215,11 @@ class Airship
|
|
215
215
|
|
216
216
|
object = self._clone_object(object)
|
217
217
|
|
218
|
-
|
218
|
+
if object['type'].nil?
|
219
|
+
object['type'] = 'User'
|
220
|
+
end
|
221
|
+
|
222
|
+
error = self._validate_nesting(object) || self._maybe_transform_id(object)
|
219
223
|
|
220
224
|
if !error.nil?
|
221
225
|
puts error
|
@@ -247,6 +251,12 @@ class Airship
|
|
247
251
|
stats['sdk_gate_control_short_name'] = control_short_name
|
248
252
|
stats['sdk_gate_timestamp'] = sdk_gate_timestamp
|
249
253
|
stats['sdk_gate_latency'] = sdk_gate_latency
|
254
|
+
|
255
|
+
stats['sdk_gate_value'] = is_enabled
|
256
|
+
stats['sdk_gate_variation'] = variation
|
257
|
+
stats['sdk_gate_eligibility'] = is_eligible
|
258
|
+
stats['sdk_gate_type'] = 'value'
|
259
|
+
|
250
260
|
stats['sdk_version'] = sdk_version
|
251
261
|
stats['sdk_id'] = @@sdk_id
|
252
262
|
|
@@ -267,7 +277,11 @@ class Airship
|
|
267
277
|
|
268
278
|
object = self._clone_object(object)
|
269
279
|
|
270
|
-
|
280
|
+
if object['type'].nil?
|
281
|
+
object['type'] = 'User'
|
282
|
+
end
|
283
|
+
|
284
|
+
error = self._validate_nesting(object) || self._maybe_transform_id(object)
|
271
285
|
|
272
286
|
if !error.nil?
|
273
287
|
puts error
|
@@ -299,6 +313,12 @@ class Airship
|
|
299
313
|
stats['sdk_gate_control_short_name'] = control_short_name
|
300
314
|
stats['sdk_gate_timestamp'] = sdk_gate_timestamp
|
301
315
|
stats['sdk_gate_latency'] = sdk_gate_latency
|
316
|
+
|
317
|
+
stats['sdk_gate_value'] = is_enabled
|
318
|
+
stats['sdk_gate_variation'] = variation
|
319
|
+
stats['sdk_gate_eligibility'] = is_eligible
|
320
|
+
stats['sdk_gate_type'] = 'variation'
|
321
|
+
|
302
322
|
stats['sdk_version'] = sdk_version
|
303
323
|
stats['sdk_id'] = @@sdk_id
|
304
324
|
|
@@ -319,7 +339,11 @@ class Airship
|
|
319
339
|
|
320
340
|
object = self._clone_object(object)
|
321
341
|
|
322
|
-
|
342
|
+
if object['type'].nil?
|
343
|
+
object['type'] = 'User'
|
344
|
+
end
|
345
|
+
|
346
|
+
error = self._validate_nesting(object) || self._maybe_transform_id(object)
|
323
347
|
|
324
348
|
if !error.nil?
|
325
349
|
puts error
|
@@ -351,6 +375,12 @@ class Airship
|
|
351
375
|
stats['sdk_gate_control_short_name'] = control_short_name
|
352
376
|
stats['sdk_gate_timestamp'] = sdk_gate_timestamp
|
353
377
|
stats['sdk_gate_latency'] = sdk_gate_latency
|
378
|
+
|
379
|
+
stats['sdk_gate_value'] = is_enabled
|
380
|
+
stats['sdk_gate_variation'] = variation
|
381
|
+
stats['sdk_gate_eligibility'] = is_eligible
|
382
|
+
stats['sdk_gate_type'] = 'eligibility'
|
383
|
+
|
354
384
|
stats['sdk_version'] = sdk_version
|
355
385
|
stats['sdk_id'] = @@sdk_id
|
356
386
|
|
@@ -409,6 +439,11 @@ class Airship
|
|
409
439
|
end
|
410
440
|
if response.status == 200
|
411
441
|
gating_info = JSON.parse(response.body)
|
442
|
+
|
443
|
+
if gating_info['server_info'] == 'maintenance'
|
444
|
+
return
|
445
|
+
end
|
446
|
+
|
412
447
|
gating_info_map = self._get_gating_info_map(gating_info)
|
413
448
|
@gating_info = gating_info
|
414
449
|
@gating_info_map = gating_info_map
|
@@ -424,10 +459,10 @@ class Airship
|
|
424
459
|
def _create_watcher
|
425
460
|
Concurrent::TimerTask.new(execution_interval: @gate_stats_upload_batch_interval, timeout_interval: 10) do |task|
|
426
461
|
now = Time.now.utc.to_i
|
427
|
-
if now - @gate_stats_last_task_scheduled_timestamp
|
462
|
+
if now - @gate_stats_last_task_scheduled_timestamp >= @gate_stats_upload_batch_interval
|
428
463
|
processed = self._process_batch(0)
|
429
464
|
if processed
|
430
|
-
@gate_stats_last_task_scheduled_timestamp
|
465
|
+
@gate_stats_last_task_scheduled_timestamp = now
|
431
466
|
end
|
432
467
|
end
|
433
468
|
end
|
@@ -482,7 +517,7 @@ class Airship
|
|
482
517
|
processed = self._process_batch(@max_gate_stats_batch_size - 1, gate_stats)
|
483
518
|
if processed
|
484
519
|
now = Time.now.utc.to_i
|
485
|
-
@gate_stats_last_task_scheduled_timestamp
|
520
|
+
@gate_stats_last_task_scheduled_timestamp = now
|
486
521
|
end
|
487
522
|
end
|
488
523
|
|
@@ -605,6 +640,7 @@ class Airship
|
|
605
640
|
return false
|
606
641
|
end
|
607
642
|
elsif attribute_type == OBJECT_ATTRIBUTE_TYPE_DATETIME
|
643
|
+
# to_time.to_i respects timezones
|
608
644
|
unix_timestamp = nil
|
609
645
|
begin
|
610
646
|
unix_timestamp = DateTime.parse(attribute_val).to_time.to_i
|
@@ -655,6 +691,7 @@ class Airship
|
|
655
691
|
end
|
656
692
|
|
657
693
|
sampled_inside_base_population = false
|
694
|
+
is_eligible = false
|
658
695
|
control_info['rule_sets'].each do |rule_set|
|
659
696
|
if sampled_inside_base_population
|
660
697
|
break
|
@@ -672,6 +709,7 @@ class Airship
|
|
672
709
|
end
|
673
710
|
|
674
711
|
if satisfies_all_rules
|
712
|
+
is_eligible = true
|
675
713
|
hash_key = "SAMPLING:control_#{control_info['id']}:env_#{@gating_info['env']['id']}:rule_set_#{rule_set['id']}:client_object_#{object['type']}_#{object['id']}"
|
676
714
|
if Airship.get_hashed_value(hash_key) <= rule_set['sampling_percentage']
|
677
715
|
sampled_inside_base_population = true
|
@@ -683,7 +721,7 @@ class Airship
|
|
683
721
|
return {
|
684
722
|
'is_enabled' => false,
|
685
723
|
'variation' => nil,
|
686
|
-
'is_eligible' =>
|
724
|
+
'is_eligible' => is_eligible,
|
687
725
|
}
|
688
726
|
end
|
689
727
|
|
@@ -883,4 +921,31 @@ class Airship
|
|
883
921
|
return 'A group cannot be nested inside another group'
|
884
922
|
end
|
885
923
|
end
|
924
|
+
|
925
|
+
def _maybe_transform_id(object)
|
926
|
+
if object['id'].is_a?(Integer)
|
927
|
+
id_str = object['id'].to_s
|
928
|
+
if id_str.length > 250
|
929
|
+
return 'Integer id must have 250 digits or less'
|
930
|
+
end
|
931
|
+
object['id'] = id_str
|
932
|
+
end
|
933
|
+
|
934
|
+
group = nil
|
935
|
+
if !object['group'].nil?
|
936
|
+
group = object['group']
|
937
|
+
end
|
938
|
+
|
939
|
+
if !group.nil?
|
940
|
+
if group['id'].is_a?(Integer)
|
941
|
+
id_str = group['id'].to_s
|
942
|
+
if id_str.length > 250
|
943
|
+
return 'Integer id must have 250 digits or less'
|
944
|
+
end
|
945
|
+
group['id'] = id_str
|
946
|
+
end
|
947
|
+
end
|
948
|
+
|
949
|
+
nil
|
950
|
+
end
|
886
951
|
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.3
|
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-02-
|
11
|
+
date: 2018-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|