0.01
There's a lot of open issues
Ruby SDK for an the specifications for the open standard of feature flag management
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 13.0
~> 3.12.0
~> 1.37.1
>= 0
~> 0.22.0
 Project Readme

OpenFeature SDK for Ruby

a v0.5.1 Ruby Build Gem version

This is the Ruby implementation of OpenFeature, a vendor-agnostic abstraction library for evaluating feature flags.

We support multiple data types for flags (numbers, strings, booleans, objects) as well as hooks, which can alter the lifecycle of a flag evaluation.

Support Matrix

Ruby Version OS
Ruby 3.1.4 Windows, MacOS, Linux
Ruby 3.2.3 Windows, MacOS, Linux
Ruby 3.3.0 Windows, MacOS, Linux

Installation

Install the gem and add to the application's Gemfile by executing:

bundle add openfeature-sdk

If bundler is not being used to manage dependencies, install the gem by executing:

gem install openfeature-sdk

Usage

require 'open_feature/sdk'
require 'json' # For JSON.dump

# API Initialization and configuration

OpenFeature::SDK.configure do |config|
    # your provider of choice
    config.provider = OpenFeature::SDK::Provider::NoOpProvider.new
end

# Create a client
client = OpenFeature::SDK.build_client(name: "my-app")

# fetching boolean value feature flag
bool_value = client.fetch_boolean_value(flag_key: 'boolean_flag', default_value: false)

# fetching string value feature flag
string_value = client.fetch_string_value(flag_key: 'string_flag', default_value: false)

# fetching number value feature flag
float_value = client.fetch_number_value(flag_key: 'number_value', default_value: 1.0)
integer_value = client.fetch_number_value(flag_key: 'number_value', default_value: 1)

# get an object value
object = client.fetch_object_value(flag_key: 'object_value', default_value: JSON.dump({ name: 'object'}))

For complete documentation, visit: https://openfeature.dev/docs/category/concepts

Providers

Providers are the abstraction layer between OpenFeature and different flag management systems.

The NoOpProvider is an example of a minimalist provider. For complete documentation on the Provider interface, visit: https://openfeature.dev/specification/sections/providers.

In addition to the fetch_* methods, providers can optionally implement lifecycle methods that are invoked when the underlying provider is switched out. For example:

class MyProvider
  def init
    # Perform any initialization steps with flag management system here
    # Return value is ignored
  end

  def shutdown
    # Perform any shutdown/reclamation steps with flag management system here
    # Return value is ignored
  end
end

Note The OpenFeature spec defines a lifecycle method called initialize to be called when a new provider is set. To avoid conflicting with the Ruby initialize method, this method should be named init when creating a provider.

Contributing

See CONTRIBUTING.md for details on how to contribute to the OpenFeature project.

Our community meetings are held regularly and open to everyone. Check the OpenFeature community calendar for specific dates and for the Zoom meeting links.

License

Apache License 2.0