openfeature-sdk 0.1.1 → 0.2.1

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: 5e0ab3e707e31b5e81d0a804445506bf8cf08b4be649f6f3eee1f38c61b5c286
4
- data.tar.gz: e4fa9d61a1c04de6b058c62ea31b4d359f251cf17c3a2323366118baaf64dea7
3
+ metadata.gz: 01c5b0fe23e56edfe9142031b5ad8b25e9f55b42e7eeb4ccb36692ee297b543f
4
+ data.tar.gz: 87c4f9c43567db36526725b79c9a7075b3acb47949f07820b444ef31fd59af5f
5
5
  SHA512:
6
- metadata.gz: 2b2e10cc74a605dabbc540cb3eeaa15d887f4173170bd4189526cae141312fdd2f71cbf3f02a41693b6b9eb76716ae8896680072f90f0ce9e89a39aed46c121d
7
- data.tar.gz: 696d50f1ff5b0632a77cfb4956fe3fe9b20132d2a39f0850a7b6514c154cf8ae93722bab2348b15443e6b7c6fd1ad354b053828ad7c95140873713025fbf5cd5
6
+ metadata.gz: 82b18ea505c33933f3a8798013cfac8d660d2560badcb45f11a9ec1036ab40ba2b61d14f347754f9d679dd07214228ae953a6a5e4e153b1196d53e3163c94cfd
7
+ data.tar.gz: 5af77fb1f0668477663dc04c1b7d759fc76ba899c693acf7cb53823133f89834b82ebe2591d8efb31d88638e950b33c53f91aa328c06a8abf98ce42fa795b5ea
@@ -1,3 +1,3 @@
1
1
  {
2
- ".": "0.1.1"
2
+ ".": "0.2.1"
3
3
  }
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.2.2
1
+ 3.3.0
data/.standard.yml ADDED
@@ -0,0 +1,5 @@
1
+ parallel: true
2
+ formatter: progress
3
+ ruby_version: 3.1
4
+ plugins:
5
+ - standard-performance
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 3.3.0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,34 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.1](https://github.com/open-feature/ruby-sdk/compare/v0.2.0...v0.2.1) (2024-03-29)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * Add domain to build_client ([#109](https://github.com/open-feature/ruby-sdk/issues/109)) ([56ccf17](https://github.com/open-feature/ruby-sdk/commit/56ccf17ec340df0ea14a72ea7379c51dbb9d7b13))
9
+
10
+ ## [0.2.0](https://github.com/open-feature/ruby-sdk/compare/v0.1.1...v0.2.0) (2024-03-09)
11
+
12
+
13
+ ### ⚠ BREAKING CHANGES
14
+
15
+ * Implement Requirement 1.1.3 ([#80](https://github.com/open-feature/ruby-sdk/issues/80))
16
+ * rename top-level lib folder to `open_feature` ([#90](https://github.com/open-feature/ruby-sdk/issues/90))
17
+ * Drop Ruby 2.7 and 3.0, add Ruby 3.3 ([#91](https://github.com/open-feature/ruby-sdk/issues/91))
18
+
19
+ ### Features
20
+
21
+ * adds `InMemoryProvider` ([#102](https://github.com/open-feature/ruby-sdk/issues/102)) ([25680a4](https://github.com/open-feature/ruby-sdk/commit/25680a40b0955ee66da256f23f7078655754a4b6))
22
+ * Implement Requirement 1.1.2 ([#78](https://github.com/open-feature/ruby-sdk/issues/78)) ([8cea7d0](https://github.com/open-feature/ruby-sdk/commit/8cea7d0cefc31ddeb2095ac60c40db3b038b02c5))
23
+ * Implement Requirement 1.1.3 ([#80](https://github.com/open-feature/ruby-sdk/issues/80)) ([bc65e7a](https://github.com/open-feature/ruby-sdk/commit/bc65e7a2754d736e858a856fd39118940c63ee41))
24
+ * Updates to `Provider` module in preparation for `InMemoryProvider` ([#99](https://github.com/open-feature/ruby-sdk/issues/99)) ([2d89570](https://github.com/open-feature/ruby-sdk/commit/2d89570b2ebace61bcb261cfcb54b2724a4a75f7))
25
+
26
+
27
+ ### Miscellaneous Chores
28
+
29
+ * Drop Ruby 2.7 and 3.0, add Ruby 3.3 ([#91](https://github.com/open-feature/ruby-sdk/issues/91)) ([51cd3a1](https://github.com/open-feature/ruby-sdk/commit/51cd3a1801e589f9049bffd7349d56bb6d32d05e))
30
+ * rename top-level lib folder to `open_feature` ([#90](https://github.com/open-feature/ruby-sdk/issues/90)) ([e1a9a01](https://github.com/open-feature/ruby-sdk/commit/e1a9a018e18cb62acedd1b5cd5a00ad3ecb4321a))
31
+
3
32
  ## [0.1.1](https://github.com/open-feature/ruby-sdk/compare/v0.1.0...v0.1.1) (2023-09-13)
4
33
 
5
34
 
data/Gemfile.lock CHANGED
@@ -1,25 +1,41 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- openfeature-sdk (0.1.1)
4
+ openfeature-sdk (0.2.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
9
  ast (2.4.2)
10
- concurrent-ruby (1.2.2)
10
+ base64 (0.1.1)
11
+ concurrent-ruby (1.2.3)
12
+ debug (1.9.1)
13
+ irb (~> 1.10)
14
+ reline (>= 0.3.8)
11
15
  diff-lcs (1.5.0)
12
16
  docile (1.4.0)
17
+ io-console (0.7.2)
18
+ irb (1.11.2)
19
+ rdoc
20
+ reline (>= 0.4.2)
13
21
  json (2.6.3)
22
+ language_server-protocol (3.17.0.3)
23
+ lint_roller (1.1.0)
14
24
  markly (0.10.0)
15
25
  parallel (1.23.0)
16
26
  parser (3.2.2.3)
17
27
  ast (~> 2.4.1)
18
28
  racc
29
+ psych (5.1.2)
30
+ stringio
19
31
  racc (1.7.1)
20
32
  rainbow (3.1.1)
21
33
  rake (13.0.6)
34
+ rdoc (6.6.2)
35
+ psych (>= 4.0.0)
22
36
  regexp_parser (2.8.1)
37
+ reline (0.4.3)
38
+ io-console (~> 0.5)
23
39
  rexml (3.2.6)
24
40
  rspec (3.12.0)
25
41
  rspec-core (~> 3.12.0)
@@ -34,18 +50,23 @@ GEM
34
50
  diff-lcs (>= 1.2.0, < 2.0)
35
51
  rspec-support (~> 3.12.0)
36
52
  rspec-support (3.12.1)
37
- rubocop (1.37.1)
53
+ rubocop (1.56.3)
54
+ base64 (~> 0.1.1)
38
55
  json (~> 2.3)
56
+ language_server-protocol (>= 3.17.0)
39
57
  parallel (~> 1.10)
40
- parser (>= 3.1.2.1)
58
+ parser (>= 3.2.2.3)
41
59
  rainbow (>= 2.2.2, < 4.0)
42
60
  regexp_parser (>= 1.8, < 3.0)
43
61
  rexml (>= 3.2.5, < 4.0)
44
- rubocop-ast (>= 1.23.0, < 2.0)
62
+ rubocop-ast (>= 1.28.1, < 2.0)
45
63
  ruby-progressbar (~> 1.7)
46
- unicode-display_width (>= 1.4.0, < 3.0)
64
+ unicode-display_width (>= 2.4.0, < 3.0)
47
65
  rubocop-ast (1.29.0)
48
66
  parser (>= 3.2.1.0)
67
+ rubocop-performance (1.19.0)
68
+ rubocop (>= 1.7.0, < 2.0)
69
+ rubocop-ast (>= 0.4.0)
49
70
  ruby-progressbar (1.13.0)
50
71
  simplecov (0.22.0)
51
72
  docile (~> 1.1)
@@ -56,11 +77,25 @@ GEM
56
77
  simplecov (~> 0.19)
57
78
  simplecov-html (0.12.3)
58
79
  simplecov_json_formatter (0.1.4)
80
+ standard (1.31.1)
81
+ language_server-protocol (~> 3.17.0.2)
82
+ lint_roller (~> 1.0)
83
+ rubocop (~> 1.56.2)
84
+ standard-custom (~> 1.0.0)
85
+ standard-performance (~> 1.2)
86
+ standard-custom (1.0.2)
87
+ lint_roller (~> 1.0)
88
+ rubocop (~> 1.50)
89
+ standard-performance (1.2.0)
90
+ lint_roller (~> 1.1)
91
+ rubocop-performance (~> 1.19.0)
92
+ stringio (3.1.0)
59
93
  unicode-display_width (2.4.2)
60
94
 
61
95
  PLATFORMS
62
96
  arm64-darwin-21
63
97
  arm64-darwin-22
98
+ arm64-darwin-23
64
99
  x64-mingw-ucrt
65
100
  x64-mingw32
66
101
  x86_64-darwin-19
@@ -70,13 +105,15 @@ PLATFORMS
70
105
 
71
106
  DEPENDENCIES
72
107
  concurrent-ruby
108
+ debug
73
109
  markly
74
110
  openfeature-sdk!
75
111
  rake (~> 13.0)
76
112
  rspec (~> 3.12.0)
77
- rubocop (~> 1.37.1)
78
113
  simplecov (~> 0.22.0)
79
114
  simplecov-cobertura (~> 2.1.0)
115
+ standard
116
+ standard-performance
80
117
 
81
118
  BUNDLED WITH
82
119
  2.3.25
data/README.md CHANGED
@@ -12,13 +12,11 @@ We support multiple data types for flags (numbers, strings, booleans, objects) a
12
12
 
13
13
  ## Support Matrix
14
14
 
15
- | Ruby Version | OS |
16
- | ----------- | ----------- |
17
- | Ruby 2.7.8 | Windows, MacOS, Linux |
18
- | Ruby 3.0.6 | Windows, MacOS, Linux |
19
- | Ruby 3.1.4 | Windows, MacOS, Linux |
20
- | Ruby 3.2.2 | Windows, MacOS, Linux |
21
-
15
+ | Ruby Version | OS |
16
+ | ------------ | --------------------- |
17
+ | Ruby 3.1.4 | Windows, MacOS, Linux |
18
+ | Ruby 3.2.3 | Windows, MacOS, Linux |
19
+ | Ruby 3.3.0 | Windows, MacOS, Linux |
22
20
 
23
21
  ## Installation
24
22
 
@@ -37,18 +35,27 @@ gem install openfeature-sdk
37
35
  ## Usage
38
36
 
39
37
  ```ruby
40
- require 'openfeature/sdk'
38
+ require 'open_feature/sdk'
41
39
  require 'json' # For JSON.dump
42
40
 
43
41
  # API Initialization and configuration
44
42
 
45
43
  OpenFeature::SDK.configure do |config|
46
- # your provider of choice
47
- config.provider = OpenFeature::SDK::Provider::NoOpProvider.new
44
+ # your provider of choice, which will be used as the default provider
45
+ config.set_provider(OpenFeature::SDK::Provider::InMemoryProvider.new(
46
+ {
47
+ "flag1" => true,
48
+ "flag2" => 1
49
+ }
50
+ ))
51
+ # alternatively, you can bind multiple providers to different domains
52
+ config.set_provider(OpenFeature::SDK::Provider::NoOpProvider.new, domain: "legacy_flags")
48
53
  end
49
54
 
50
55
  # Create a client
51
- client = OpenFeature::SDK.build_client(name: "my-app")
56
+ client = OpenFeature::SDK.build_client
57
+ # Create a client for a different domain, this will use the provider assigned to that domain
58
+ legacy_flag_client = OpenFeature::SDK.build_client(domain: "legacy_flags")
52
59
 
53
60
  # fetching boolean value feature flag
54
61
  bool_value = client.fetch_boolean_value(flag_key: 'boolean_flag', default_value: false)
@@ -66,13 +73,36 @@ object = client.fetch_object_value(flag_key: 'object_value', default_value: JSON
66
73
 
67
74
  For complete documentation, visit: https://openfeature.dev/docs/category/concepts
68
75
 
76
+ ### Providers
77
+
78
+ Providers are the abstraction layer between OpenFeature and different flag management systems.
79
+
80
+ The `NoOpProvider` is an example of a minimalist provider. The `InMemoryProvider` is a provider that can be initialized with flags and used to store flags in process. For complete documentation on the Provider interface, visit: https://openfeature.dev/specification/sections/providers.
81
+
82
+ In addition to the `fetch_*` methods, providers can optionally implement lifecycle methods that are invoked when the underlying provider is switched out. For example:
83
+
84
+ ```ruby
85
+ class MyProvider
86
+ def init
87
+ # Perform any initialization steps with flag management system here
88
+ # Return value is ignored
89
+ end
90
+
91
+ def shutdown
92
+ # Perform any shutdown/reclamation steps with flag management system here
93
+ # Return value is ignored
94
+ end
95
+ end
96
+ ```
97
+
98
+ **Note** The OpenFeature spec defines a lifecycle method called `initialize` to be called when a new provider is set. To avoid conflicting with the Ruby `initialize` method, this method should be named `init` when creating a provider.
99
+
69
100
  ## Contributing
70
101
 
71
102
  See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to the OpenFeature project.
72
103
 
73
104
  Our community meetings are held regularly and open to everyone. Check the [OpenFeature community calendar](https://calendar.google.com/calendar/u/0?cid=MHVhN2kxaGl2NWRoMThiMjd0b2FoNjM2NDRAZ3JvdXAuY2FsZW5kYXIuZ29vZ2xlLmNvbQ) for specific dates and for the Zoom meeting links.
74
105
 
75
-
76
106
  ## License
77
107
 
78
108
  [Apache License 2.0](LICENSE)
data/Rakefile CHANGED
@@ -5,11 +5,6 @@ require "rspec/core/rake_task"
5
5
 
6
6
  RSpec::Core::RakeTask.new(:spec)
7
7
 
8
- require "rubocop/rake_task"
8
+ require "standard/rake"
9
9
 
10
- RuboCop::RakeTask.new do |task|
11
- task.options = ["--parallel"]
12
- task.options << "--color" if ENV["CI"] == "true"
13
- end
14
-
15
- task default: %i[spec rubocop]
10
+ task default: %i[spec standard]
@@ -4,9 +4,10 @@ require "forwardable"
4
4
  require "singleton"
5
5
 
6
6
  require_relative "configuration"
7
+ require_relative "evaluation_details"
7
8
  require_relative "client"
8
9
  require_relative "metadata"
9
- require_relative "provider/no_op_provider"
10
+ require_relative "provider"
10
11
 
11
12
  module OpenFeature
12
13
  module SDK
@@ -18,7 +19,7 @@ module OpenFeature
18
19
  # To use the SDK, you can optionally configure a <tt>Provider</tt>, with <tt>Hook</tt>
19
20
  #
20
21
  # OpenFeature::SDK::API.instance.configure do |config|
21
- # config.provider = NoOpProvider.new
22
+ # config.set_provider NoOpProvider.new
22
23
  # end
23
24
  #
24
25
  # If no provider is specified, the <tt>NoOpProvider</tt> is set as the default <tt>Provider</tt>.
@@ -26,27 +27,27 @@ module OpenFeature
26
27
  #
27
28
  # client = OpenFeature::SDK::API.instance.build_client(name: 'my-open-feature-client')
28
29
  class API
29
- include Singleton
30
+ include Singleton # Satisfies Flag Evaluation API Requirement 1.1.1
30
31
  extend Forwardable
31
32
 
32
- def_delegator :@configuration, :provider
33
- def_delegator :@configuration, :hooks
34
- def_delegator :@configuration, :context
33
+ def_delegators :configuration, :provider, :set_provider, :hooks, :context
35
34
 
36
35
  def configuration
37
36
  @configuration ||= Configuration.new
38
37
  end
39
38
 
40
39
  def configure(&block)
41
- return unless block_given?
40
+ return unless block
42
41
 
43
42
  block.call(configuration)
44
43
  end
45
44
 
46
- def build_client(name: nil, version: nil)
47
- client_options = Metadata.new(name: name, version: version).freeze
48
- provider = Provider::NoOpProvider.new if provider.nil?
49
- Client.new(provider: provider, client_options: client_options, context: context)
45
+ def build_client(name: nil, version: nil, domain: nil)
46
+ client_options = Metadata.new(name: name, version: version, domain: domain).freeze
47
+
48
+ active_provider = provider(domain:).nil? ? Provider::NoOpProvider.new : provider(domain:)
49
+
50
+ Client.new(provider: active_provider, client_options:, context:)
50
51
  end
51
52
  end
52
53
  end
@@ -26,8 +26,9 @@ module OpenFeature
26
26
  # result = @provider.fetch_boolean_value(flag_key: flag_key, default_value: default_value, evaluation_context: evaluation_context)
27
27
  # end
28
28
  def fetch_#{result_type}_#{suffix}(flag_key:, default_value:, evaluation_context: nil)
29
- result = @provider.fetch_#{result_type}_value(flag_key: flag_key, default_value: default_value, evaluation_context: evaluation_context)
30
- #{"result.value" if suffix == :value}
29
+ resolution_details = @provider.fetch_#{result_type}_value(flag_key:, default_value:, evaluation_context:)
30
+ evaluation_details = EvaluationDetails.new(flag_key:, resolution_details:)
31
+ #{"evaluation_details.value" if suffix == :value}
31
32
  end
32
33
  RUBY
33
34
  end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "concurrent"
4
+
5
+ require_relative "api"
6
+
7
+ module OpenFeature
8
+ module SDK
9
+ # Represents the configuration object for the global API where <tt>Provider</tt>, <tt>Hook</tt>,
10
+ # and <tt>Context</tt> are configured.
11
+ # This class is not meant to be interacted with directly but instead through the <tt>OpenFeature::SDK.configure</tt>
12
+ # method
13
+ class Configuration
14
+ extend Forwardable
15
+
16
+ attr_accessor :context, :hooks
17
+
18
+ def_delegator :provider, :metadata
19
+
20
+ def initialize
21
+ @hooks = []
22
+ @providers = {}
23
+ end
24
+
25
+ def provider(domain: nil)
26
+ @providers[domain]
27
+ end
28
+
29
+ # When switching providers, there are a few lifecycle methods that need to be taken care of.
30
+ # 1. If a provider is already set, we need to call `shutdown` on it.
31
+ # 2. On the new provider, call `init`.
32
+ # 3. Finally, set the internal provider to the new provider
33
+ def set_provider(provider, domain: nil)
34
+ @providers[domain].shutdown if @providers[domain].respond_to?(:shutdown)
35
+
36
+ provider.init if provider.respond_to?(:init)
37
+
38
+ @providers[domain] = provider
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,9 @@
1
+ module OpenFeature
2
+ module SDK
3
+ EvaluationDetails = Struct.new(:flag_key, :resolution_details, keyword_init: true) do
4
+ extend Forwardable
5
+
6
+ def_delegators :resolution_details, :value, :reason, :variant, :error_code, :error_message, :flag_metadata
7
+ end
8
+ end
9
+ end
@@ -10,19 +10,22 @@ module OpenFeature
10
10
  #
11
11
  # * <tt>version</tt> - Allows you to specify version of the Metadata structure
12
12
  #
13
+ # * <tt>domain</tt> - Allows you to specify the domain of the Metadata structure
14
+ #
13
15
  # Usage:
14
16
  #
15
- # metadata = Metadata.new(name: 'name-for-metadata', version: 'v1.1.3')
17
+ # metadata = Metadata.new(name: 'name-for-metadata', version: 'v1.1.3', domain: 'test')
16
18
  # metadata.name # 'name-for-metadata'
17
19
  # metadata.version # version
18
20
  # metadata_two = Metadata.new(name: 'name-for-metadata')
19
21
  # metadata_two == metadata # true - equality based on values
20
22
  class Metadata
21
- attr_reader :name, :version
23
+ attr_reader :name, :version, :domain
22
24
 
23
- def initialize(name:, version: nil)
25
+ def initialize(name:, version: nil, domain: nil)
24
26
  @name = name
25
27
  @version = version
28
+ @domain = domain
26
29
  end
27
30
 
28
31
  def ==(other)
@@ -0,0 +1,15 @@
1
+ module OpenFeature
2
+ module SDK
3
+ module Provider
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"
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,62 @@
1
+ module OpenFeature
2
+ module SDK
3
+ module Provider
4
+ # TODO: Add evaluation context support
5
+ class InMemoryProvider
6
+ NAME = "In-memory Provider"
7
+
8
+ def initialize(flags = {})
9
+ @metadata = Metadata.new(name: NAME).freeze
10
+ @flags = flags
11
+ end
12
+
13
+ def init
14
+ # Intentional no-op, used for testing
15
+ end
16
+
17
+ def shutdown
18
+ # Intentional no-op, used for testing
19
+ end
20
+
21
+ def add_flag(flag_key:, value:)
22
+ flags[flag_key] = value
23
+ # TODO: Emit PROVIDER_CONFIGURATION_CHANGED event once events are implemented
24
+ end
25
+
26
+ def fetch_boolean_value(flag_key:, default_value:, evaluation_context: nil)
27
+ fetch_value(allowed_classes: [TrueClass, FalseClass], flag_key:, default_value:, evaluation_context:)
28
+ end
29
+
30
+ def fetch_string_value(flag_key:, default_value:, evaluation_context: nil)
31
+ fetch_value(allowed_classes: [String], flag_key:, default_value:, evaluation_context:)
32
+ end
33
+
34
+ def fetch_number_value(flag_key:, default_value:, evaluation_context: nil)
35
+ fetch_value(allowed_classes: [Integer, Float], flag_key:, default_value:, evaluation_context:)
36
+ end
37
+
38
+ def fetch_object_value(flag_key:, default_value:, evaluation_context: nil)
39
+ fetch_value(allowed_classes: [Array, Hash], flag_key:, default_value:, evaluation_context:)
40
+ end
41
+
42
+ private
43
+
44
+ attr_reader :flags
45
+
46
+ def fetch_value(allowed_classes:, flag_key:, default_value:, evaluation_context:)
47
+ value = flags[flag_key]
48
+
49
+ if value.nil?
50
+ return ResolutionDetails.new(value: default_value, error_code: ErrorCode::FLAG_NOT_FOUND, reason: Reason::ERROR)
51
+ end
52
+
53
+ if allowed_classes.include?(value.class)
54
+ ResolutionDetails.new(value:, reason: Reason::STATIC)
55
+ else
56
+ ResolutionDetails.new(value: default_value, error_code: ErrorCode::TYPE_MISMATCH, reason: Reason::ERROR)
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
@@ -11,7 +11,7 @@ module OpenFeature
11
11
  # To use <tt>NoOpProvider</tt>, it can be set during the configuration of the SDK
12
12
  #
13
13
  # OpenFeature::SDK.configure do |config|
14
- # config.provider = NoOpProvider.new
14
+ # config.set_provider NoOpProvider.new
15
15
  # end
16
16
  #
17
17
  # Within the <tt>NoOpProvider</tt>, the following methods exist
@@ -30,8 +30,6 @@ module OpenFeature
30
30
 
31
31
  attr_reader :metadata
32
32
 
33
- ResolutionDetails = Struct.new(:value, :reason, :variant, :error_code, :error_message)
34
-
35
33
  def initialize
36
34
  @metadata = Metadata.new(name: NAME).freeze
37
35
  end
@@ -0,0 +1,17 @@
1
+ module OpenFeature
2
+ module SDK
3
+ module Provider
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"
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,7 @@
1
+ module OpenFeature
2
+ module SDK
3
+ module Provider
4
+ ResolutionDetails = Struct.new(:value, :reason, :variant, :error_code, :error_message, :flag_metadata, keyword_init: true)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,12 @@
1
+ require_relative "provider/error_code"
2
+ require_relative "provider/reason"
3
+ require_relative "provider/resolution_details"
4
+ require_relative "provider/no_op_provider"
5
+ require_relative "provider/in_memory_provider"
6
+
7
+ module OpenFeature
8
+ module SDK
9
+ module Provider
10
+ end
11
+ end
12
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OpenFeature
4
4
  module SDK
5
- VERSION = "0.1.1"
5
+ VERSION = "0.2.1"
6
6
  end
7
7
  end
@@ -8,9 +8,9 @@ module OpenFeature
8
8
  #
9
9
  module SDK
10
10
  class << self
11
- def method_missing(method_name, *args, **kwargs, &block)
11
+ def method_missing(method_name, ...)
12
12
  if API.instance.respond_to?(method_name)
13
- API.instance.send(method_name, *args, **kwargs, &block)
13
+ API.instance.send(method_name, ...)
14
14
  else
15
15
  super
16
16
  end
@@ -9,7 +9,7 @@
9
9
  "bump-minor-pre-major": true,
10
10
  "bump-patch-for-minor-pre-major": true,
11
11
  "package-name": "openfeature-sdk",
12
- "version-file": "lib/openfeature/sdk/version.rb"
12
+ "version-file": "lib/open_feature/sdk/version.rb"
13
13
  }
14
14
  }
15
15
  }
data/renovate.json CHANGED
@@ -1,8 +1,7 @@
1
1
  {
2
2
  "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3
3
  "extends": [
4
- "config:base",
5
- "helpers:pinGitHubActionDigests"
4
+ "config:base"
6
5
  ],
7
6
  "packageRules": [
8
7
  {
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openfeature-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenFeature Authors
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-09-13 00:00:00.000000000 Z
11
+ date: 2024-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: debug
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: markly
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -53,19 +67,33 @@ dependencies:
53
67
  - !ruby/object:Gem::Version
54
68
  version: 3.12.0
55
69
  - !ruby/object:Gem::Dependency
56
- name: rubocop
70
+ name: standard
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - "~>"
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: standard-performance
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
60
88
  - !ruby/object:Gem::Version
61
- version: 1.37.1
89
+ version: '0'
62
90
  type: :development
63
91
  prerelease: false
64
92
  version_requirements: !ruby/object:Gem::Requirement
65
93
  requirements:
66
- - - "~>"
94
+ - - ">="
67
95
  - !ruby/object:Gem::Version
68
- version: 1.37.1
96
+ version: '0'
69
97
  - !ruby/object:Gem::Dependency
70
98
  name: simplecov
71
99
  requirement: !ruby/object:Gem::Requirement
@@ -104,9 +132,10 @@ extra_rdoc_files: []
104
132
  files:
105
133
  - ".release-please-manifest.json"
106
134
  - ".rspec"
107
- - ".rubocop.yml"
108
135
  - ".ruby-version"
109
136
  - ".simplecov"
137
+ - ".standard.yml"
138
+ - ".tool-versions"
110
139
  - CHANGELOG.md
111
140
  - CODEOWNERS
112
141
  - CODE_OF_CONDUCT.md
@@ -115,16 +144,21 @@ files:
115
144
  - LICENSE
116
145
  - README.md
117
146
  - Rakefile
118
- - lib/openfeature/sdk.rb
119
- - lib/openfeature/sdk/api.rb
120
- - lib/openfeature/sdk/client.rb
121
- - lib/openfeature/sdk/configuration.rb
122
- - lib/openfeature/sdk/metadata.rb
123
- - lib/openfeature/sdk/provider/no_op_provider.rb
124
- - lib/openfeature/sdk/version.rb
147
+ - lib/open_feature/sdk.rb
148
+ - lib/open_feature/sdk/api.rb
149
+ - lib/open_feature/sdk/client.rb
150
+ - lib/open_feature/sdk/configuration.rb
151
+ - lib/open_feature/sdk/evaluation_details.rb
152
+ - lib/open_feature/sdk/metadata.rb
153
+ - lib/open_feature/sdk/provider.rb
154
+ - lib/open_feature/sdk/provider/error_code.rb
155
+ - lib/open_feature/sdk/provider/in_memory_provider.rb
156
+ - lib/open_feature/sdk/provider/no_op_provider.rb
157
+ - lib/open_feature/sdk/provider/reason.rb
158
+ - lib/open_feature/sdk/provider/resolution_details.rb
159
+ - lib/open_feature/sdk/version.rb
125
160
  - release-please-config.json
126
161
  - renovate.json
127
- - sig/openfeature/sdk.rbs
128
162
  homepage: https://github.com/open-feature/openfeature-ruby
129
163
  licenses:
130
164
  - Apache-2.0'
@@ -142,14 +176,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
142
176
  requirements:
143
177
  - - ">="
144
178
  - !ruby/object:Gem::Version
145
- version: '2.7'
179
+ version: '3.1'
146
180
  required_rubygems_version: !ruby/object:Gem::Requirement
147
181
  requirements:
148
182
  - - ">="
149
183
  - !ruby/object:Gem::Version
150
184
  version: '0'
151
185
  requirements: []
152
- rubygems_version: 3.4.10
186
+ rubygems_version: 3.5.3
153
187
  signing_key:
154
188
  specification_version: 4
155
189
  summary: OpenFeature SDK for Ruby
data/.rubocop.yml DELETED
@@ -1,28 +0,0 @@
1
- AllCops:
2
- TargetRubyVersion: 2.7
3
- NewCops: enable
4
-
5
- Style/StringLiterals:
6
- Enabled: true
7
- EnforcedStyle: double_quotes
8
-
9
- Style/StringLiteralsInInterpolation:
10
- Enabled: true
11
- EnforcedStyle: double_quotes
12
-
13
- Layout/LineLength:
14
- Max: 120
15
- Exclude:
16
- - 'spec/**/*.rb'
17
-
18
- Metrics/BlockLength:
19
- Exclude:
20
- - 'spec/**/*.rb'
21
- - 'openfeature-sdk.gemspec'
22
-
23
- Gemspec/RequireMFA:
24
- Enabled: false
25
-
26
- Style/DocumentDynamicEvalDefinition:
27
- # TODO re-enable after figuring out what it actually wants
28
- Enabled: false
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "concurrent"
4
-
5
- require_relative "api"
6
-
7
- module OpenFeature
8
- module SDK
9
- # Represents the configuration object for the global API where <tt>Provider</tt>, <tt>Hook</tt>,
10
- # and <tt>Context</tt> are configured.
11
- # This class is not meant to be interacted with directly but instead through the <tt>OpenFeature::SDK.configure</tt>
12
- # method
13
- class Configuration
14
- extend Forwardable
15
-
16
- attr_accessor :context, :provider, :hooks
17
-
18
- def_delegator :@provider, :metadata
19
-
20
- def initialize
21
- @hooks = []
22
- end
23
- end
24
- end
25
- end
@@ -1,6 +0,0 @@
1
- module Openfeature
2
- module Sdk
3
- VERSION: String
4
- # See the writing guide of rbs: https://github.com/ruby/rbs#guides
5
- end
6
- end