Project

corral

0.0
No commit activity in last 3 years
No release in over 3 years
Use Corral to disable certain features in your application.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3
~> 0.10.4
~> 12.0
 Project Readme

Corral

Code Climate Travic CI

Corral

Use Corral to disable certain features in your application.

Is it any good?

Yes

What was your inspiration?

I love Paddock (for which Corral should be a nearly drop-in replacement), but found its Rails environment specific approach to be too concrete for my needs. Specifically, I wanted to toggle my features on arbitrary--or at least callable--Ruby expressions.

Setup

Put this somewhere like: config/initializers/corral.rb

include Corral

# Pass an environment to use the `in` option...
Corral.corral(Rails.env) do
  disable :torpedoes, when: -> { true }
  disable :fun_and_games, in: [:staging, :production]
  disable :cupcakes, if: ->(person) { person == "Bryan" }
end

("when" and "if" mean the same thing. Use whichever makes you happy.)

If you don't mind polluting your global namespace and want to more easily refer to these methods, you can include Corral::Helpers

include Corral::Helpers

corral(Rails.env) do
  disable :caching, in: [:development, :test, :staging]
  enable :crying, when: ->(user) { user.birthday == Date.today }
end

Usage

# If you've included Corral::Helpers
fire! if enabled?(:torpedoes)
sulk if disabled?(:cupcakes, "Bryan") # And I don't even *like* sweets!

# If you've only included Corral
fire! if Corral.enabled?(:torpedoes)
sulk if Corral.disabled?(:cupcakes, "Bryan")

Installation

Add this line to your application's Gemfile:

gem 'corral'

And then execute:

$ bundle

Or install it yourself as:

$ gem install corral

Contributing

  1. Fork it
  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 new Pull Request