openfeature-ruby-sdk-contrib 0.0.5 → 0.1.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 +4 -4
- data/Gemfile.lock +47 -32
- data/lib/open_feature/sdk/contrib/providers/common.rb +6 -2
- data/lib/open_feature/sdk/contrib/providers/file_provider.rb +1 -1
- data/lib/open_feature/sdk/contrib/providers/http_provider.rb +62 -0
- data/lib/open_feature/sdk/contrib/version.rb +1 -1
- data/lib/open_feature/sdk/contrib.rb +1 -0
- metadata +11 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3e791af8182bb9d8d4bb7c50c76415a85103c3be707b114dd143b506bf375565
|
|
4
|
+
data.tar.gz: 4b17588e1e77169ee3d646f5fef7e6e6a9cf1318d3d95ce9ce27e51823053a2c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: af5c29d9bc12d92a52f45581e754973cd1c2a019023a8a1af837733562c96621c6b453090c91e0ea2fb4bf4b61a6733dc448466535769bfb6c80d7179bf71db7
|
|
7
|
+
data.tar.gz: 00a06c0ebce0599856aae41f38bcb04b098ce893556e3b4479a6f33b2608d9d32014632f9052e99f76ef35fa34ca5a84addd42569306346c9cf97e4cab3e4983
|
data/Gemfile.lock
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
openfeature-ruby-sdk-contrib (0.0.
|
|
4
|
+
openfeature-ruby-sdk-contrib (0.0.5)
|
|
5
5
|
concurrent-ruby (~> 1.2.2)
|
|
6
|
-
faraday (~> 2.7.
|
|
6
|
+
faraday (~> 2.7.10)
|
|
7
7
|
openfeature-sdk (~> 0.1)
|
|
8
8
|
|
|
9
9
|
GEM
|
|
@@ -14,69 +14,84 @@ GEM
|
|
|
14
14
|
coderay (1.1.3)
|
|
15
15
|
concurrent-ruby (1.2.2)
|
|
16
16
|
diff-lcs (1.5.0)
|
|
17
|
-
faraday (2.7.
|
|
17
|
+
faraday (2.7.10)
|
|
18
18
|
faraday-net_http (>= 2.0, < 3.1)
|
|
19
19
|
ruby2_keywords (>= 0.0.4)
|
|
20
20
|
faraday-net_http (3.0.2)
|
|
21
21
|
json (2.6.3)
|
|
22
|
+
language_server-protocol (3.17.0.3)
|
|
23
|
+
lint_roller (1.1.0)
|
|
22
24
|
method_source (1.0.0)
|
|
23
25
|
openfeature-sdk (0.1.0)
|
|
24
|
-
parallel (1.
|
|
25
|
-
parser (3.2.
|
|
26
|
+
parallel (1.23.0)
|
|
27
|
+
parser (3.2.2.3)
|
|
26
28
|
ast (~> 2.4.1)
|
|
27
|
-
|
|
29
|
+
racc
|
|
30
|
+
pry (0.14.2)
|
|
28
31
|
coderay (~> 1.1)
|
|
29
32
|
method_source (~> 1.0)
|
|
30
33
|
pry-byebug (3.10.1)
|
|
31
34
|
byebug (~> 11.0)
|
|
32
35
|
pry (>= 0.13, < 0.15)
|
|
36
|
+
racc (1.7.1)
|
|
33
37
|
rainbow (3.1.1)
|
|
34
38
|
rake (13.0.6)
|
|
35
|
-
regexp_parser (2.
|
|
36
|
-
rexml (3.2.
|
|
37
|
-
rspec (3.
|
|
38
|
-
rspec-core (~> 3.
|
|
39
|
-
rspec-expectations (~> 3.
|
|
40
|
-
rspec-mocks (~> 3.
|
|
41
|
-
rspec-core (3.
|
|
42
|
-
rspec-support (~> 3.
|
|
43
|
-
rspec-expectations (3.
|
|
39
|
+
regexp_parser (2.8.1)
|
|
40
|
+
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)
|
|
44
48
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
45
|
-
rspec-support (~> 3.
|
|
46
|
-
rspec-mocks (3.
|
|
49
|
+
rspec-support (~> 3.12.0)
|
|
50
|
+
rspec-mocks (3.12.6)
|
|
47
51
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
48
|
-
rspec-support (~> 3.
|
|
49
|
-
rspec-support (3.
|
|
50
|
-
rubocop (1.
|
|
52
|
+
rspec-support (~> 3.12.0)
|
|
53
|
+
rspec-support (3.12.1)
|
|
54
|
+
rubocop (1.52.1)
|
|
51
55
|
json (~> 2.3)
|
|
52
56
|
parallel (~> 1.10)
|
|
53
|
-
parser (>= 3.2.
|
|
57
|
+
parser (>= 3.2.2.3)
|
|
54
58
|
rainbow (>= 2.2.2, < 4.0)
|
|
55
59
|
regexp_parser (>= 1.8, < 3.0)
|
|
56
60
|
rexml (>= 3.2.5, < 4.0)
|
|
57
|
-
rubocop-ast (>= 1.
|
|
61
|
+
rubocop-ast (>= 1.28.0, < 2.0)
|
|
58
62
|
ruby-progressbar (~> 1.7)
|
|
59
63
|
unicode-display_width (>= 2.4.0, < 3.0)
|
|
60
|
-
rubocop-ast (1.
|
|
64
|
+
rubocop-ast (1.29.0)
|
|
61
65
|
parser (>= 3.2.1.0)
|
|
62
|
-
rubocop-capybara (2.
|
|
66
|
+
rubocop-capybara (2.18.0)
|
|
63
67
|
rubocop (~> 1.41)
|
|
64
|
-
rubocop-
|
|
68
|
+
rubocop-factory_bot (2.23.1)
|
|
69
|
+
rubocop (~> 1.33)
|
|
70
|
+
rubocop-performance (1.18.0)
|
|
65
71
|
rubocop (>= 1.7.0, < 2.0)
|
|
66
72
|
rubocop-ast (>= 0.4.0)
|
|
67
73
|
rubocop-rake (0.6.0)
|
|
68
74
|
rubocop (~> 1.0)
|
|
69
|
-
rubocop-rspec (2.
|
|
75
|
+
rubocop-rspec (2.23.0)
|
|
70
76
|
rubocop (~> 1.33)
|
|
71
77
|
rubocop-capybara (~> 2.17)
|
|
78
|
+
rubocop-factory_bot (~> 2.22)
|
|
72
79
|
ruby-progressbar (1.13.0)
|
|
73
80
|
ruby2_keywords (0.0.5)
|
|
74
|
-
standard (
|
|
75
|
-
|
|
81
|
+
standard (1.30.1)
|
|
82
|
+
language_server-protocol (~> 3.17.0.2)
|
|
83
|
+
lint_roller (~> 1.0)
|
|
84
|
+
rubocop (~> 1.52.0)
|
|
85
|
+
standard-custom (~> 1.0.0)
|
|
86
|
+
standard-performance (~> 1.1.0)
|
|
87
|
+
standard-custom (1.0.2)
|
|
88
|
+
lint_roller (~> 1.0)
|
|
89
|
+
rubocop (~> 1.50)
|
|
90
|
+
standard-performance (1.1.2)
|
|
91
|
+
lint_roller (~> 1.1)
|
|
92
|
+
rubocop-performance (~> 1.18.0)
|
|
76
93
|
unicode-display_width (2.4.2)
|
|
77
|
-
|
|
78
|
-
yard (0.9.28)
|
|
79
|
-
webrick (~> 1.7.0)
|
|
94
|
+
yard (0.9.34)
|
|
80
95
|
|
|
81
96
|
PLATFORMS
|
|
82
97
|
arm64-darwin-22
|
|
@@ -90,7 +105,7 @@ DEPENDENCIES
|
|
|
90
105
|
rubocop-performance (~> 1.15)
|
|
91
106
|
rubocop-rake (~> 0.6)
|
|
92
107
|
rubocop-rspec (~> 2.19)
|
|
93
|
-
standard (
|
|
108
|
+
standard (>= 1.0.0)
|
|
94
109
|
yard (~> 0.9)
|
|
95
110
|
|
|
96
111
|
BUNDLED WITH
|
|
@@ -13,6 +13,9 @@ module OpenFeature
|
|
|
13
13
|
keyword_init: true
|
|
14
14
|
)
|
|
15
15
|
|
|
16
|
+
# @return [Hash]
|
|
17
|
+
attr_reader :extra_options
|
|
18
|
+
|
|
16
19
|
# @return [String]
|
|
17
20
|
attr_reader :source
|
|
18
21
|
|
|
@@ -42,11 +45,12 @@ module OpenFeature
|
|
|
42
45
|
# @param custom_parser [#call<String>] If your file is not JSON or YAML you can pass a custom parser as a lambda here which will be used to parse the file instead.
|
|
43
46
|
# Even if your file is YAML or JSON you can pass this option if you opt to use a parser other than <tt>YAML.load</tt> or <tt>JSON.parse</tt>.
|
|
44
47
|
# The raw file contents will be passed to this Proc.
|
|
45
|
-
def initialize(source:, format: :yaml, deep_keys: [], cache_duration: Float::INFINITY, custom_parser: nil)
|
|
48
|
+
def initialize(source:, format: :yaml, deep_keys: [], cache_duration: Float::INFINITY, custom_parser: nil, extra_options: {})
|
|
46
49
|
@source = source
|
|
47
50
|
@format = format
|
|
48
51
|
@deep_keys = deep_keys
|
|
49
52
|
@cache_duration = cache_duration
|
|
53
|
+
@extra_options = extra_options
|
|
50
54
|
@metadata = Metadata.new(name: self.class::NAME).freeze
|
|
51
55
|
|
|
52
56
|
if format == :yaml && !custom_parser
|
|
@@ -160,7 +164,7 @@ module OpenFeature
|
|
|
160
164
|
|
|
161
165
|
return ResolutionDetails.new(value: nil) if actual_value.nil?
|
|
162
166
|
|
|
163
|
-
return_types = Array(return_types)
|
|
167
|
+
return_types = Array(return_types) + [NilClass]
|
|
164
168
|
variant_value = actual_value["variants"] ? actual_value["variants"][actual_value["value"]] : actual_value["value"]
|
|
165
169
|
|
|
166
170
|
raise OpenFeature::SDK::Contrib::InvalidReturnValueError, "Invalid flag value found: #{variant_value} is not in #{return_types.join(', ')}" unless return_types.include?(variant_value.class)
|
|
@@ -10,7 +10,7 @@ module OpenFeature
|
|
|
10
10
|
# To use <tt>FileProvider</tt>, it can be set during the configuration of the SDK
|
|
11
11
|
#
|
|
12
12
|
# OpenFeature::SDK.configure do |config|
|
|
13
|
-
# config.provider = OpenFeature::SDK::Contrib::FileProvider.new(
|
|
13
|
+
# config.provider = OpenFeature::SDK::Contrib::Providers::FileProvider.new(source: "/path/to/file")
|
|
14
14
|
# end
|
|
15
15
|
#
|
|
16
16
|
# Within the <tt>FileProvider</tt>, the following methods exist
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
require "openfeature/sdk"
|
|
2
|
+
require "faraday"
|
|
3
|
+
|
|
4
|
+
module OpenFeature
|
|
5
|
+
module SDK
|
|
6
|
+
module Contrib
|
|
7
|
+
module Providers
|
|
8
|
+
# Read feature flags from a URL.
|
|
9
|
+
#
|
|
10
|
+
# To use <tt>FileProvider</tt>, it can be set during the configuration of the SDK. The `extra_options` hash can be anything passed to `Faraday.new``
|
|
11
|
+
#
|
|
12
|
+
# OpenFeature::SDK.configure do |config|
|
|
13
|
+
# config.provider = OpenFeature::SDK::Contrib::Providers::HttpProvider.new(source: http://path_to_flags, extra_options: { headers: { Auhorization: "token" }})
|
|
14
|
+
# end
|
|
15
|
+
#
|
|
16
|
+
# Within the <tt>FileProvider</tt>, the following methods exist
|
|
17
|
+
#
|
|
18
|
+
# * <tt>fetch_boolean_value</tt> - Retrieve feature flag boolean value from the file
|
|
19
|
+
#
|
|
20
|
+
# * <tt>fetch_string_value</tt> - Retrieve feature flag string value from the file
|
|
21
|
+
#
|
|
22
|
+
# * <tt>fetch_number_value</tt> - Retrieve feature flag number value from the file
|
|
23
|
+
#
|
|
24
|
+
# * <tt>fetch_object_value</tt> - Retrieve feature flag object value from the file
|
|
25
|
+
class HttpProvider
|
|
26
|
+
include Common
|
|
27
|
+
|
|
28
|
+
NAME = "Http Provider".freeze
|
|
29
|
+
|
|
30
|
+
def read_and_parse_flags
|
|
31
|
+
headers = extra_options.fetch(:headers, {})
|
|
32
|
+
uri = URI(source)
|
|
33
|
+
base_url = "#{uri.scheme}://#{uri.host}:#{uri.port}"
|
|
34
|
+
|
|
35
|
+
if format == :yaml
|
|
36
|
+
headers["Content-Type"] ||= "application/yaml"
|
|
37
|
+
elsif format == :json
|
|
38
|
+
headers["Content-Type"] ||= "application/json"
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
client = Faraday.new(url: base_url, **extra_options, headers: headers)
|
|
42
|
+
res = client.get(uri.request_uri)
|
|
43
|
+
|
|
44
|
+
return custom_parser.call(res.body) if custom_parser
|
|
45
|
+
|
|
46
|
+
begin
|
|
47
|
+
@flag_contents = if format == :yaml
|
|
48
|
+
YAML.safe_load(res.body)
|
|
49
|
+
else
|
|
50
|
+
JSON.parse(res.body)
|
|
51
|
+
end
|
|
52
|
+
rescue
|
|
53
|
+
@flag_contents = {}
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
@flag_contents
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
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.0
|
|
4
|
+
version: 0.1.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-08-07 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: concurrent-ruby
|
|
@@ -30,14 +30,14 @@ dependencies:
|
|
|
30
30
|
requirements:
|
|
31
31
|
- - "~>"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: 2.7.
|
|
33
|
+
version: 2.7.10
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - "~>"
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: 2.7.
|
|
40
|
+
version: 2.7.10
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: openfeature-sdk
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -86,14 +86,14 @@ dependencies:
|
|
|
86
86
|
requirements:
|
|
87
87
|
- - "~>"
|
|
88
88
|
- !ruby/object:Gem::Version
|
|
89
|
-
version:
|
|
89
|
+
version: 1.55.1
|
|
90
90
|
type: :development
|
|
91
91
|
prerelease: false
|
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
|
93
93
|
requirements:
|
|
94
94
|
- - "~>"
|
|
95
95
|
- !ruby/object:Gem::Version
|
|
96
|
-
version:
|
|
96
|
+
version: 1.55.1
|
|
97
97
|
- !ruby/object:Gem::Dependency
|
|
98
98
|
name: rubocop-performance
|
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -140,16 +140,16 @@ dependencies:
|
|
|
140
140
|
name: standard
|
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
|
142
142
|
requirements:
|
|
143
|
-
- - "
|
|
143
|
+
- - ">="
|
|
144
144
|
- !ruby/object:Gem::Version
|
|
145
|
-
version:
|
|
145
|
+
version: 1.0.0
|
|
146
146
|
type: :development
|
|
147
147
|
prerelease: false
|
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
|
149
149
|
requirements:
|
|
150
|
-
- - "
|
|
150
|
+
- - ">="
|
|
151
151
|
- !ruby/object:Gem::Version
|
|
152
|
-
version:
|
|
152
|
+
version: 1.0.0
|
|
153
153
|
- !ruby/object:Gem::Dependency
|
|
154
154
|
name: yard
|
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -182,6 +182,7 @@ files:
|
|
|
182
182
|
- lib/open_feature/sdk/contrib/client.rb
|
|
183
183
|
- lib/open_feature/sdk/contrib/providers/common.rb
|
|
184
184
|
- lib/open_feature/sdk/contrib/providers/file_provider.rb
|
|
185
|
+
- lib/open_feature/sdk/contrib/providers/http_provider.rb
|
|
185
186
|
- lib/open_feature/sdk/contrib/version.rb
|
|
186
187
|
homepage: https://github.com/ehowe/openfeature-ruby-sdk-contrib
|
|
187
188
|
licenses:
|