Skip to content

Commit

Permalink
Support integer and float client resolution method and deprecate numb…
Browse files Browse the repository at this point in the history
…er method

Signed-off-by: Alexandre Chakroun <[email protected]>
  • Loading branch information
alxckn committed May 13, 2024
1 parent d4f8c98 commit c957adf
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion providers/openfeature-flagd-provider/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ PATH
specs:
openfeature-flagd-provider (0.0.1)
grpc (~> 1.50)
openfeature-sdk (~> 0.3)
openfeature-sdk (~> 0.3.1)

GEM
remote: https://rubygems.org/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,7 @@ def fetch_boolean_value(flag_key:, default_value:, evaluation_context: nil)
end

def fetch_number_value(flag_key:, default_value:, evaluation_context: nil)
case default_value
when Integer
fetch_integer_value(flag_key: flag_key, default_value: default_value, evaluation_context: evaluation_context)
when Float
fetch_float_value(flag_key: flag_key, default_value: default_value, evaluation_context: evaluation_context)
end
raise "fetch_number_value is not supported by flagd"
end

def fetch_integer_value(flag_key:, default_value:, evaluation_context: nil)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
spec.require_paths = ["lib"]

spec.add_runtime_dependency "grpc", "~> 1.50"
spec.add_runtime_dependency "openfeature-sdk", "~> 0.3"
spec.add_runtime_dependency "openfeature-sdk", "~> 0.3.1"

spec.add_development_dependency "rake", "~> 13.0"
spec.add_development_dependency "rspec", "~> 3.12.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
)
end

it do
expect { client.fetch_number_value(flag_key: "integer-flag", default_value: 1) }.to raise_error(StandardError)
end

it do
expect(client.fetch_integer_value(flag_key: "integer-flag", default_value: 1).to_h).to include(
error_code: nil,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@
end

it do
expect(client.fetch_number_value(flag_key: "integer-flag", default_value: 1)).to eq(42)
expect(client.fetch_integer_value(flag_key: "integer-flag", default_value: 1)).to eq(42)
end

it do
expect(client.fetch_number_value(flag_key: "float-flag", default_value: 1.1)).to eq(4.2)
expect(client.fetch_float_value(flag_key: "float-flag", default_value: 1.1)).to eq(4.2)
end

it do
Expand Down Expand Up @@ -149,7 +149,7 @@
end

it do
expect(client.fetch_number_details(flag_key: "integer-flag", default_value: 1).resolution_details.to_h).to include(
expect(client.fetch_integer_details(flag_key: "integer-flag", default_value: 1).resolution_details.to_h).to include(
error_code: nil,
error_message: nil,
reason: "STATIC",
Expand All @@ -159,7 +159,7 @@
end

it do
expect(client.fetch_number_details(flag_key: "float-flag", default_value: 1.1).resolution_details.to_h).to include(
expect(client.fetch_float_details(flag_key: "float-flag", default_value: 1.1).resolution_details.to_h).to include(
error_code: nil,
error_message: nil,
reason: "STATIC",
Expand Down

0 comments on commit c957adf

Please sign in to comment.