The official Unleash OpenFeature provider for Ruby.
- Ruby 3.4+
- Bundler
gem 'unleash-openfeature-provider'For local development:
bundle installIf you cloned without submodules, initialize the verifier harness:
git submodule update --init --recursiveIf the verifier submodule is intentionally updated, refresh it and commit the new submodule pointer:
git submodule update --remote --merge verifier
git statusrequire 'open_feature/sdk'
require 'unleash'
require 'unleash-openfeature-provider'
unleash_client = Unleash::Client.new(
app_name: 'my-ruby-app',
url: 'https://app.unleash-hosted.com/demo/api',
custom_http_headers: {
Authorization: '<client-api-key>'
}
)
OpenFeature::SDK.configure do |config|
config.set_provider(Unleash::OpenFeature::Provider::UnleashFlagProvider.new(unleash_client))
end
client = OpenFeature::SDK.build_client
enabled = client.fetch_boolean_value(
flag_key: 'my-feature',
default_value: false,
evaluation_context: OpenFeature::SDK::EvaluationContext.new(targeting_key: 'user-123')
)bundle exec ruby examples/boolean_flag.rb \
--url https://app.unleash-hosted.com/demo/api \
--api-key "$UNLEASH_API_KEY" \
--flag-key my-feature \
--targeting-key user-123bundle exec rake buildBuild artifacts are written to pkg/.
bundle exec rspecThe contract tests use the verifier submodule. To refresh it:
git submodule update --remote --merge verifierbundle exec rubocop