openfeature-ruby-sdk-contrib 0.3.0 → 0.5.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: 2cf8cd0512f8cb54964eef7abc7152a8a1ff440b87ff180c3e5cf4d5672fe2be
4
- data.tar.gz: f67486141dd2f5e0847b0884dd95d8aa3ec6e8176495164637f9fdca6c71fd99
3
+ metadata.gz: be2d89c0a27aff01c3af71cf16c50edb267f7b76347de4b390ff6130a1aa0217
4
+ data.tar.gz: 432c022ce3a40af8f9e58715aa9b6ca4b88dbfa067e8ba81ec2784a21b729d52
5
5
  SHA512:
6
- metadata.gz: ff01303ffef255120f9eb98855e25eff6669b88153ec04c40e7700a8dc14b1bb620be992a509067ff0c80352c12706a0faa50e9d2af42bb6c5dff917c1690562
7
- data.tar.gz: 297f07e8736d693bf7f68b22aa2236e6836c8b86cbaa36d81e86e045f91771b985bc0595e8622fbe0889b810ca9ffd2f6a6aaaa08b66232e5ccf30334889b741
6
+ metadata.gz: 65b1632d328b1d91ff91cdc5e021b88d23d9dcf342328778e56d64b31bacd8126ff6064be89735e1b7c7b9004ad757e8accb18c6b17a641d6d5fa934ae33f892
7
+ data.tar.gz: a3d906869ea5a09f5e0ee88649e04e021a5802f72e3465b0d17fd580c7a321bfab9e12a78a20cec37817409a8eb5ab056200c96600354947012915821ca23309
data/Gemfile.lock CHANGED
@@ -1,30 +1,32 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- openfeature-ruby-sdk-contrib (0.2.1)
4
+ openfeature-ruby-sdk-contrib (0.4.0)
5
5
  concurrent-ruby (~> 1.2.2)
6
6
  faraday (~> 2.7.10)
7
- openfeature-sdk (~> 0.1)
7
+ openfeature-sdk (~> 0.2)
8
8
 
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
12
  ast (2.4.2)
13
+ base64 (0.2.0)
13
14
  byebug (11.1.3)
14
15
  coderay (1.1.3)
15
- concurrent-ruby (1.2.2)
16
- diff-lcs (1.5.0)
17
- faraday (2.7.10)
16
+ concurrent-ruby (1.2.3)
17
+ diff-lcs (1.5.1)
18
+ faraday (2.7.12)
19
+ base64
18
20
  faraday-net_http (>= 2.0, < 3.1)
19
21
  ruby2_keywords (>= 0.0.4)
20
22
  faraday-net_http (3.0.2)
21
- json (2.6.3)
23
+ json (2.7.1)
22
24
  language_server-protocol (3.17.0.3)
23
25
  lint_roller (1.1.0)
24
26
  method_source (1.0.0)
25
- openfeature-sdk (0.1.1)
26
- parallel (1.23.0)
27
- parser (3.2.2.3)
27
+ openfeature-sdk (0.2.0)
28
+ parallel (1.24.0)
29
+ parser (3.3.0.5)
28
30
  ast (~> 2.4.1)
29
31
  racc
30
32
  pry (0.14.2)
@@ -33,24 +35,24 @@ GEM
33
35
  pry-byebug (3.10.1)
34
36
  byebug (~> 11.0)
35
37
  pry (>= 0.13, < 0.15)
36
- racc (1.7.1)
38
+ racc (1.7.3)
37
39
  rainbow (3.1.1)
38
- rake (13.0.6)
39
- regexp_parser (2.8.1)
40
+ rake (13.1.0)
41
+ regexp_parser (2.9.0)
40
42
  rexml (3.2.6)
41
- rspec (3.12.0)
42
- rspec-core (~> 3.12.0)
43
- rspec-expectations (~> 3.12.0)
44
- rspec-mocks (~> 3.12.0)
45
- rspec-core (3.12.2)
46
- rspec-support (~> 3.12.0)
47
- rspec-expectations (3.12.3)
43
+ rspec (3.13.0)
44
+ rspec-core (~> 3.13.0)
45
+ rspec-expectations (~> 3.13.0)
46
+ rspec-mocks (~> 3.13.0)
47
+ rspec-core (3.13.0)
48
+ rspec-support (~> 3.13.0)
49
+ rspec-expectations (3.13.0)
48
50
  diff-lcs (>= 1.2.0, < 2.0)
49
- rspec-support (~> 3.12.0)
50
- rspec-mocks (3.12.6)
51
+ rspec-support (~> 3.13.0)
52
+ rspec-mocks (3.13.0)
51
53
  diff-lcs (>= 1.2.0, < 2.0)
52
- rspec-support (~> 3.12.0)
53
- rspec-support (3.12.1)
54
+ rspec-support (~> 3.13.0)
55
+ rspec-support (3.13.1)
54
56
  rubocop (1.52.1)
55
57
  json (~> 2.3)
56
58
  parallel (~> 1.10)
@@ -61,19 +63,19 @@ GEM
61
63
  rubocop-ast (>= 1.28.0, < 2.0)
62
64
  ruby-progressbar (~> 1.7)
63
65
  unicode-display_width (>= 2.4.0, < 3.0)
64
- rubocop-ast (1.29.0)
65
- parser (>= 3.2.1.0)
66
- rubocop-capybara (2.18.0)
66
+ rubocop-ast (1.31.2)
67
+ parser (>= 3.3.0.4)
68
+ rubocop-capybara (2.20.0)
69
+ rubocop (~> 1.41)
70
+ rubocop-factory_bot (2.25.1)
67
71
  rubocop (~> 1.41)
68
- rubocop-factory_bot (2.23.1)
69
- rubocop (~> 1.33)
70
72
  rubocop-performance (1.18.0)
71
73
  rubocop (>= 1.7.0, < 2.0)
72
74
  rubocop-ast (>= 0.4.0)
73
75
  rubocop-rake (0.6.0)
74
76
  rubocop (~> 1.0)
75
- rubocop-rspec (2.23.0)
76
- rubocop (~> 1.33)
77
+ rubocop-rspec (2.27.1)
78
+ rubocop (~> 1.40)
77
79
  rubocop-capybara (~> 2.17)
78
80
  rubocop-factory_bot (~> 2.22)
79
81
  ruby-progressbar (1.13.0)
@@ -90,11 +92,11 @@ GEM
90
92
  standard-performance (1.1.2)
91
93
  lint_roller (~> 1.1)
92
94
  rubocop-performance (~> 1.18.0)
93
- unicode-display_width (2.4.2)
94
- yard (0.9.34)
95
+ unicode-display_width (2.5.0)
96
+ yard (0.9.36)
95
97
 
96
98
  PLATFORMS
97
- arm64-darwin-22
99
+ arm64-darwin-23
98
100
 
99
101
  DEPENDENCIES
100
102
  openfeature-ruby-sdk-contrib!
data/README.md CHANGED
@@ -107,6 +107,32 @@ Rails.application.config.openfeature_client = OpenFeature::SDK::Contrib::Client.
107
107
  )
108
108
  ```
109
109
 
110
+ #### Custom Auth Strategy
111
+
112
+ Some applications may require more finesse to authenticate, for example, an OAuth Flow. To use this style flow, the `extra_options` key that is passed to `HttpProvider.new` accepts an `authentication_strategy` key. This key gets passed to the internal Faraday client as a middleware, so it can be anything usable as a Faraday middleware. Example:
113
+
114
+ ```
115
+ module FaradayMiddleware
116
+ class MyCustomMiddleware < Faraday::Middleware
117
+ def initialize(args)
118
+ # do stuff
119
+ end
120
+
121
+ def call(env)
122
+ @app.call(env)
123
+ end
124
+ end
125
+
126
+ Faraday::Request.register_middleware my_custom_middleware: -> { MyCustomMiddleware }
127
+ end
128
+
129
+ Rails.application.config.openfeature_provider = OpenFeature::SDK::Contrib::Providers::HttpProvider.new(
130
+ extra_options: {
131
+ authentication_strategy: [:my_custom_middleware, my_custom_middleware_arguments]
132
+ }
133
+ )
134
+ ```
135
+
110
136
  ## Development
111
137
 
112
138
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "openfeature/sdk/client"
3
+ require "open_feature/sdk/client"
4
4
 
5
5
  module OpenFeature
6
6
  module SDK
@@ -134,7 +134,7 @@ module OpenFeature
134
134
  def read_all_values_with_cache
135
135
  now = Time.now.to_i
136
136
 
137
- read_from_cache = if !@flag_contents && !@last_cache
137
+ read_from_cache = if !@flag_contents || !@last_cache
138
138
  false
139
139
  elsif cache_duration == Float::INFINITY
140
140
  true
@@ -155,7 +155,7 @@ module OpenFeature
155
155
  # Returns a value for the requested flag_key
156
156
  #
157
157
  # @param flag_key [String] requested flag key
158
- # @param type ["boolean", "number", "float", "string"]
158
+ # @param type ["boolean", "number", "float", "string", "array"]
159
159
  def read_value_with_cache(flag_key:, type:)
160
160
  read_all_values_with_cache.detect { |f| f["kind"] == type && f["name"] == flag_key }
161
161
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "openfeature/sdk"
3
+ require "open_feature/sdk"
4
4
  require "erb"
5
5
 
6
6
  module OpenFeature
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "openfeature/sdk"
3
+ require "open_feature/sdk"
4
4
  require "faraday"
5
5
 
6
6
  module OpenFeature
@@ -30,9 +30,12 @@ module OpenFeature
30
30
  NAME = "Http Provider"
31
31
 
32
32
  def read_and_parse_flags
33
- headers = extra_options.fetch(:headers, {})
34
- uri = URI(source)
35
- base_url = "#{uri.scheme}://#{uri.host}:#{uri.port}"
33
+ options = extra_options.clone
34
+ headers = options.fetch(:headers, {})
35
+ uri = URI(source)
36
+ base_url = "#{uri.scheme}://#{uri.host}:#{uri.port}"
37
+ authentication_strategy = options.delete(:authentication_strategy)
38
+ logger = options.delete(:logger)
36
39
 
37
40
  if format == :yaml
38
41
  headers["Content-Type"] ||= "application/yaml"
@@ -40,8 +43,12 @@ module OpenFeature
40
43
  headers["Content-Type"] ||= "application/json"
41
44
  end
42
45
 
43
- client = Faraday.new(url: base_url, **extra_options, headers: headers)
44
- res = client.get(uri.request_uri)
46
+ client = Faraday.new(url: base_url, **options, headers: headers) do |conn|
47
+ conn.request(*authentication_strategy) if authentication_strategy
48
+ conn.response(:logger, logger) if logger
49
+ end
50
+
51
+ res = client.get(uri.request_uri)
45
52
 
46
53
  return custom_parser.call(res.body) if custom_parser
47
54
 
@@ -3,7 +3,7 @@
3
3
  module OpenFeature
4
4
  module SDK
5
5
  module Contrib
6
- VERSION = "0.3.0"
6
+ VERSION = "0.5.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.3.0
4
+ version: 0.5.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-10-03 00:00:00.000000000 Z
11
+ date: 2024-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0.1'
47
+ version: '0.2'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0.1'
54
+ version: '0.2'
55
55
  description:
56
56
  email:
57
57
  - eugene.howe@protonmail.com
@@ -94,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
94
94
  - !ruby/object:Gem::Version
95
95
  version: '0'
96
96
  requirements: []
97
- rubygems_version: 3.2.33
97
+ rubygems_version: 3.3.7
98
98
  signing_key:
99
99
  specification_version: 4
100
100
  summary: Providers and Hooks for the OpenFeature Ruby SDK