openfeature-sdk-sorbet 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (26) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +7 -7
  3. data/CHANGELOG.md +10 -10
  4. data/Gemfile.lock +1 -1
  5. data/README.md +20 -18
  6. data/lib/{open_feature → open_feature_sorbet}/client.rb +6 -6
  7. data/lib/{open_feature → open_feature_sorbet}/client_metadata.rb +1 -1
  8. data/lib/{open_feature → open_feature_sorbet}/configuration.rb +2 -2
  9. data/lib/{open_feature → open_feature_sorbet}/error_code.rb +1 -1
  10. data/lib/{open_feature → open_feature_sorbet}/evaluation_context.rb +1 -1
  11. data/lib/{open_feature → open_feature_sorbet}/evaluation_context_builder.rb +1 -1
  12. data/lib/{open_feature → open_feature_sorbet}/evaluation_details.rb +1 -1
  13. data/lib/{open_feature → open_feature_sorbet}/evaluation_options.rb +1 -1
  14. data/lib/{open_feature → open_feature_sorbet}/flag_metadata.rb +1 -1
  15. data/lib/{open_feature → open_feature_sorbet}/hook.rb +6 -6
  16. data/lib/{open_feature → open_feature_sorbet}/hook_context.rb +4 -4
  17. data/lib/{open_feature → open_feature_sorbet}/hooks.rb +1 -1
  18. data/lib/{open_feature → open_feature_sorbet}/multiple_source_provider.rb +1 -1
  19. data/lib/{open_feature → open_feature_sorbet}/no_op_provider.rb +1 -1
  20. data/lib/{open_feature → open_feature_sorbet}/provider.rb +1 -1
  21. data/lib/{open_feature → open_feature_sorbet}/provider_metadata.rb +1 -1
  22. data/lib/{open_feature → open_feature_sorbet}/provider_status.rb +1 -1
  23. data/lib/{open_feature → open_feature_sorbet}/resolution_details.rb +1 -1
  24. data/lib/{open_feature → open_feature_sorbet}/structure.rb +1 -1
  25. data/lib/{open_feature.rb → open_feature_sorbet.rb} +1 -1
  26. metadata +22 -22
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c618b9b2a1026874a45d03ea989183343bb2653a0de5184d510ba37b37d7abfe
4
- data.tar.gz: 6573830336c85fb9c4bc66a3903dde8745947b510d45d145e040f4f5592d9eaa
3
+ metadata.gz: d4c602dee15992f209891df9bfcfa7dac28a786bbef9d3943538f1de80e21496
4
+ data.tar.gz: edb41a3936933b08581683adb6e2020e92ebee2f92f4cf11e3af84ffb1e2ed21
5
5
  SHA512:
6
- metadata.gz: 02a81d4faa83f8915aa40f6b23aa8261746ef3d3df0ad4155d5a56a12aad98f81fc5a58b7c874e62253e7e43b92d92980b8adf307fd39fce02140e609598a7bd
7
- data.tar.gz: 3572884d4efb1813c9388534758ebca4791c1f00c1682e8edaa0fb337d1f327be4efd4df1ccd51f7954f23095d6de13ed7818fc065eb143b3a9f62e165d1118e
6
+ metadata.gz: c4034f39bd39dd8f31802c426088f7c65597814888bf463c06bb3586321e4d8e08beae0eb5716bab5c0b0d753344fd6bc097487336386edad33d7f1e0dd3205f
7
+ data.tar.gz: 7c52323bfecad7627afdbeee236b5ca8d0be775adea5c57eec2b61b803d3167c28cfb5a4d919309d4ca65088edb8a9cd8b5c55dee6c45d611921d7d6005b21a8
data/.rubocop.yml CHANGED
@@ -15,19 +15,19 @@ AllCops:
15
15
  - sorbet/**/*.rbi
16
16
 
17
17
  Layout/LineLength:
18
- Max: 120
18
+ Max: 130
19
19
 
20
20
  Lint/UnusedMethodArgument:
21
21
  Exclude:
22
- - lib/open_feature/multiple_source_provider.rb
23
- - lib/open_feature/no_op_provider.rb
22
+ - lib/open_feature_sorbet/multiple_source_provider.rb
23
+ - lib/open_feature_sorbet/no_op_provider.rb
24
24
 
25
25
  Metrics/ClassLength:
26
26
  Exclude:
27
- - lib/open_feature/client.rb
28
- - lib/open_feature/multiple_source_provider.rb
29
- - test/open_feature/client_test.rb
30
- - test/open_feature/multiple_source_provider_test.rb
27
+ - lib/open_feature_sorbet/client.rb
28
+ - lib/open_feature_sorbet/multiple_source_provider.rb
29
+ - test/open_feature_sorbet/client_test.rb
30
+ - test/open_feature_sorbet/multiple_source_provider_test.rb
31
31
 
32
32
  Metrics/MethodLength:
33
33
  Exclude:
data/CHANGELOG.md CHANGED
@@ -26,25 +26,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
26
26
 
27
27
  ### Added
28
28
 
29
- - Added `OpenFeature::Provider#status` reader that returns an `OpenFeature::ProviderStatus`.
30
- - Added `OpenFeature::Provider#init` as an overridable method on `Provider`s that can perform any initialization work for the given provider. This method accepts the global `EvaluationContext` and has a `void` return type. The default implementation is a no-op.
31
- - Added `OpenFeature::Provider#shutdown` as an overridable method on `Provider`s that can perform any cleanup work for the given provider. This method has a `void` return type and the default implementation is a no-op.
29
+ - Added `OpenFeatureSorbet::Provider#status` reader that returns an `OpenFeatureSorbet::ProviderStatus`.
30
+ - Added `OpenFeatureSorbet::Provider#init` as an overridable method on `Provider`s that can perform any initialization work for the given provider. This method accepts the global `EvaluationContext` and has a `void` return type. The default implementation is a no-op.
31
+ - Added `OpenFeatureSorbet::Provider#shutdown` as an overridable method on `Provider`s that can perform any cleanup work for the given provider. This method has a `void` return type and the default implementation is a no-op.
32
32
  - Added `OpenFeature.shutdown` to invoke the current provider's `shutdown` method.
33
33
 
34
34
  ### Changed
35
35
 
36
36
  - *Breaking* Changed minimum supported Ruby version to 3.1.
37
- - *Breaking* `OpenFeature::Provider` changed from a module interface to an abstract class to support default method implementations.
38
- - *Breaking* `OpenFeature::Provider.initialize` now must accept an `OpenFeature::ProviderStatus`. Any providers may pass this in during initialization. If you need to do additional setup in `Provider.init`, we recommend you pass `OpenFeature::ProviderStatus::NotReady` here.
37
+ - *Breaking* `OpenFeatureSorbet::Provider` changed from a module interface to an abstract class to support default method implementations.
38
+ - *Breaking* `OpenFeatureSorbet::Provider.initialize` now must accept an `OpenFeatureSorbet::ProviderStatus`. Any providers may pass this in during initialization. If you need to do additional setup in `Provider.init`, we recommend you pass `OpenFeatureSorbet::ProviderStatus::NotReady` here.
39
39
 
40
40
  ## [0.2.0] - 2023-05-17
41
41
 
42
42
  ### Added
43
43
 
44
- - Added ability to set evaluation context globally on the `Configuration` singleton, i.e. `OpenFeature::Configuration.instance.evaluation_context = OpenFeature::EvaluationContext.new(fields: { "globally" => "available" })`.
45
- - Added ability to set evaluation context globally on the `OpenFeature` module, i.e. `OpenFeature.set_evaluation_context(OpenFeature::EvaluationContext.new(fields: { "globally" => "available" }))`.
46
- - Added ability to set evaluation context on a `Client` instance, i.e. `client.evaluation_context = OpenFeature::EvaluationContext.new(fields: { "client" => "available" })`.
47
- - Added ability to set hooks and evaluation context on `Client` initialization, i.e. `OpenFeature.create_client(name: "my_client", evaluation_context: OpenFeature::EvaluationContext.new(fields: { "client" => "available" }), hooks: OpenFeature::Hook.new)`
44
+ - Added ability to set evaluation context globally on the `Configuration` singleton, i.e. `OpenFeatureSorbet::Configuration.instance.evaluation_context = OpenFeatureSorbet::EvaluationContext.new(fields: { "globally" => "available" })`.
45
+ - Added ability to set evaluation context globally on the `OpenFeature` module, i.e. `OpenFeature.set_evaluation_context(OpenFeatureSorbet::EvaluationContext.new(fields: { "globally" => "available" }))`.
46
+ - Added ability to set evaluation context on a `Client` instance, i.e. `client.evaluation_context = OpenFeatureSorbet::EvaluationContext.new(fields: { "client" => "available" })`.
47
+ - Added ability to set hooks and evaluation context on `Client` initialization, i.e. `OpenFeature.create_client(name: "my_client", evaluation_context: OpenFeatureSorbet::EvaluationContext.new(fields: { "client" => "available" }), hooks: OpenFeatureSorbet::Hook.new)`
48
48
  - Added `Configuration#reset!` to reset global configuration to the default state.
49
49
 
50
50
  ### Changed
@@ -61,7 +61,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
61
61
 
62
62
  ### Added
63
63
 
64
- - Introduced `OpenFeature::MultipleSourceProvider` to allow fetching flags from multiple sources.
64
+ - Introduced `OpenFeatureSorbet::MultipleSourceProvider` to allow fetching flags from multiple sources.
65
65
 
66
66
  ## [0.1.1] - 2023-05-15
67
67
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- openfeature-sdk-sorbet (0.4.0)
4
+ openfeature-sdk-sorbet (0.5.0)
5
5
  sorbet-runtime (~> 0.5)
6
6
  sorbet-struct-comparable (~> 1.3)
7
7
  zeitwerk (~> 2.6)
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Sorbet-aware OpenFeature Ruby Implementation
2
2
 
3
+ **NOTE** This implementation has been deprecated in favor of the [official Ruby SDK](https://github.com/open-feature/ruby-sdk). We recommend switching to that. In the future, we hope to add RBS and Tapioca DSL generation support to the official library.
4
+
3
5
  [OpenFeature](https://openfeature.dev) is an open standard for vendor-agnostic feature flagging. [Sorbet](https://sorbet.org) is a type-checker for Ruby, built by Stripe. Sorbet provides powerful runtime utilities to achieve things traditionally not possible with Ruby, such as interfaces, immutable structures and enums. This makes it a very good option when defining specifications.
4
6
 
5
7
  If an organization is not already using Sorbet, you probably don't want to introduce a dependency on `sorbet-runtime`, which this gem does. As such, this will always be a distinct implementation, separate from the official [Ruby SDK](https://github.com/open-feature/ruby-sdk).
@@ -21,15 +23,15 @@ If bundler is not being used to manage dependencies, install the gem by executin
21
23
  ## Usage
22
24
 
23
25
  ```ruby
24
- require "open_feature"
26
+ require "open_feature_sorbet"
25
27
 
26
28
  # Configure global API properties
27
29
 
28
- OpenFeature.set_provider(OpenFeature::NoOpProvider.new)
29
- OpenFeature.set_evaluation_context(OpenFeature::EvaluationContext.new(fields: { "globally" => "available" }))
30
- OpenFeature.add_hooks([OpenFeature::Hook.new]) # experimental, not fully supported
30
+ OpenFeature.set_provider(OpenFeatureSorbet::NoOpProvider.new)
31
+ OpenFeature.set_evaluation_context(OpenFeatureSorbet::EvaluationContext.new(fields: { "globally" => "available" }))
32
+ OpenFeature.add_hooks([OpenFeatureSorbet::Hook.new]) # experimental, not fully supported
31
33
 
32
- client = OpenFeature.create_client(evaluation_context: OpenFeature::EvaluationContext.new(fields: { "client" => "available" }))
34
+ client = OpenFeature.create_client(evaluation_context: OpenFeatureSorbet::EvaluationContext.new(fields: { "client" => "available" }))
33
35
 
34
36
  # Fetch boolean value
35
37
  # Also methods available for String, Number, Integer, Float and Structure (Hash)
@@ -39,7 +41,7 @@ bool_value = client.fetch_boolean_value(flag_key: "my_toggle", default_value: fa
39
41
  bool_value = client.fetch_boolean_value(flag_key: "my_toggle", default_value: "bad!") # => raises TypeError from Sorbet, invalid default value
40
42
 
41
43
  # Additional evaluation context can be provided during invocation
42
- number_value = client.fetch_number_value(flag_key: "my_toggle", default_value: 1, context: OpenFeature::EvaluationContext.new(fields: { "only_this_call_site" => 10 })) # => merges client and global context
44
+ number_value = client.fetch_number_value(flag_key: "my_toggle", default_value: 1, context: OpenFeatureSorbet::EvaluationContext.new(fields: { "only_this_call_site" => 10 })) # => merges client and global context
43
45
 
44
46
  # Fetch structure evaluation details
45
47
  structure_evaluation_details = client.fetch_structure_details(flag_key: "my_structure", default_value: { "a" => "fallback" }) # => EvaluationDetails(value: Hash, flag_key: "my_structure", ...)
@@ -55,15 +57,15 @@ We support global evaluation context (set on the `OpenFeature` module), client e
55
57
 
56
58
  ### Provider Abstract Class
57
59
 
58
- By default, this implementation sets the provider to the `OpenFeature::NoOpProvider` which always returns the default value. It's up to the individual teams to define their own providers based on their flag source (in the future, I'll release open-source providers based on various, common vendors).
60
+ By default, this implementation sets the provider to the `OpenFeatureSorbet::NoOpProvider` which always returns the default value. It's up to the individual teams to define their own providers based on their flag source (in the future, I'll release open-source providers based on various, common vendors).
59
61
 
60
- This gem also provides `OpenFeature::MultipleSourceProvider` to allow fetching flags from multiple sources. This is especially useful if your existing application has flags spread across bespoke and vendor solutions and you want to unify the evaluation sites. It can be instantiated and configured like so:
62
+ This gem also provides `OpenFeatureSorbet::MultipleSourceProvider` to allow fetching flags from multiple sources. This is especially useful if your existing application has flags spread across bespoke and vendor solutions and you want to unify the evaluation sites. It can be instantiated and configured like so:
61
63
 
62
64
  ```ruby
63
- provider = OpenFeature::MultipleSourceProvider.new(
65
+ provider = OpenFeatureSorbet::MultipleSourceProvider.new(
64
66
  providers: [
65
67
  CustomProvider.new,
66
- OpenFeature::NoOpProvider.new
68
+ OpenFeatureSorbet::NoOpProvider.new
67
69
  ]
68
70
  )
69
71
 
@@ -75,17 +77,17 @@ OpenFeature.set_provider(provider)
75
77
  Thanks to Sorbet abstract classes, it's fairly straightforward to implement a new provider. Here is an example for a JSON-based flag format on disk:
76
78
 
77
79
  ```ruby
78
- class JsonFileFlagProvider < OpenFeature::Provider
80
+ class JsonFileFlagProvider < OpenFeatureSorbet::Provider
79
81
  extend T::Sig
80
82
 
81
83
  sig { void }
82
84
  def initialize
83
- super(OpenFeature::ProviderStatus::NotReady)
85
+ super(OpenFeatureSorbet::ProviderStatus::NotReady)
84
86
  end
85
87
 
86
88
  def init(context)
87
89
  @file = File.open(context.file || "flags.json")
88
- @status = OpenFeature::ProviderStatus::Ready
90
+ @status = OpenFeatureSorbet::ProviderStatus::Ready
89
91
  end
90
92
 
91
93
  sig { overridable.void }
@@ -93,9 +95,9 @@ class JsonFileFlagProvider < OpenFeature::Provider
93
95
  @file.close
94
96
  end
95
97
 
96
- sig { override.returns(OpenFeature::ProviderMetadata) }
98
+ sig { override.returns(OpenFeatureSorbet::ProviderMetadata) }
97
99
  def metadata
98
- OpenFeature::ProviderMetadata.new(name: "Json File Flag Provider")
100
+ OpenFeatureSorbet::ProviderMetadata.new(name: "Json File Flag Provider")
99
101
  end
100
102
 
101
103
  sig { override.returns(T::Array[Hook]) }
@@ -110,13 +112,13 @@ class JsonFileFlagProvider < OpenFeature::Provider
110
112
  default_value: T::Boolean,
111
113
  context: T.nilable(EvaluationContext)
112
114
  )
113
- .returns(OpenFeature::ResolutionDetails[T::Boolean])
115
+ .returns(OpenFeatureSorbet::ResolutionDetails[T::Boolean])
114
116
  end
115
117
  def resolve_boolean_value(flag_key:, default_value:, context: nil)
116
118
  file_input = JSON.parse(File.read("flags.rb"))
117
119
  value = file_input.fetch("flag_key", default_value)
118
120
 
119
- OpenFeature::ResolutionDetails.new(
121
+ OpenFeatureSorbet::ResolutionDetails.new(
120
122
  value: value,
121
123
  # ... other optional fields
122
124
  )
@@ -126,7 +128,7 @@ class JsonFileFlagProvider < OpenFeature::Provider
126
128
  end
127
129
  ```
128
130
 
129
- By inheriting from the `OpenFeature::Provider` class, Sorbet will indicate what methods it's expecting and what their type signatures should be.
131
+ By inheriting from the `OpenFeatureSorbet::Provider` class, Sorbet will indicate what methods it's expecting and what their type signatures should be.
130
132
 
131
133
  ##### A note on `initialize` versus `init`
132
134
 
@@ -1,7 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- module OpenFeature
4
+ module OpenFeatureSorbet
5
5
  # Used during runtime for evaluating features.
6
6
  class Client
7
7
  extend T::Sig
@@ -247,14 +247,14 @@ module OpenFeature
247
247
  def build_context_with_before_hooks(flag_key:, default_value:, invocation_context:, options:, flag_type:)
248
248
  hook_context = build_hook_context(flag_key: flag_key, default_value: default_value,
249
249
  invocation_context: invocation_context, flag_type: flag_type)
250
- OpenFeature::Hook::BeforeHook.call(hooks: build_hooks(options), context: hook_context,
251
- hints: {})
250
+ OpenFeatureSorbet::Hook::BeforeHook.call(hooks: build_hooks(options), context: hook_context,
251
+ hints: {})
252
252
  end
253
253
 
254
254
  sig { params(options: T.nilable(EvaluationOptions)).returns(Hooks) }
255
255
  def build_hooks(options)
256
256
  Hooks.new(
257
- global: OpenFeature.configuration.hooks,
257
+ global: OpenFeatureSorbet.configuration.hooks,
258
258
  client: hooks,
259
259
  invocation: (options ? options.hooks : []),
260
260
  provider: provider.hooks
@@ -270,7 +270,7 @@ module OpenFeature
270
270
  ).returns(HookContext[T.type_parameter(:U)])
271
271
  end
272
272
  def build_hook_context(flag_key:, default_value:, invocation_context:, flag_type:)
273
- evaluation_context = build_context(invocation_context) || OpenFeature::EvaluationContext.new
273
+ evaluation_context = build_context(invocation_context) || OpenFeatureSorbet::EvaluationContext.new
274
274
  HookContext.new(flag_key: flag_key, default_value: default_value,
275
275
  evaluation_context: evaluation_context, flag_type: flag_type,
276
276
  client_metadata: client_metadata, provider_metadata: provider.metadata)
@@ -279,7 +279,7 @@ module OpenFeature
279
279
  sig { params(invocation_context: T.nilable(EvaluationContext)).returns(T.nilable(EvaluationContext)) }
280
280
  def build_context(invocation_context)
281
281
  EvaluationContextBuilder.new.call(
282
- global_context: OpenFeature.configuration.evaluation_context,
282
+ global_context: OpenFeatureSorbet.configuration.evaluation_context,
283
283
  client_context: evaluation_context,
284
284
  invocation_context: invocation_context
285
285
  )
@@ -1,7 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- module OpenFeature
4
+ module OpenFeatureSorbet
5
5
  # Defines information about a Client.
6
6
  class ClientMetadata < T::Struct
7
7
  include T::Struct::ActsAsComparable
@@ -3,7 +3,7 @@
3
3
 
4
4
  require "singleton"
5
5
 
6
- module OpenFeature
6
+ module OpenFeatureSorbet
7
7
  # Singleton class that supports global configuration for OpenFeature.
8
8
  # Should not be interacted with directly; rather, favor interacting
9
9
  # with methods defined on the `OpenFeature` module.
@@ -35,7 +35,7 @@ module OpenFeature
35
35
 
36
36
  sig { void }
37
37
  def reset!
38
- @provider = OpenFeature::NoOpProvider.new
38
+ @provider = OpenFeatureSorbet::NoOpProvider.new
39
39
  @hooks = []
40
40
  @evaluation_context = nil
41
41
  end
@@ -1,7 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- module OpenFeature
4
+ module OpenFeatureSorbet
5
5
  # Possible error codes
6
6
  class ErrorCode < T::Enum
7
7
  enums do
@@ -3,7 +3,7 @@
3
3
 
4
4
  require "date"
5
5
 
6
- module OpenFeature
6
+ module OpenFeatureSorbet
7
7
  # Provides ambient information for the purposes of flag evaluation.
8
8
  # Currently does not meet specification!
9
9
  class EvaluationContext < T::Struct
@@ -1,7 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- module OpenFeature
4
+ module OpenFeatureSorbet
5
5
  # Used to combine evaluation contexts from different sources
6
6
  class EvaluationContextBuilder
7
7
  extend T::Sig
@@ -1,7 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- module OpenFeature
4
+ module OpenFeatureSorbet
5
5
  # Information about resolved value, created by a Provider.
6
6
  class EvaluationDetails < T::Struct
7
7
  extend T::Generic
@@ -1,7 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- module OpenFeature
4
+ module OpenFeatureSorbet
5
5
  # Additional options to be supplied to client during flag evaluation.
6
6
  class EvaluationOptions < T::Struct
7
7
  const :hooks, T::Array[Hook], default: []
@@ -1,6 +1,6 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- module OpenFeature
4
+ module OpenFeatureSorbet
5
5
  FlagMetadata = T.type_alias { T::Hash[String, T.any(T::Boolean, String, Numeric)] }
6
6
  end
@@ -1,7 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- module OpenFeature
4
+ module OpenFeatureSorbet
5
5
  # See https://openfeature.dev/specification/sections/hooks
6
6
  # We model Hooks as a simple ADT
7
7
  module Hook
@@ -15,11 +15,11 @@ module OpenFeature
15
15
  include Hook
16
16
  extend T::Sig
17
17
  extend T::Helpers
18
- include OpenFeature::Hook
18
+ include OpenFeatureSorbet::Hook
19
19
  abstract!
20
20
  sig do
21
- abstract.params(context: OpenFeature::HookContext[T.untyped],
22
- hints: T::Hash[String, T.untyped]).returns(OpenFeature::EvaluationContext)
21
+ abstract.params(context: OpenFeatureSorbet::HookContext[T.untyped],
22
+ hints: T::Hash[String, T.untyped]).returns(OpenFeatureSorbet::EvaluationContext)
23
23
  end
24
24
  def call(context:, hints:); end
25
25
 
@@ -27,8 +27,8 @@ module OpenFeature
27
27
  extend T::Sig
28
28
 
29
29
  sig do
30
- params(hooks: Hooks, context: OpenFeature::HookContext[T.untyped],
31
- hints: T::Hash[String, T.untyped]).returns(OpenFeature::EvaluationContext)
30
+ params(hooks: Hooks, context: OpenFeatureSorbet::HookContext[T.untyped],
31
+ hints: T::Hash[String, T.untyped]).returns(OpenFeatureSorbet::EvaluationContext)
32
32
  end
33
33
  def call(hooks:, context:, hints:)
34
34
  context.evaluation_context.merge(
@@ -1,7 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- module OpenFeature
4
+ module OpenFeatureSorbet
5
5
  # See https://openfeature.dev/specification/sections/hooks#41-hook-context
6
6
  # See Requirement 4.1.1, 4.1.3, 4.1.4
7
7
  # TODO: Requirement 4.1.2
@@ -22,9 +22,9 @@ module OpenFeature
22
22
  # Needed as opposed to .with due to https://sorbet.org/docs/tstruct#from_hash-gotchas
23
23
  sig { params(new_context: EvaluationContext).returns(HookContext[Value]) }
24
24
  def with_new_evaluation_context(new_context)
25
- OpenFeature::HookContext.new(flag_key: flag_key, flag_type: flag_type, default_value: default_value,
26
- evaluation_context: new_context, client_metadata: client_metadata,
27
- provider_metadata: provider_metadata)
25
+ OpenFeatureSorbet::HookContext.new(flag_key: flag_key, flag_type: flag_type, default_value: default_value,
26
+ evaluation_context: new_context, client_metadata: client_metadata,
27
+ provider_metadata: provider_metadata)
28
28
  end
29
29
  end
30
30
  end
@@ -1,7 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- module OpenFeature
4
+ module OpenFeatureSorbet
5
5
  # Represents full set of hooks with helper methods for filtering and sequencing each subtype
6
6
  class Hooks < T::Struct
7
7
  extend T::Generic
@@ -1,7 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- module OpenFeature
4
+ module OpenFeatureSorbet
5
5
  # Used to pull from multiple providers.
6
6
  # Order of the providers given to initialize matters.
7
7
  # The providers will be evaluated in that order and the first
@@ -1,7 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- module OpenFeature
4
+ module OpenFeatureSorbet
5
5
  # Default provider when initializing OpenFeature.
6
6
  # Always returns the default value given.
7
7
  # This will result in a TypeError if the given default value does not have the correct type.
@@ -1,7 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- module OpenFeature
4
+ module OpenFeatureSorbet
5
5
  # Interface that providers must implement.
6
6
  class Provider
7
7
  extend T::Sig
@@ -1,7 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- module OpenFeature
4
+ module OpenFeatureSorbet
5
5
  # Defines information about a Provider.
6
6
  class ProviderMetadata < T::Struct
7
7
  include T::Struct::ActsAsComparable
@@ -1,7 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- module OpenFeature
4
+ module OpenFeatureSorbet
5
5
  # Indicates what state a provider is in
6
6
  class ProviderStatus < T::Enum
7
7
  enums do
@@ -1,7 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- module OpenFeature
4
+ module OpenFeatureSorbet
5
5
  # Information about resolved value, created by a Provider.
6
6
  class ResolutionDetails < T::Struct
7
7
  extend T::Generic
@@ -1,6 +1,6 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- module OpenFeature
4
+ module OpenFeatureSorbet
5
5
  Structure = T.type_alias { T.any(T::Array[T.untyped], T::Hash[T.untyped, T.untyped]) }
6
6
  end
@@ -8,7 +8,7 @@ loader = Zeitwerk::Loader.for_gem
8
8
  loader.setup
9
9
 
10
10
  # Sorbet-aware implementation of the OpenFeature specification
11
- module OpenFeature
11
+ module OpenFeatureSorbet
12
12
  class << self
13
13
  extend T::Sig
14
14
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openfeature-sdk-sorbet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max VelDink
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-02-21 00:00:00.000000000 Z
11
+ date: 2024-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sorbet-runtime
@@ -70,26 +70,26 @@ files:
70
70
  - LICENSE.txt
71
71
  - README.md
72
72
  - Rakefile
73
- - lib/open_feature.rb
74
- - lib/open_feature/client.rb
75
- - lib/open_feature/client_metadata.rb
76
- - lib/open_feature/configuration.rb
77
- - lib/open_feature/error_code.rb
78
- - lib/open_feature/evaluation_context.rb
79
- - lib/open_feature/evaluation_context_builder.rb
80
- - lib/open_feature/evaluation_details.rb
81
- - lib/open_feature/evaluation_options.rb
82
- - lib/open_feature/flag_metadata.rb
83
- - lib/open_feature/hook.rb
84
- - lib/open_feature/hook_context.rb
85
- - lib/open_feature/hooks.rb
86
- - lib/open_feature/multiple_source_provider.rb
87
- - lib/open_feature/no_op_provider.rb
88
- - lib/open_feature/provider.rb
89
- - lib/open_feature/provider_metadata.rb
90
- - lib/open_feature/provider_status.rb
91
- - lib/open_feature/resolution_details.rb
92
- - lib/open_feature/structure.rb
73
+ - lib/open_feature_sorbet.rb
74
+ - lib/open_feature_sorbet/client.rb
75
+ - lib/open_feature_sorbet/client_metadata.rb
76
+ - lib/open_feature_sorbet/configuration.rb
77
+ - lib/open_feature_sorbet/error_code.rb
78
+ - lib/open_feature_sorbet/evaluation_context.rb
79
+ - lib/open_feature_sorbet/evaluation_context_builder.rb
80
+ - lib/open_feature_sorbet/evaluation_details.rb
81
+ - lib/open_feature_sorbet/evaluation_options.rb
82
+ - lib/open_feature_sorbet/flag_metadata.rb
83
+ - lib/open_feature_sorbet/hook.rb
84
+ - lib/open_feature_sorbet/hook_context.rb
85
+ - lib/open_feature_sorbet/hooks.rb
86
+ - lib/open_feature_sorbet/multiple_source_provider.rb
87
+ - lib/open_feature_sorbet/no_op_provider.rb
88
+ - lib/open_feature_sorbet/provider.rb
89
+ - lib/open_feature_sorbet/provider_metadata.rb
90
+ - lib/open_feature_sorbet/provider_status.rb
91
+ - lib/open_feature_sorbet/resolution_details.rb
92
+ - lib/open_feature_sorbet/structure.rb
93
93
  - sorbet/config
94
94
  - sorbet/rbi/annotations/rainbow.rbi
95
95
  - sorbet/rbi/gems/.gitattributes