Project

foggle

0.0
No commit activity in last 3 years
No release in over 3 years
Environment-based feature toggle Ruby gem
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.11
~> 10.0
~> 3.0
~> 0.38
~> 0.11
>= 0
 Project Readme

Foggle

Build Status Codecov Sponsor

Environment-based feature toggles for Rails

Get it.

Add this line to your application's Gemfile:

gem "foggle"

And then execute:

$ bundle

Or install it yourself as:

$ gem install foggle

Do it.

Add a feature toggle to the environment. The naming convention is FEATURE_{{NAME}}, where {{NAME}} is the feature name you're working on.

Let's say you're working on cool stuff. 😎

# add to the environment
FEATURE_COOL_STUFF=true

In your views and controllers, you have access to the method that rules them all: enabled?.

<% if enabled? :cool_stuff %>
  <%= render "cool_stuff" %>
<% end %>

This method just reads in the environment variable you've set. Returns true or false.

There are a couple ways to use foggle, depending on your preference.

feature? is an alias for enabled?.

enabled? :cool_stuff
feature? :cool_stuff

These methods also take strings.

enabled? "cool_stuff"
enabled? "COOL_STUFF"

Passing in a Symbol version of your feature name is recommended, only because it looks cool and Ruby-esque. Do you.

Why?

The team at Current wanted a simple feature toggle system without having to integrate a larger feature toggle system into the codebase. Since we are already deploying to Heroku and could quickly modify environment variables across our environments, we thought we'd try this out.

Cool.

Totes.

Hack it.

Editing

# install dependencies
$ bin/setup

# run Rubocop and tests
$ bundle exec rake spec

Installation

Install Foggle locally

$ bundle exec rake install

Deploy Foggle

# bump `foggle/version`
$ bundle exec rake release

Make it.

Bug reports? Ideas? Bring 'em. 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

Copyright 2016 Macklin Underdown

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.