Getting started with Ruby SDK

1 minute read

This section describes how to set up and install the Ruby SDK and how to deploy a feature flag.

Step 1 - Setting up

The following are prerequisites for installing the Ruby SDK:

  1. Create a CloudBees Feature Management account. See Signup Page to create an account.

  2. Get your environment key. Copy your environment key from App settings > Environments > Key.

Step 2 - Installing the Ruby SDK

Add the CloudBees Feature Management Ruby library to your application by running the following commands:

# Add the SDK to your application $ gem install rox-rollout

Add the following lines of code to your application:

# Import SDK require 'rox/server/rox_server' # Create Roxflags in the Flags container class class Flags attr_accessor :enableTutorial, :titleColors, :page, :percentage def initialize # Define the feature flags @enableTutorial = Rox::Server::RoxFlag.new(false) @titleColors = Rox::Server::RoxString.new('red', ['red', 'blue', 'green']) @page = Rox::Server::RoxInt.new(1, [1, 2, 3]) @percentage = Rox::Server::RoxDouble.new(99.9, [10.5, 50.0, 99.9]) end end flags = Flags.new # Register the flags container Rox::Server::RoxServer.register(flags) # Setup the environment key Rox::Server::RoxServer.setup("<ROLLOUT-ENV-KEY>").join # Boolean flag example puts "enableTutorial is #{flags.enableTutorial.enabled? ? "enabled" : "disabled"}" # String flag example puts "titleColors is #{flags.titleColors.value}" # Int flag example puts "page is #{flags.page.value}" # Double flag example puts "percentage is #{flags.percentage.value}"

Container class registration and environment key setup

  • You cannot call Rox.setup() twice in the same runtime.

Run your application

Running the application

The flag name is automatically added to the CloudBees Feature Management dashboard after running the application.