prefab-cloud-ruby 1.8.6 → 1.8.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 10aaec070fe5f88d0d56b932b72895176f0c2cda93c74a8b161806f6dfebf0d4
4
- data.tar.gz: bf027e7a737b145caa1b04ab5fb0b19f819434d1e68963635d4579db03160d54
3
+ metadata.gz: '08c5749617f280419c9737d7a0961a69f718dd8c5cc1db73066a198c0d37561c'
4
+ data.tar.gz: aa211a7fcc73b06d343178ce75a8d673fd45bca7bdf40837a1da5f7217bf3c00
5
5
  SHA512:
6
- metadata.gz: 5f56eae3ec7979c5e04a5c946d6c1758e461f3188146248226cf35e392a432b5ba5bcf118161ecebc6d2bf370055fae452600c2c1815355e5c26bd8278c447ac
7
- data.tar.gz: 8f6019f38b32ab4dc04cc55f461cecbbf3760a8445cbb52fa708b3cee84cb08aa64b5cc3060e084b896144de4123f49b7341f9012e421924aeb664a03f9d53fa
6
+ metadata.gz: d9a6ca64f6157cb62d4fddb62d8f5f3c6b9764e37b79ba53b7901d5988008733ac6c95851a8b66056dfdfb636f5739e4a4bd15c20dd8cd157a8329913e813151
7
+ data.tar.gz: 0a6470d0f65411f96e02512dbecf7806732f21b2b18431a9e0cb1e5b3a9c043d7c30c7ea5398a9abb4955b0f4be4051c4bdbaa382c25b5baa882372bb66f189d
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.8.7 - 2024-10-25
4
+
5
+ - Add option symbolize_json_names (#211)
6
+
7
+
3
8
  ## 1.8.6 - 2024-10-07
4
9
 
5
10
  - Fix deprecation warning caused by x_datafile being set by default (#208)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.8.6
1
+ 1.8.7
@@ -69,6 +69,10 @@ module Prefab
69
69
  end
70
70
  end
71
71
 
72
+ def symbolize_json_names?
73
+ @base_client.options.symbolize_json_names
74
+ end
75
+
72
76
  private
73
77
 
74
78
  def make_local
@@ -42,7 +42,7 @@ module Prefab
42
42
  if raw_json
43
43
  @config_value.json.json
44
44
  else
45
- JSON.parse(@config_value.json.json)
45
+ JSON.parse(@config_value.json.json, symbolize_names: @resolver.symbolize_json_names?)
46
46
  end
47
47
  else
48
48
  LOG.error "Unknown type: #{@config_value.type}"
@@ -20,6 +20,7 @@ module Prefab
20
20
  attr_reader :datafile
21
21
  attr_reader :global_context
22
22
  attr_accessor :is_fork
23
+ attr_reader :symbolize_json_names
23
24
 
24
25
  module ON_INITIALIZATION_FAILURE
25
26
  RAISE = :raise
@@ -69,6 +70,7 @@ module Prefab
69
70
  datafile: ENV['PREFAB_DATAFILE'],
70
71
  x_datafile: nil, # DEPRECATED in favor of `datafile`
71
72
  x_use_local_cache: false,
73
+ symbolize_json_names: false,
72
74
  global_context: {}
73
75
  )
74
76
  @api_key = api_key
@@ -96,6 +98,7 @@ module Prefab
96
98
  @use_local_cache = x_use_local_cache
97
99
  @is_fork = false
98
100
  @global_context = global_context
101
+ @symbolize_json_names = symbolize_json_names
99
102
 
100
103
  # defaults that may be overridden by context_upload_mode
101
104
  @collect_shapes = false
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: prefab-cloud-ruby 1.8.6 ruby lib
5
+ # stub: prefab-cloud-ruby 1.8.7 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "prefab-cloud-ruby".freeze
9
- s.version = "1.8.6"
9
+ s.version = "1.8.7"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["Jeff Dwyer".freeze]
14
- s.date = "2024-10-07"
14
+ s.date = "2024-10-25"
15
15
  s.description = "Feature Flags, Live Config, and Dynamic Log Levels as a service".freeze
16
16
  s.email = "jdwyer@prefab.cloud".freeze
17
17
  s.extra_rdoc_files = [
@@ -65,10 +65,25 @@ class TestConfigValueUnwrapper < Minitest::Test
65
65
  assert_equal 390605 ,unwrap(config_value, CONFIG, EMPTY_CONTEXT).in_seconds
66
66
  end
67
67
 
68
- def test_unwrapping_json
68
+ def test_unwrapping_json
69
69
  json = PrefabProto::Json.new(json: '{"a": 1, "b": "c"}')
70
70
  config_value = PrefabProto::ConfigValue.new(json: json)
71
- assert_equal({"a" => 1, "b" => "c"}, unwrap(config_value, CONFIG, EMPTY_CONTEXT))
71
+ assert_equal({"a" => 1, "b" => "c"}, unwrap(config_value, CONFIG, EMPTY_CONTEXT))
72
+ end
73
+
74
+ def test_unwrapping_json_with_symbolize_json_names_true
75
+ @mock_resolver = MockResolver.new(symbolize_json_names: true)
76
+ json = PrefabProto::Json.new(json: '{"a": 1, "b": "c"}')
77
+ config_value = PrefabProto::ConfigValue.new(json: json)
78
+ assert_equal({:a => 1, :b => "c"}, unwrap(config_value, CONFIG, EMPTY_CONTEXT))
79
+
80
+ json = PrefabProto::Json.new(json: '{"foo": { "bar": "baz"}, "cow": "moo"}')
81
+ config_value = PrefabProto::ConfigValue.new(json: json)
82
+ assert_equal({:foo=>{:bar=>"baz"}, :cow=>"moo"}, unwrap(config_value, CONFIG, EMPTY_CONTEXT))
83
+
84
+ json = PrefabProto::Json.new(json: '[{"foo": { "bar": "baz"}}, {"cow": "moo"}]')
85
+ config_value = PrefabProto::ConfigValue.new(json: json)
86
+ assert_equal([{:foo=>{:bar=>"baz"}}, {:cow=>"moo"}], unwrap(config_value, CONFIG, EMPTY_CONTEXT))
72
87
  end
73
88
 
74
89
  def test_unwrapping_weighted_values
@@ -228,6 +243,15 @@ class TestConfigValueUnwrapper < Minitest::Test
228
243
  end
229
244
 
230
245
  class MockResolver
246
+
247
+ def initialize(symbolize_json_names: false)
248
+ @symbolize_json_names = symbolize_json_names
249
+ end
250
+
251
+ def symbolize_json_names?
252
+ @symbolize_json_names
253
+ end
254
+
231
255
  def get(key)
232
256
  if DECRYPTION_KEY_NAME == key
233
257
  Prefab::Evaluation.new(config: PrefabProto::Config.new(key: key),
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prefab-cloud-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.6
4
+ version: 1.8.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Dwyer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-07 00:00:00.000000000 Z
11
+ date: 2024-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby