openfeature-ruby-sdk-contrib 0.1.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/README.md +34 -3
- data/lib/open_feature/sdk/contrib/client.rb +9 -0
- data/lib/open_feature/sdk/contrib/providers/common.rb +4 -0
- data/lib/open_feature/sdk/contrib/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2cf8cd0512f8cb54964eef7abc7152a8a1ff440b87ff180c3e5cf4d5672fe2be
|
4
|
+
data.tar.gz: f67486141dd2f5e0847b0884dd95d8aa3ec6e8176495164637f9fdca6c71fd99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff01303ffef255120f9eb98855e25eff6669b88153ec04c40e7700a8dc14b1bb620be992a509067ff0c80352c12706a0faa50e9d2af42bb6c5dff917c1690562
|
7
|
+
data.tar.gz: 297f07e8736d693bf7f68b22aa2236e6836c8b86cbaa36d81e86e045f91771b985bc0595e8622fbe0889b810ca9ffd2f6a6aaaa08b66232e5ccf30334889b741
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
openfeature-ruby-sdk-contrib (0.1
|
4
|
+
openfeature-ruby-sdk-contrib (0.2.1)
|
5
5
|
concurrent-ruby (~> 1.2.2)
|
6
6
|
faraday (~> 2.7.10)
|
7
7
|
openfeature-sdk (~> 0.1)
|
@@ -22,7 +22,7 @@ GEM
|
|
22
22
|
language_server-protocol (3.17.0.3)
|
23
23
|
lint_roller (1.1.0)
|
24
24
|
method_source (1.0.0)
|
25
|
-
openfeature-sdk (0.1.
|
25
|
+
openfeature-sdk (0.1.1)
|
26
26
|
parallel (1.23.0)
|
27
27
|
parser (3.2.2.3)
|
28
28
|
ast (~> 2.4.1)
|
data/README.md
CHANGED
@@ -68,12 +68,43 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
68
68
|
|
69
69
|
## Usage
|
70
70
|
|
71
|
+
If you are using rails, this code will go in an initializer. If you aren't, replace the assignments for `Rails.application.config.openfeature_provider` and `Rails.application.config.openfeature_client` with constants that you will have access to application-wide.
|
72
|
+
|
73
|
+
### File Provider
|
74
|
+
|
75
|
+
```
|
76
|
+
require "open_feature/sdk/contrib"
|
77
|
+
|
78
|
+
Rails.application.config.openfeature_provider = OpenFeature::SDK::Contrib::Providers::FileProvider.new(
|
79
|
+
cache_duration: 300,
|
80
|
+
deep_keys: ["flags"], # If your flags are nested inside of a response, this array is a list of keys that will get to the array where the actual flags are defined
|
81
|
+
format: :yaml, # json or yaml
|
82
|
+
source: "/path/to/file.yml"
|
83
|
+
)
|
84
|
+
|
85
|
+
Rails.application.config.openfeature_client = OpenFeature::SDK::Contrib::Client.new(
|
86
|
+
client_options: { name: "your arbitrary client name" },
|
87
|
+
provider: Rails.application.config.openfeature_provider
|
88
|
+
)
|
89
|
+
```
|
90
|
+
|
91
|
+
### HTTP Provider
|
92
|
+
|
71
93
|
```
|
72
94
|
require "open_feature/sdk/contrib"
|
73
95
|
|
74
|
-
OpenFeature::SDK.
|
75
|
-
|
76
|
-
|
96
|
+
Rails.application.config.openfeature_provider = OpenFeature::SDK::Contrib::Providers::HttpProvider.new(
|
97
|
+
cache_duration: 300,
|
98
|
+
deep_keys: ["flags"], # If your flags are nested inside of a response, this array is a list of keys that will get to the array where the actual flags are defined
|
99
|
+
extra_options: { Authorization: "Bearer <some token>" }, # This object can be anything that gets passed to Faraday.new
|
100
|
+
format: :json, # json or yaml
|
101
|
+
source: "https://some.url/feature-flags"
|
102
|
+
)
|
103
|
+
|
104
|
+
Rails.application.config.openfeature_client = OpenFeature::SDK::Contrib::Client.new(
|
105
|
+
client_options: { name: "your arbitrary client name" },
|
106
|
+
provider: Rails.application.config.openfeature_provider
|
107
|
+
)
|
77
108
|
```
|
78
109
|
|
79
110
|
## Development
|
@@ -9,6 +9,15 @@ module OpenFeature
|
|
9
9
|
def all_flags
|
10
10
|
@provider.read_all_values_with_cache
|
11
11
|
end
|
12
|
+
|
13
|
+
def fetch_float_value(flag_key:, default_value:, evaluation_context: nil)
|
14
|
+
result = @provider.fetch_float_value(flag_key: flag_key, default_value: default_value, evaluation_context: evaluation_context)
|
15
|
+
result.value
|
16
|
+
end
|
17
|
+
|
18
|
+
def fetch_raw_flag(flag_key:)
|
19
|
+
@provider.fetch_raw_key(flag_key: flag_key)
|
20
|
+
end
|
12
21
|
end
|
13
22
|
end
|
14
23
|
end
|
@@ -67,6 +67,10 @@ module OpenFeature
|
|
67
67
|
@flag_contents = nil
|
68
68
|
end
|
69
69
|
|
70
|
+
def fetch_raw_key(flag_key:)
|
71
|
+
read_all_values_with_cache.detect { |f| f["name"] == flag_key }
|
72
|
+
end
|
73
|
+
|
70
74
|
# Returns a boolean value for the key specified
|
71
75
|
#
|
72
76
|
# @param flag_key [String] flag key to search for
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openfeature-ruby-sdk-contrib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eugene Howe
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|