GithubHelp home page GithubHelp logo

dolphin's Introduction

Dolphin

<img src=“https://secure.travis-ci.org/songkick/dolphin.png?branch=master” alt=“Build Status” /> <img src=“https://codeclimate.com/badge.png” />

Dolphin is a feature flipper, as Rails plugin. Use it to flip areas of your app on your off, based on pre-defined conditions.

Installation

git submodule add git://github.com/grillpanda/dolphin.git vendor/plugins/dolphin
git submodule init
git submodule update

Or

script/plugin install git://github.com/grillpanda/dolphin.git

Configuration

Define your flippers

You’ll need to add some flippers. These are called later by the feature helper and determine whether a feature should be visible or not.

Dolphin has the flippers enabled and disabled baked in. These return true and false respectively.

In config/initializers/dolphin.rb:

Dolphin.configure do
  flipper(:admin) { logged_in_user.admin? }
  flipper(:local) { request.env['HTTP_X_FORWARDED_FOR'] == '127.0.0.1' }
end

Note that whatever methods or variables you use in your flipper blocks will need to be available to the scope in which you include Dolphin::Helper.

Add some features

Add config/dolphin/features.yml and configure some features. You need to provide the name of your feature, and the name of the flipper it should use.

local_feature: local
disabled_feature: off

Important: If you want to remember your feature settings between deploys, store features.yml somewhere that will survive them and link to it.

Include the helper

module ApplicationController < ActionController::Base
  include Dolphin::Helper
end

module ApplicationHelper
  include Dolphin::Helper
end

Usage

Displaying a feature, or not

Use your super-secret mondo-feature with the feature helper method.

<% feature :local_feature do %>
  <h1>MMM, TUNA</h1>
<% end %>

Dolphin will call the flipper associated with the feature and run what’s in the feature block if the result is truthy. If a feature or a flipper isn’t found, or there’s an error with the flipper, whatever’s in the feature block won’t be run.

You can pass a partial to the feature helper instead of a block.

<%= feature(:local_feature, :partial => 'tuna', :collection => @tuna) %>

You can check the availability of a feature using feature?

<%= link_to('TUNA FISH', tuna_path) if feature?(:tuna) %>

Considerations

Dolphin stores it’s feature configuration on disk, and needs to read it once per request. This hasn’t been a performance issue for us, but it’s something to keep in mind.

License

Copyright © 2010 Matt Johnson, released under the MIT license

dolphin's People

Contributors

danlucraft avatar dwo avatar jcoglan avatar josephwilk avatar vivienbarousse avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.