# Plug [![Maintainability](https://api.codeclimate.com/v1/badges/6246b1cd8e42603c42f6/maintainability)](https://codeclimate.com/github/DigitalNZ/plug/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/6246b1cd8e42603c42f6/test_coverage)](https://codeclimate.com/github/DigitalNZ/plug/test_coverage) [![Build Status](https://travis-ci.org/DigitalNZ/plug.svg?branch=master)](https://travis-ci.org/DigitalNZ/plug) A Rails engine to turn on/off features (Feature flipper). ### Features - Supports Rails 3 and above - MySQL - Set notices ### Prerequisites - Rails version 3 and above - MySQL ### Getting Started Add this line to your application's Gemfile: ```ruby gem 'plug' ``` Execute: ```bash → bundle ``` And run the install generator: ```bash → rails g plug:install → rails plug:install:migrations → rake plug:install:migrations # For Rails <= 3.x → rails db:migrate # Newer version of Rails → rake db:migrate # Older version of Rails → rails s ``` ### Usage Go to `localhost:3000/plug` and start creating features. Use the provided method to check if the feature is enabled. ```ruby Plug.enabled?('my-awesome-feature-slug') ``` If you wanted to restrict routes, you can use `Plug::Constraint` class ```ruby Rails.application.routes.draw do resources :blog, constraint: Plug::Constraint.new('my-awesome-feature-slug') end ``` Notices can be displayed using the `Plug.notice` method. ```erb <%= Plug.notice('my-awesome-feature-slug') %> ``` If you have custom HTML for notice, you can pass a block. ```erb <% Plug.notice('my-awesome-feature-slug') do |notice| %>
<%= notice %>