launchdarkly-server-sdk 8.0.0 → 8.1.0

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
  SHA256:
3
- metadata.gz: bdb1eeb75ade6b2f82e1271c763f74ae577da09510e585b7cc1076ae9ff594d7
4
- data.tar.gz: 8f794b216dff21125547319781efc2d77ce1632af6faccd8fa3c7fd96e2c8216
3
+ metadata.gz: 133fe555993b53f1e53f3348242d1c96ac2318d2c2c1ebf48e33e4d23c6e97f3
4
+ data.tar.gz: 12f604c2a17d9d06433a1ad041051e41f767efa3c7310a5925553cb5678b5709
5
5
  SHA512:
6
- metadata.gz: 1ad1349bf430c6bb3a821d033f11106883c25d68aadc10bd622809b4c6dfe04e55ada3b9a49b8c92588389a4b3fb2112b1fd4fb63cdedf264cd3a0cc0bc0ac26
7
- data.tar.gz: 6a605bd4f7ea9c7af3454e9a70bf5b3db1057456e5fc96249c807a706b0ca2fa8f0d3bd1238dae7e2fa5778ffe5d3b8728c9085499df0d952f76b3e41dcfa7a7
6
+ metadata.gz: 1be2d4708681d7e0a2665e68e878ed8d2e17975f6c28716ed139911b866acb067884b4af872e6f5469177f09b5071f1c8fbb0ac6b7519f581bb20ee11afb76df
7
+ data.tar.gz: 2d0a5df44d5de21887eb4330f34bf65d4a4bab9a153d7644077790e3262a8b6418c26c4ebe5612523be468d05ddd5a8b837dc22a347c08ef463229c337e040c3
data/README.md CHANGED
@@ -3,7 +3,7 @@ LaunchDarkly Server-side SDK for Ruby
3
3
 
4
4
  [![Gem Version](https://badge.fury.io/rb/launchdarkly-server-sdk.svg)](http://badge.fury.io/rb/launchdarkly-server-sdk)
5
5
 
6
- [![Circle CI](https://circleci.com/gh/launchdarkly/ruby-server-sdk/tree/main.svg?style=svg)](https://circleci.com/gh/launchdarkly/ruby-server-sdk/tree/main)
6
+ [![Run CI](https://github.com/launchdarkly/ruby-server-sdk/actions/workflows/ci.yml/badge.svg)](https://github.com/launchdarkly/ruby-server-sdk/actions/workflows/ci.yml)
7
7
  [![RubyDoc](https://img.shields.io/static/v1?label=docs+-+all+versions&message=reference&color=00add8)](https://www.rubydoc.info/gems/launchdarkly-server-sdk)
8
8
  [![GitHub Pages](https://img.shields.io/static/v1?label=docs+-+latest&message=reference&color=00add8)](https://launchdarkly.github.io/ruby-server-sdk)
9
9
 
@@ -47,9 +47,6 @@ module LaunchDarkly
47
47
  # @return [String, nil] Returns the error associated with this LDContext if invalid
48
48
  attr_reader :error
49
49
 
50
- # @return [Array<Reference>] Returns the private attributes associated with this LDContext
51
- attr_reader :private_attributes
52
-
53
50
  #
54
51
  # @private
55
52
  # @param key [String, nil]
@@ -69,10 +66,10 @@ module LaunchDarkly
69
66
  @name = name
70
67
  @anonymous = anonymous || false
71
68
  @attributes = attributes
72
- @private_attributes = []
69
+ @private_attributes = Set.new
73
70
  (private_attributes || []).each do |attribute|
74
71
  reference = Reference.create(attribute)
75
- @private_attributes << reference if reference.error.nil?
72
+ @private_attributes.add(reference) if reference.error.nil?
76
73
  end
77
74
  @error = error
78
75
  @contexts = contexts
@@ -80,6 +77,16 @@ module LaunchDarkly
80
77
  end
81
78
  private_class_method :new
82
79
 
80
+ protected attr_reader :name, :anonymous, :attributes
81
+
82
+ #
83
+ # @return [Array<Reference>] Returns the private attributes associated with this LDContext
84
+ #
85
+ def private_attributes
86
+ # TODO(sc-227265): Return a set instead of an array.
87
+ @private_attributes.to_a
88
+ end
89
+
83
90
  #
84
91
  # @return [Boolean] Is this LDContext a multi-kind context?
85
92
  #
@@ -274,6 +281,59 @@ module LaunchDarkly
274
281
  nil
275
282
  end
276
283
 
284
+ #
285
+ # An LDContext can be compared to other LDContexts or to a hash object. If
286
+ # a hash is provided, it is first converted to an LDContext using the
287
+ # `LDContext.create` method.
288
+ #
289
+ # @param other [LDContext, Hash]
290
+ # @return [Boolean]
291
+ #
292
+ def ==(other)
293
+ other = LDContext.create(other) if other.is_a? Hash
294
+ return false unless other.is_a? LDContext
295
+
296
+ return false unless self.kind == other.kind
297
+ return false unless self.valid? == other.valid?
298
+ return false unless self.error == other.error
299
+
300
+ return false unless self.individual_context_count == other.individual_context_count
301
+
302
+ if self.multi_kind?
303
+ self.kinds.each do |kind|
304
+ return false unless self.individual_context(kind) == other.individual_context(kind)
305
+ end
306
+
307
+ return true
308
+ end
309
+
310
+ return false unless self.key == other.key
311
+ return false unless self.name == other.name
312
+ return false unless self.anonymous == other.anonymous
313
+ return false unless self.attributes == other.attributes
314
+
315
+ # TODO(sc-227265): Calling .to_set is unnecessary once private_attributes are sets.
316
+ return false unless self.private_attributes.to_set == other.private_attributes.to_set
317
+
318
+ true
319
+ end
320
+ alias eql? ==
321
+
322
+ #
323
+ # For a single-kind context, the provided key will return the attribute value specified. This is the same as calling
324
+ # `LDCotnext.get_value`.
325
+ #
326
+ # For multi-kind contexts, the key will be interpreted as a context kind. If the multi-kind context has an
327
+ # individual context of that kind, it will be returned. Otherwise, this method will return nil. This behaves the
328
+ # same as calling `LDContext.individual_context`.
329
+ #
330
+ # @param key [Symbol, String]
331
+ #
332
+ def [](key)
333
+ return nil unless key.is_a? Symbol or key.is_a? String
334
+ multi_kind? ? individual_context(key.to_s) : get_value(key)
335
+ end
336
+
277
337
  #
278
338
  # Retrieve the value of any top level, addressable attribute.
279
339
  #
@@ -142,4 +142,4 @@ module LaunchDarkly
142
142
  end
143
143
  end
144
144
  end
145
- end
145
+ end
@@ -112,7 +112,7 @@ module LaunchDarkly
112
112
  @pool = create_redis_pool(opts)
113
113
 
114
114
  # shutdown pool on close unless the client passed a custom pool and specified not to shutdown
115
- @pool_shutdown_on_close = (!opts[:pool] || opts.fetch(:pool_shutdown_on_close, true))
115
+ @pool_shutdown_on_close = !opts[:pool] || opts.fetch(:pool_shutdown_on_close, true)
116
116
 
117
117
  @prefix = opts[:prefix] || LaunchDarkly::Integrations::Redis::default_prefix
118
118
  @logger = opts[:logger] || Config.default_logger
@@ -93,6 +93,7 @@ module LaunchDarkly
93
93
 
94
94
  if @config.use_ldd?
95
95
  @config.logger.info { "[LDClient] Started LaunchDarkly Client in LDD mode" }
96
+ @data_source = NullUpdateProcessor.new
96
97
  return # requestor and update processor are not used in this mode
97
98
  end
98
99
 
@@ -109,6 +109,8 @@ module LaunchDarkly
109
109
  end
110
110
  private_class_method :new
111
111
 
112
+ protected attr_reader :components
113
+
112
114
  #
113
115
  # Creates a Reference from a string. For the supported syntax and examples,
114
116
  # see comments on the Reference type.
@@ -227,6 +229,15 @@ module LaunchDarkly
227
229
  @components[index]
228
230
  end
229
231
 
232
+ def ==(other)
233
+ self.error == other.error && self.components == other.components
234
+ end
235
+ alias eql? ==
236
+
237
+ def hash
238
+ ([error] + components).hash
239
+ end
240
+
230
241
  #
231
242
  # Performs unescaping of attribute reference path components:
232
243
  #
@@ -1,3 +1,3 @@
1
1
  module LaunchDarkly
2
- VERSION = "8.0.0"
2
+ VERSION = "8.1.0" # x-release-please-version
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: launchdarkly-server-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.0.0
4
+ version: 8.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - LaunchDarkly
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-17 00:00:00.000000000 Z
11
+ date: 2024-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-dynamodb
@@ -361,7 +361,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
361
361
  - !ruby/object:Gem::Version
362
362
  version: '0'
363
363
  requirements: []
364
- rubygems_version: 3.4.21
364
+ rubygems_version: 3.5.3
365
365
  signing_key:
366
366
  specification_version: 4
367
367
  summary: LaunchDarkly SDK for Ruby