openfeature-ruby-sdk-contrib 0.1.1 → 0.2.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: 8044ba5b7f2fec56734a8d09b300cb13afc2592d7d1de18484db9eeecf0c9818
4
- data.tar.gz: b303b66a1fd84f522e22f8b4e4b9e541497a38d58e6247f06ecff17deb467854
3
+ metadata.gz: a769e314a26cad2d838cd2038cc0bf7c419bb341b3a1d84c8f25af1c86f431a4
4
+ data.tar.gz: f5fe644274b24df571e54d2128f39de106ca0e88a7e3c8d1ec354e2ead2fdbf2
5
5
  SHA512:
6
- metadata.gz: 7e1f41b92f665462cbccb2b956d03fd79438d910e5fd29f81255412896e224e95580398016b7af52341461ad16fb4bf2b0037ae0c0d8511da678c7bb126a87db
7
- data.tar.gz: a2b41ab8ef2f6a8c032bf9a7f3580d141b74d1443b23dae0fca63d5d7c6d081cd192c8888bd2ee8e3ea5aaf40f2fac8a31186dc03786546e2c2765ed90fd303b
6
+ metadata.gz: 4295a9914e8e7be4f79e65e1879964d5ffa4ccb560b71a094f6618df9731afc39a611a199f99efa69ab759bb24b6d3e6bcd16fc6aa2a3fecac2e22e71fcb0458
7
+ data.tar.gz: 01e988330d77f7ec392c53ab253622141d4e698ed1662bc8dd70aa03085d15d35980367b96502afcf6a6d35042394735952567673a34d868b2d36c6971106638
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- openfeature-ruby-sdk-contrib (0.1.0)
4
+ openfeature-ruby-sdk-contrib (0.1.2)
5
5
  concurrent-ruby (~> 1.2.2)
6
6
  faraday (~> 2.7.10)
7
7
  openfeature-sdk (~> 0.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.configure do |config|
75
- config.provider = OpenFeature::SDK::Contrib::Providers::FileProvider.new(source: "path/to/file", format: :yaml)
76
- end
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,11 @@ 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
12
17
  end
13
18
  end
14
19
  end
@@ -62,6 +62,11 @@ module OpenFeature
62
62
  end
63
63
  end
64
64
 
65
+ def expire_cache!
66
+ @last_cache = nil
67
+ @flag_contents = nil
68
+ end
69
+
65
70
  # Returns a boolean value for the key specified
66
71
  #
67
72
  # @param flag_key [String] flag key to search for
@@ -3,7 +3,7 @@
3
3
  module OpenFeature
4
4
  module SDK
5
5
  module Contrib
6
- VERSION = "0.1.1"
6
+ VERSION = "0.2.0"
7
7
  end
8
8
  end
9
9
  end
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.1.1
4
+ version: 0.2.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-08-10 00:00:00.000000000 Z
11
+ date: 2023-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby