Coder Social home page Coder Social logo

dice_bag's Introduction

DiceBag

Code Climate

DiceBag is a library of rake tasks for configuring web apps in the style of The Twelve-Factor App. Configuration values are picked up from the environment and used to populate configuration files from templates. Pre-packaged templates for common configuration files are provided.

Install

Add the following to your Gemfile:

gem 'dice_bag'

If you are using these tasks outside of a Rails project, add the following to your Rakefile or wherever your local rake tasks are defined:

require 'dice_bag/tasks'

Run the following command to see the new tasks:

[bundle exec] rake -D config

Create configuration files from templates

When the rake "config" task is run, configuration files are populated for all ERB template files in the project that have a ".dice" extension. Configuration values from the environment are made available to the templates through the configured object.

For example, take a "database.yml.dice" file containing this template:

development:
  database: development
  username: <%= configured.database_username || 'root' %>
  password: <%= configured.database_password %>

Then run the following command:

[bundle exec] rake DATABASE_USERNAME=alice DATABASE_PASSWORD=xyzzy config

The following "database.yml" file is generated:

development:
  database: development
  username: alice
  password: xyzzy

See the feature documentation for further examples and functionality.

As discussed in The Twelve-Factor App section on configuration, do not commit your generated configuration files to source control. Instead, commit the templates to source control and then regenerate the configuration files at deployment time by running the rake config:deploy task.

Generate pre-packaged templates

Pre-packaged templates for the following configuration files in the config directory are provided:

Run the following command to generate them:

[bundle exec] rake config:generate_all

As with your own templates, you should commit these pre-packaged templates to source control.

You can customize these pre-packaged template to your needs but if the change is a generic fix or extension, please consider contributing it back to this project so that everyone benefits.

Define your own pre-packaged templates

If you want DiceBag to generate your own pre-packaged templates when you run the rake "config:generate_all" task, you can create a plug-in. Read the templates.md file to learn how to do this.

Contributors

dice_bag's People

Contributors

jcarres-mdsol avatar asmith-mdsol avatar lgreene-mdsol avatar clabrunda avatar honoredb avatar dhoizner 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.