Skip to content
/ ffeature Public

Wrapper around Flipper for Rails projects to remove ugly global variables like $flipper.

Notifications You must be signed in to change notification settings

fs/ffeature

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FFeature

Build Status Dependency Status

This is simple wrapper around Flipper for Rails projects to remove ugly global variables like $flipper.

Usage

  • ffeature?(feature, user = current_user) helper in views and controllers
  • FFeature.enabled?(feature, user) helper for PORO

In case user or current_user responds to #tester? and returns true it will be registered in testers Flipper group. For that group all features defined in FFeature.features will be enabled by default.

Configuration

You can configure FFeature in config/inititalizers/ffeature.rb

# config/inititalizers/ffeature.rb

require "flipper"
require "flipper/adapters/redis"

url = ENV.fetch("REDISTOGO_URL", ENV.fetch("REDIS_URL", nil))
url = URI.parse(url) if url.present?

redis = Redis.new(url: url)
adapter = Flipper::Adapters::Redis.new(redis)

FFeature.configure do |config|
  config.features = %i(user_management)
  config.ip_whitelist = ENV.fetch("FLIPPER_UI_IP_WHITELIST", "").split(",")
  config.flipper = Flipper.new(adapter)
  config.dev_mode = ENV["FEATURE_DEV_MODE"].present?
end

Following options are available:

  • features – list of features registered and enabled by default for testers.
  • ip_whitelist – list of IP addresses, could be used to configure FlipperUI route constraints
  • dev_mode – if enabled all features considered enabled for all users

FlipperUI

You can use FlipperUI to have more robust control over features.

# config/routes.rb
constraints(->(request) { FFeature.ip_allowed?(request.remote_ip) }) do
  mount Flipper::UI.app(FFeature.flipper) => "/flipper"
end

Credits

FFeature is maintained and was written by Flatstack with the help of our contributors.

About

Wrapper around Flipper for Rails projects to remove ugly global variables like $flipper.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published