# Contingency

“Freedom is the recognition of contingency.”

  • Richard M. Rorty

Contingency is the custom error page controller you’ve implemented in every project you’ve ever written. It’s compatibile with every framework you’ve ever implemented a project in. A Contingency Plan has been written for every Ruby framework you’re familiar with. And odds are, its better tested than your implementation.

So for the love of god, stop implementing it yourself.

It’s quick to get started, gives you full customization over Exception coverage, gives you full control over rendering your own error page, and has a contingency plan itself in the event that your custom error views trigger an Exception.

It’s also very lightweight: the core functionality (the module in contingency/plan.rb) is less than 50 lines; and only adds 3 integration methods, 2 helper methods, and 1 controller action method to your controller. Everything but the controller method is private. The rest of the codebase else is just a matter of integration. It’s a hard codebase to get lost in.

Experience true freedom, and make yourself a Contingency Plan.

## Table of Contents

## Installation

Add these lines to your application’s Gemfile:

gem 'contingency',                    '~> 1.0'
gem 'contingency_my-framework-name',  '~> x.0'

…where my-framework-name is the name of your framework.

Then, execute:

$ bundle

## Configuration

Contingency

## Supported Integrations

Contingency Plan Integration Quality Version Maintainer
Rails Poor 0.0.1 christhekeele

### Rails

## Custom Integrations

If the framework you’re using doesn’t have a Contingency Plan integration, you’re only 3 methods away from integrating it yourself.

### Integrating it Yourself

It’s easy to integrate Contingency into your own app. Contingency only relys on 3 methods to communicate with your framework:

#### Integration Dependencies

If you decide to go through this trouble, you really should consider contributing your Contingency Plan integration to Contingency.</a> I’ll be more than happy to help you develop your integration until it meets our minimum quality standards, if it doesn’t out-of-the-box.

## Versioning

### Contingency Versioning

Contingency itself is versioned as it changes. It bumps its major version as its API changes, which is rarely, as its public API only requires 3 methods. It uses symantic versioning. This means you should safely be able to install it with loose bundler dependencies.

### Integration Versioning

#### Great

Contingency Plans should be versioned with their frameworks. Integrations that follow this simple requirement are labeled as great.

#### Good

Contingency Plans that keep up with at least the major version of their framework will result in the integration being labeled as good.

#### Poor

Contingency Plans that fail to keep up with the major version of their framework will result in the integration being labeled as poor.

#### Bad

Contingency Plans that throw off the shackles of symantic versioning and don’t follow it from the get-go, Pull Request, or fall very behind will result in the integration being labeled as bad.

I keep up with these frameworks through the Bundle Scout. You should, too! Checkest thineself lest thy wrekest thineself.

## Contributing Integrations

See contingency_rails as an example.

  1. Create a new gem named after your framework (bundle gem contingency-my_integration)
  2. Add Contingency as a dependency to your gemspec and bundle install
  3. Generate an integration template (bundle exec rake contingency:generate:plan[my_integration])
  4. Implement the 3 methods that rake instructs you to
  5. Commit your changes (git commit -am 'Created my_integration')
  6. Push (git push origin master)
  7. Follow the steps below to add autoloading your Contingency Plan in Contingency core and wait get your Pull Request accepted
  8. Create the intital build of your gem (gem build contingency-my_integration)
  9. Release your gem (gem push contingency-my_integration.gem)
  10. Revel in the fact that you’ve provided a Contingency Plan for you and yours
  11. Continue to mantain your integration over time by handling API changes and bumping the version number in accordance with the framework, lest your integration be marked as deprecated.

## Contributing to Contingency

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Add the name of your integration to the integrations array in the contingency/integration.rb file if you’re contributing a Contingency Plan
  4. Commit your changes (git commit -am 'Add some feature')
  5. Push to the branch (git push origin my-new-feature)
  6. Create new Pull Request
  7. I tell you to go back and write some tests if you haven’t already
  8. I tell you to go back and update the README.md if you haven’t already
  9. I accept your Pull Request

## Credits

### Contributers

### Shout-Outs

  • Thanks to nathanl and his excellent authorization gem, Authority, the structure of which inspired this one.
  • Thanks to ryanb, and his subscription-worthy Railscasts, which have inspired us all. Especially us Pro users.