openfeature-sdk 0.3.1 → 0.4.0

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: '08a030402839c73a3704f262d09a72b284c96de65c7bdfb09b3020aa180b3448'
4
- data.tar.gz: 4834664e0fced5480a5a36c3adad3ee64ab964ddd90de99fd4f477e168e78fe5
3
+ metadata.gz: 121bf1c0f068a672898b818d3241b8a62eb31bfc16b5c777064b509c05c75ffa
4
+ data.tar.gz: e48cd05f98c6cc4c54697d716ea6c3fcee273b602de2fdf743a3bfb2b7cc65c1
5
5
  SHA512:
6
- metadata.gz: 03d9d6b4fe3af45924f87a356e3f099789c44763a696e55132f31c263c6ef1fce00a4fdabb7b3224113e23f85d5fc00b43e2cebb8f8e05608e3decaedf39d29b
7
- data.tar.gz: 9a27d780aec56d644bcda6232d91f03a9ff7022a973f8ef1adbd860a8f2e5d1ab0ab180760a6f30e4f5de22d059f1ef1fbf7473c6adafbc77a52385ea36e291e
6
+ metadata.gz: 60bea62f478cc58a7a5b4a5defc6b51fc1dc9af83770102ef49ad26d3604d25ceb76f2752edbfdec6d598c8ee0f7aaefb6d8ded5d437ab1e041c921438b5be71
7
+ data.tar.gz: b13c80c92cbafe9902f445e9bbd170cec6ca4fd2a73c86f72bfaf7c09cd208ef75ba27b6f69f9a72d58a0f59bf1b65f44275abb27b18493029524661697d6f64
@@ -1,3 +1,3 @@
1
1
  {
2
- ".": "0.3.1"
2
+ ".": "0.4.0"
3
3
  }
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.3.0
1
+ 3.3.3
data/.tool-versions CHANGED
@@ -1 +1 @@
1
- ruby 3.3.0
1
+ ruby 3.3.3
data/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.4.0](https://github.com/open-feature/ruby-sdk/compare/v0.3.1...v0.4.0) (2024-06-13)
4
+
5
+
6
+ ### ⚠ BREAKING CHANGES
7
+
8
+ * Use strings from spec for error and reason enums ([#131](https://github.com/open-feature/ruby-sdk/issues/131))
9
+
10
+ ### Features
11
+
12
+ * add hook hints ([#135](https://github.com/open-feature/ruby-sdk/issues/135)) ([51155a7](https://github.com/open-feature/ruby-sdk/commit/51155a7d9cd2c28b38accb9d9b49018bd4868040))
13
+ * Use strings from spec for error and reason enums ([#131](https://github.com/open-feature/ruby-sdk/issues/131)) ([cb2a4cd](https://github.com/open-feature/ruby-sdk/commit/cb2a4cd54059ffe7ed3484be6705ca2a9d590c1a))
14
+
15
+
16
+ ### Bug Fixes
17
+
18
+ * synchronize provider registration ([#136](https://github.com/open-feature/ruby-sdk/issues/136)) ([1ff6fd0](https://github.com/open-feature/ruby-sdk/commit/1ff6fd0c3732e9e074c8b30cbe4164a67286b0a4))
19
+
3
20
  ## [0.3.1](https://github.com/open-feature/ruby-sdk/compare/v0.3.0...v0.3.1) (2024-04-22)
4
21
 
5
22
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- openfeature-sdk (0.3.1)
4
+ openfeature-sdk (0.4.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -16,6 +16,7 @@ module OpenFeature
16
16
  def initialize
17
17
  @hooks = []
18
18
  @providers = {}
19
+ @provider_mutex = Mutex.new
19
20
  end
20
21
 
21
22
  def provider(domain: nil)
@@ -27,11 +28,13 @@ module OpenFeature
27
28
  # 2. On the new provider, call `init`.
28
29
  # 3. Finally, set the internal provider to the new provider
29
30
  def set_provider(provider, domain: nil)
30
- @providers[domain].shutdown if @providers[domain].respond_to?(:shutdown)
31
-
32
- provider.init if provider.respond_to?(:init)
33
-
34
- @providers[domain] = provider
31
+ @provider_mutex.synchronize do
32
+ @providers[domain].shutdown if @providers[domain].respond_to?(:shutdown)
33
+ provider.init if provider.respond_to?(:init)
34
+ new_providers = @providers.dup
35
+ new_providers[domain] = provider
36
+ @providers = new_providers
37
+ end
35
38
  end
36
39
  end
37
40
  end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OpenFeature
4
+ module SDK
5
+ module Hooks
6
+ class Hints < DelegateClass(Hash)
7
+ ALLOWED_TYPES = [String, Symbol, Numeric, TrueClass, FalseClass, Time, Hash, Array].freeze
8
+
9
+ def initialize(hash = {})
10
+ hash.each do |key, value|
11
+ assert_allowed_key(key)
12
+ assert_allowed_value(value)
13
+ end
14
+ @hash = hash.dup
15
+ super(@hash)
16
+ freeze
17
+ end
18
+
19
+ private
20
+
21
+ def assert_allowed_key(key)
22
+ raise ArgumentError, "Only String or Symbol are allowed as keys." unless key.is_a?(String) || key.is_a?(Symbol)
23
+ end
24
+
25
+ def assert_allowed_value(value)
26
+ allowed_type = ALLOWED_TYPES.any? { |t| value.is_a?(t) }
27
+ raise ArgumentError, "Only #{ALLOWED_TYPES.join(", ")} are allowed as values." unless allowed_type
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -2,13 +2,14 @@ module OpenFeature
2
2
  module SDK
3
3
  module Provider
4
4
  module ErrorCode
5
- PROVIDER_NOT_READY = "Provider Not Ready"
6
- FLAG_NOT_FOUND = "Flag Not Found"
7
- PARSE_ERROR = "Parse Error"
8
- TYPE_MISMATCH = "Type Mismatch"
9
- TARGETING_KEY_MISSING = "Targeting Key Missing"
10
- INVALID_CONTEXT = "Invalid Context"
11
- GENERAL = "General"
5
+ PROVIDER_NOT_READY = "PROVIDER_NOT_READY"
6
+ FLAG_NOT_FOUND = "FLAG_NOT_FOUND"
7
+ PARSE_ERROR = "PARSE_ERROR"
8
+ TYPE_MISMATCH = "TYPE_MISMATCH"
9
+ TARGETING_KEY_MISSING = "TARGETING_KEY_MISSING"
10
+ INVALID_CONTEXT = "INVALID_CONTEXT"
11
+ PROVIDER_FATAL = "PROVIDER_FATAL"
12
+ GENERAL = "GENERAL"
12
13
  end
13
14
  end
14
15
  end
@@ -2,15 +2,15 @@ module OpenFeature
2
2
  module SDK
3
3
  module Provider
4
4
  module Reason
5
- STATIC = "Static"
6
- DEFAULT = "Default"
7
- TARGETING_MATCH = "Targeting Match"
8
- SPLIT = "Split"
9
- CACHED = "Cached"
10
- DISABLED = "Disabled"
11
- UNKNOWN = "Unknown"
12
- STALE = "Stale"
13
- ERROR = "Error"
5
+ STATIC = "STATIC"
6
+ DEFAULT = "DEFAULT"
7
+ TARGETING_MATCH = "TARGETING_MATCH"
8
+ SPLIT = "SPLIT"
9
+ CACHED = "CACHED"
10
+ DISABLED = "DISABLED"
11
+ UNKNOWN = "UNKNOWN"
12
+ STALE = "STALE"
13
+ ERROR = "ERROR"
14
14
  end
15
15
  end
16
16
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OpenFeature
4
4
  module SDK
5
- VERSION = "0.3.1"
5
+ VERSION = "0.4.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openfeature-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenFeature Authors
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-04-22 00:00:00.000000000 Z
11
+ date: 2024-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: debug
@@ -152,6 +152,7 @@ files:
152
152
  - lib/open_feature/sdk/evaluation_context.rb
153
153
  - lib/open_feature/sdk/evaluation_context_builder.rb
154
154
  - lib/open_feature/sdk/evaluation_details.rb
155
+ - lib/open_feature/sdk/hooks/hints.rb
155
156
  - lib/open_feature/sdk/provider.rb
156
157
  - lib/open_feature/sdk/provider/error_code.rb
157
158
  - lib/open_feature/sdk/provider/in_memory_provider.rb
@@ -186,7 +187,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
186
187
  - !ruby/object:Gem::Version
187
188
  version: '0'
188
189
  requirements: []
189
- rubygems_version: 3.5.3
190
+ rubygems_version: 3.5.11
190
191
  signing_key:
191
192
  specification_version: 4
192
193
  summary: OpenFeature SDK for Ruby