Project

featurer

0.01
No commit activity in last 3 years
No release in over 3 years
Easy feature flag for your project shipped with Redis support
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.6
~> 10.0
~> 3.1

Runtime

~> 3.1
 Project Readme

Build Status

Featurer

Easy feature flag for your project.

By default featurer saves all the data in Redis, although you can create your own adapter.

Features

  • Shipped with Redis support by default
    • Fast
    • Doesn't overload your main database
    • Doesn't save data in your application's memory(don't lose it when restarting)
    • Redis goodies :D
  • Non-framework dependent
    • Plug it wherever you want, Sinatra, Padrino, Rails, your own scripts...
  • Create your own adapter

Installation

Add this line to your application's Gemfile:

gem 'featurer'

And then execute:

$ bundle

Or install it yourself as:

$ gem install featurer

Usage

Configure your connection:

Featurer.configure(host: host, port: port)

or use the default localhost connection:

Featurer.init

Start using it:

Per user feature

For different users:

Featurer.register(:feature, [first_user_id, second_user_id, third_user_id])

or single:

Featurer.register(:feature, user_id)

Then request the enabled feature:

Featurer.on?(:feature, user_id)

To add more users later on:

Featurer.add(:feature, first_user_id)
Featurer.add(:feature, [second_user_id, third_user_id])

In order to remove a user from a feature:

Featurer.off(:feature, user_id)
Featurer.off(:feature, [first_user_id, second_user_id])

Global feature

Featurer.register(:feature, true)

Then request the enabled feature:

Featurer.on? :feature

Deleting features

Featurer.delete(:feature)

Create your own adapter

Just extend Featurer::Adapter, add the basic methods and your are done! e.g

class TestAdapter < Featurer::Adapter
  def prepare
    # if defined this is called automatically
    # in order to initialize your adapter
    # e.g: @redis = Redis.new
  end

  def register(name, value = true)
    # your logic
  end

  def on?(name, value = true)
    # your logic
  end

  def add(name, value)
    # your logic
  end

  def off(name)
    # your logic
  end

  def delete(name)
    # your logic
end

This will automatically register your adapter in the adapters list. Also it will give it an id, in this case test, is the lowercase class name without the adapter keyword.

Then initialize your featurer:

Featurer.configure(adapter: :test, custom: :option)

Your are ready to go! No need to call .init

Contributing

  1. Fork it ( https://github.com/ainformatico/featurer/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

License

Copyright (c) 2014 Alejandro El Informático

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.