openfeature-ruby-sdk-contrib 0.1.0 → 0.1.2

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: 3e791af8182bb9d8d4bb7c50c76415a85103c3be707b114dd143b506bf375565
4
- data.tar.gz: 4b17588e1e77169ee3d646f5fef7e6e6a9cf1318d3d95ce9ce27e51823053a2c
3
+ metadata.gz: 6c405f0d8a129b8a8890acb6c7c23ff5a6503a4000a0e2cd794f376f905a4485
4
+ data.tar.gz: a13bf2b6d68a6b7e34dbd87a1a43d26bc5838f386f50db84959b521d77195f8c
5
5
  SHA512:
6
- metadata.gz: af5c29d9bc12d92a52f45581e754973cd1c2a019023a8a1af837733562c96621c6b453090c91e0ea2fb4bf4b61a6733dc448466535769bfb6c80d7179bf71db7
7
- data.tar.gz: 00a06c0ebce0599856aae41f38bcb04b098ce893556e3b4479a6f33b2608d9d32014632f9052e99f76ef35fa34ca5a84addd42569306346c9cf97e4cab3e4983
6
+ metadata.gz: af206ed84de4785ceaf8a68d2f9d90be936a864a76e52f807b77925584b43c4a3e6a484b185c5154c82722e1c65af7154f1196746bd5397ec473f27925035b10
7
+ data.tar.gz: 13919f472a49086f191a2172f6a61e86a4d09179b4ab8d0c3773ad4c52757deabe3bfc52e6d2e09c00468cb3ad596c7b2787c5ba5af4a3cb7197ebcb18411644
data/.rubocop.yml CHANGED
@@ -36,16 +36,25 @@ Metrics/AbcSize:
36
36
  Metrics/CyclomaticComplexity:
37
37
  Enabled: false
38
38
 
39
+ Metrics/MethodLength:
40
+ Enabled: false
41
+
42
+ Metrics/ParameterLists:
43
+ Enabled: false
44
+
39
45
  Metrics/PerceivedComplexity:
40
46
  Enabled: false
41
47
 
48
+ RSpec/ExpectInHook:
49
+ Enabled: false
50
+
42
51
  RSpec/MessageSpies:
43
52
  Enabled: false
44
53
 
45
54
  RSpec/MultipleExpectations:
46
55
  Enabled: false
47
56
 
48
- Standard/SemanticBlocks:
57
+ Style/Documentation:
49
58
  Enabled: false
50
59
 
51
60
  Style/StringLiterals:
data/Gemfile CHANGED
@@ -7,6 +7,13 @@ gemspec
7
7
 
8
8
  gem "rake", "~> 13.0"
9
9
 
10
- gem "rspec", "~> 3.0"
11
-
12
- gem "rubocop", "~> 1.21"
10
+ group :development, :test do
11
+ gem "pry-byebug", "~> 3.10.1"
12
+ gem "rspec", "~> 3.11"
13
+ gem "rubocop", "~> 1.52.0"
14
+ gem "rubocop-performance", "~> 1.15"
15
+ gem "rubocop-rake", "~> 0.6"
16
+ gem "rubocop-rspec", "~> 2.19"
17
+ gem "standard", ">= 1.30.1"
18
+ gem "yard", "~> 0.9"
19
+ end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- openfeature-ruby-sdk-contrib (0.0.5)
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)
@@ -100,12 +100,12 @@ DEPENDENCIES
100
100
  openfeature-ruby-sdk-contrib!
101
101
  pry-byebug (~> 3.10.1)
102
102
  rake (~> 13.0)
103
- rspec (~> 3.0)
104
- rubocop (~> 1.21)
103
+ rspec (~> 3.11)
104
+ rubocop (~> 1.52.0)
105
105
  rubocop-performance (~> 1.15)
106
106
  rubocop-rake (~> 0.6)
107
107
  rubocop-rspec (~> 2.19)
108
- standard (>= 1.0.0)
108
+ standard (>= 1.30.1)
109
109
  yard (~> 0.9)
110
110
 
111
111
  BUNDLED WITH
data/README.md CHANGED
@@ -24,32 +24,32 @@ A feature flag format of:
24
24
  { "name" => "example_named_number",
25
25
  "kind" => "number",
26
26
  "variants" => { "small" => 8, "medium" => 128, "large" => 2048 },
27
- "value" => "medium",
27
+ "variant" => "medium",
28
28
  "enabled" => true },
29
29
  { "name" => "example_invalid_named_number",
30
30
  "kind" => "number",
31
31
  "variants" => { "small" => "a string", "medium" => "a string", "large" => "a string" },
32
- "value" => "medium",
32
+ "variant" => "medium",
33
33
  "enabled" => true },
34
34
  { "name" => "example_disabled_named_number",
35
35
  "kind" => "number",
36
36
  "variants" => { "small" => 8, "medium" => 128, "large" => 2048 },
37
- "value" => "medium",
37
+ "variant" => "medium",
38
38
  "enabled" => false },
39
39
  { "name" => "example_named_float",
40
40
  "kind" => "float",
41
41
  "variants" => { "pi" => 3.141592653589793, "e" => 2.718281828459045, "phi" => 1.618033988749894 },
42
- "value" => "e",
42
+ "variant" => "e",
43
43
  "enabled" => true },
44
44
  { "name" => "example_invalid_named_float",
45
45
  "kind" => "float",
46
46
  "variants" => { "pi" => "a string", "e" => "a string", "phi" => "a string" },
47
- "value" => "e",
47
+ "variant" => "e",
48
48
  "enabled" => true },
49
49
  { "name" => "example_disabled_named_float",
50
50
  "kind" => "float",
51
51
  "variants" => { "pi" => 3.141592653589793, "e" => 2.718281828459045, "phi" => 1.618033988749894 },
52
- "value" => "e",
52
+ "variant" => "e",
53
53
  "enabled" => false }
54
54
  ]
55
55
  ```
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "openfeature/sdk/client"
2
4
 
3
5
  module OpenFeature
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module OpenFeature
2
4
  module SDK
3
5
  module Contrib
@@ -60,6 +62,11 @@ module OpenFeature
60
62
  end
61
63
  end
62
64
 
65
+ def expire_cache!
66
+ @last_cache = nil
67
+ @flag_contents = nil
68
+ end
69
+
63
70
  # Returns a boolean value for the key specified
64
71
  #
65
72
  # @param flag_key [String] flag key to search for
@@ -123,9 +130,7 @@ module OpenFeature
123
130
  def read_all_values_with_cache
124
131
  now = Time.now.to_i
125
132
 
126
- read_from_cache = if !@flag_contents
127
- false
128
- elsif !@last_cache
133
+ read_from_cache = if !@flag_contents && !@last_cache
129
134
  false
130
135
  elsif cache_duration == Float::INFINITY
131
136
  true
@@ -165,7 +170,7 @@ module OpenFeature
165
170
  return ResolutionDetails.new(value: nil) if actual_value.nil?
166
171
 
167
172
  return_types = Array(return_types) + [NilClass]
168
- variant_value = actual_value["variants"] ? actual_value["variants"][actual_value["value"]] : actual_value["value"]
173
+ variant_value = actual_value["variants"] ? actual_value["variants"][actual_value["variant"]] : actual_value["value"]
169
174
 
170
175
  raise OpenFeature::SDK::Contrib::InvalidReturnValueError, "Invalid flag value found: #{variant_value} is not in #{return_types.join(', ')}" unless return_types.include?(variant_value.class)
171
176
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "openfeature/sdk"
2
4
  require "erb"
3
5
 
@@ -25,16 +27,17 @@ module OpenFeature
25
27
  class FileProvider
26
28
  include Common
27
29
 
28
- NAME = "File Provider".freeze
30
+ NAME = "File Provider"
29
31
 
30
32
  def read_and_parse_flags
31
33
  file_contents = begin
32
34
  ERB.new(File.read(File.expand_path(source))).result
33
35
  rescue Errno::ENOENT
34
36
  @flag_contents = {}
35
- return
36
37
  end
37
38
 
39
+ return @flag_contents if @flag_contents
40
+
38
41
  return custom_parser.call(file_contents) if custom_parser
39
42
 
40
43
  @flag_contents = if format == :yaml
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "openfeature/sdk"
2
4
  require "faraday"
3
5
 
@@ -25,11 +27,11 @@ module OpenFeature
25
27
  class HttpProvider
26
28
  include Common
27
29
 
28
- NAME = "Http Provider".freeze
30
+ NAME = "Http Provider"
29
31
 
30
32
  def read_and_parse_flags
31
- headers = extra_options.fetch(:headers, {})
32
- uri = URI(source)
33
+ headers = extra_options.fetch(:headers, {})
34
+ uri = URI(source)
33
35
  base_url = "#{uri.scheme}://#{uri.host}:#{uri.port}"
34
36
 
35
37
  if format == :yaml
@@ -39,7 +41,7 @@ module OpenFeature
39
41
  end
40
42
 
41
43
  client = Faraday.new(url: base_url, **extra_options, headers: headers)
42
- res = client.get(uri.request_uri)
44
+ res = client.get(uri.request_uri)
43
45
 
44
46
  return custom_parser.call(res.body) if custom_parser
45
47
 
@@ -49,7 +51,7 @@ module OpenFeature
49
51
  else
50
52
  JSON.parse(res.body)
51
53
  end
52
- rescue
54
+ rescue StandardError
53
55
  @flag_contents = {}
54
56
  end
55
57
 
@@ -3,7 +3,7 @@
3
3
  module OpenFeature
4
4
  module SDK
5
5
  module Contrib
6
- VERSION = "0.1.0"
6
+ VERSION = "0.1.2"
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.0
4
+ version: 0.1.2
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-07 00:00:00.000000000 Z
11
+ date: 2023-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -52,118 +52,6 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0.1'
55
- - !ruby/object:Gem::Dependency
56
- name: pry-byebug
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: 3.10.1
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: 3.10.1
69
- - !ruby/object:Gem::Dependency
70
- name: rspec
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '3.11'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '3.11'
83
- - !ruby/object:Gem::Dependency
84
- name: rubocop
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: 1.55.1
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: 1.55.1
97
- - !ruby/object:Gem::Dependency
98
- name: rubocop-performance
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: '1.15'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: '1.15'
111
- - !ruby/object:Gem::Dependency
112
- name: rubocop-rake
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: '0.6'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - "~>"
123
- - !ruby/object:Gem::Version
124
- version: '0.6'
125
- - !ruby/object:Gem::Dependency
126
- name: rubocop-rspec
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - "~>"
130
- - !ruby/object:Gem::Version
131
- version: '2.19'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - "~>"
137
- - !ruby/object:Gem::Version
138
- version: '2.19'
139
- - !ruby/object:Gem::Dependency
140
- name: standard
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - ">="
144
- - !ruby/object:Gem::Version
145
- version: 1.0.0
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - ">="
151
- - !ruby/object:Gem::Version
152
- version: 1.0.0
153
- - !ruby/object:Gem::Dependency
154
- name: yard
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - "~>"
158
- - !ruby/object:Gem::Version
159
- version: '0.9'
160
- type: :development
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - "~>"
165
- - !ruby/object:Gem::Version
166
- version: '0.9'
167
55
  description:
168
56
  email:
169
57
  - eugene.howe@protonmail.com