All Projects → bibendi → Feature_toggles

bibendi / Feature_toggles

Licence: mit
This gem provides a mechanism for pending features.

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Feature toggles

CloudKitFeatureFlags
A library that lets you setup feature flagging for your iOS app using CloudKit
Stars: ✭ 91 (+193.55%)
Mutual labels:  feature-toggles
react-client-sdk
LaunchDarkly Client-side SDK for React.js
Stars: ✭ 42 (+35.48%)
Mutual labels:  feature-toggles
Flopflip
🎚Flip or flop features in your React application in real-time backed by flag provider of your choice 🚦
Stars: ✭ 334 (+977.42%)
Mutual labels:  feature-toggles
feature-flag-android
A Gradle plugin to achieve feature flag based development for Android applications.
Stars: ✭ 82 (+164.52%)
Mutual labels:  feature-toggles
ruby-server-sdk
LaunchDarkly Server-side SDK for Ruby
Stars: ✭ 25 (-19.35%)
Mutual labels:  feature-toggles
python-client
Python SDK client for Split Software
Stars: ✭ 12 (-61.29%)
Mutual labels:  feature-toggles
unleash-client-java
Unleash client SDK for Java
Stars: ✭ 86 (+177.42%)
Mutual labels:  feature-toggles
Featuretoggle
Simple, reliable feature toggles in .NET
Stars: ✭ 641 (+1967.74%)
Mutual labels:  feature-toggles
toggler
toggler is a feature flag service to decouple deployment, feature enrollment and experiments
Stars: ✭ 27 (-12.9%)
Mutual labels:  feature-toggles
Unleash
Unleash is the open source feature toggle service.
Stars: ✭ 4,679 (+14993.55%)
Mutual labels:  feature-toggles
erlang-server-sdk
LaunchDarkly Server-Side SDK for Erlang/Elixir
Stars: ✭ 16 (-48.39%)
Mutual labels:  feature-toggles
jest-launchdarkly-mock
Easily unit test LaunchDarkly feature flagged components with jest
Stars: ✭ 14 (-54.84%)
Mutual labels:  feature-toggles
Tweek
Tweek - an open source feature manager
Stars: ✭ 268 (+764.52%)
Mutual labels:  feature-toggles
flagsmith-js-client
Javascript Client for Flagsmith. Ship features with confidence using feature flags and remote config. Host yourself or use our hosted version at https://www.flagsmith.com/
Stars: ✭ 42 (+35.48%)
Mutual labels:  feature-toggles
Feature Flags
Feature flags API written in Go
Stars: ✭ 375 (+1109.68%)
Mutual labels:  feature-toggles
PowerShell-FeatureFlags
PowerShell module containing a Feature Flags implementation based on a local config file.
Stars: ✭ 15 (-51.61%)
Mutual labels:  feature-toggles
ios-client-sdk
LaunchDarkly Client-side SDK for iOS (Swift and Obj-C)
Stars: ✭ 45 (+45.16%)
Mutual labels:  feature-toggles
Javascript Client
NodeJS and Browser SDK client for Split Software
Stars: ✭ 30 (-3.23%)
Mutual labels:  feature-toggles
Fun with flags
Feature Flags/Toggles for Elixir
Stars: ✭ 554 (+1687.1%)
Mutual labels:  feature-toggles
Flags
⛳️ Feature Flags for Next.js
Stars: ✭ 277 (+793.55%)
Mutual labels:  feature-toggles

Gem Version Build Status

FeatureToggles

This gem provides a mechanism for pending features that take longer than a single release cycle. The basic idea is to have a configuration file that defines a bunch of toggles for various features you have pending. The running application then uses these toggles in order to decide whether or not to show the new feature.

Sponsored by Evil Martians

Installation

Add this line to your application's Gemfile:

gem "feature_toggles"

And then execute:

$ bundle

Or install it yourself as:

$ gem install feature_toggles

Framework-agnostic usage

Features could be defined dynamically

features = FeatureToggles.build do
  # define env var prefix to enable features
  # globally by passing MY_PREFIX_BAR=1
  env "MY_PREFIX"

  feature :bar do
    user.can_bar?
  end

  feature :foo do |user: nil|
    !user.nil? && user.can_foo?
  end
end

features.enabled?(:bar)
features.enabled?(:bar, user: user)
features.for(user: user).enabled?(:foo)

or loaded from files

features = FeatureToggles.build(["/path/to/features.rb"])

Rails usage

This is step-by-step guide to add feature_toggles to Rails application.

Step 0. (optional) Add features to User model

NOTE: This is not the part of this gem–you can model you per-user features settings differently.

class AddFeaturesToUsers < ActiveRecord::Migration
  def change
    # we use a `features` array column to store user's active features
    add_column :users, :features, :string, array: true, default: []
  end
end

Step 1. Define features

Features from file <rails-root-or-engine>/config/features.rb are loaded by convention.

# config/features.rb
env "FEATURE"

feature :chat do |user: nil|
  user&.features.include?("chat")
end

Features will be available at Rails.features after the end of application initialization.

Step 2. Add current_features helper and use it.

class ApplicationController < ActionController::Base
  # ...
  helper_method :current_features

  def current_features
    Rails.features.for(user: current_user)
  end
end

Step 3. Use current_features.

For example, in your navigation template:

<ul>
 <% if current_features.enabled?(:chat) %>
   <li><a href="/chat">Chat</a></li>
 <% end %>
</ul>

Or in your controller:

class ChatController < ApplicationController
  def index
    unless current_features.enabled?(:chat)
      return render template: "comming_soon"
    end
  end
end

Metadata

You can add arbitrary metadata to features:

feature :manual_quantity_backsync, icon: :updated, description: "Manual quantity sync for imported products" do |user: nil|
  !!user&.features&.fetch("manual_quantity_backsync", false)
end

That metadata can be later programmatically accessed and exposed into admin panels, API documentation, etc.

Rails.features.first.metadata
# => { icon: :updated, description: "Manual quantity sync for imported products" }

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/bibendi/feature_toggles. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the FeatureToggles project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].