Skip to content

Easy config, Rails and Rack application's configuration made easy.

Notifications You must be signed in to change notification settings

felipecvo/easy_config

Repository files navigation

Easy config

Gem Version Build Status Code Climate Test Coverage Dependency Status

Rails and Rack applications configuration made easy.

Install

gem install easy_config

or in your Gemfile

gem "easy_config"

Usage

Rails/Sinatra

Inside config dir, create a file redis.yml:

development:
  host: 127.0.0.1
  port: 6379
  password:
production:
  host: 172.0.0.1
  port: 6379
  password: "alpha"

In your ruby code, you do:

  Redis.current = Redis.new({
    host: EasyConfig.redis.host,
    port: EasyConfig.redis.port,
    password: EasyConfig.redis.password
  })

Custom config paths

You can provide additional custom config paths.

Config file at vendor/config/sample.yml:

development:
  property: "value"

Code:

  EasyConfig.append_config_path Rails.root.join('vendor/config')
  puts EasyConfig.sample.property

Output will be: "value"

Environment Variables

  # ENV['APP_API_KEY'] = '1234567890'
  puts EasyConfig.app.api_key

How it works

EasyConfig allows you to access your config files easily. All you have to do is to put your files in config dir and be a valid YAML file (with .yml as extension).

If you desire you can split your configurations by environment. Easy config treats it automatically.

Supported rubies

  • 2.1
  • 2.0
  • 1.9.3
  • ree (will be dropped after 1.0)

License

The MIT License

Copyright (c) 2012-2014 Felipe Oliveira <http://felipecvo.github.io/>

About

Easy config, Rails and Rack application's configuration made easy.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages