skyfallsin / simple_settings

A simple Settings object for Rails/Merb/Ruby apps

Home Page:http://github.com/skyfallsin/simple_settings

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Simple Settings

This gem exposes a Settings object for your Rails/Merb/Ruby apps. Attempts to load up “config/settings.yml” based on RAILS_ROOT or MERB_ROOT. Otherwise, tries to load “settings.yml” You can also assign variables on runtime if you choose to.

Example

require 'rubygems'
require 'simple_settings'

# ----------------
Settings.drb_server = "mydrb.com"

puts Settings[:drb_server]
#=> "mydrb.com"
puts Settings.drb_server
#=> "mydrb.com"

# ----------------
Settings.xmpp = {:server => "localhost", :port => 5280}

puts Settings.xmpp.server
#=> "localhost"
puts Settings[:xmpp][:port]
#=> 5280

Example settings.yml

my_settings: &my_settings
  xmpp:
    server: localhost
    port: 5280

  drb_server:
    server: 'mydrb.com'
    port: 9090

development:
  <<: *my_settings

testing:
  <<: *my_settings

production:
  <<: *my_settings
  xmpp:
    server: 'myxmpp.com'
    port: 80

Acknowledgements

Michael Bleigh, for his awesome Mash gem.

About

A simple Settings object for Rails/Merb/Ruby apps

http://github.com/skyfallsin/simple_settings

License:MIT License


Languages

Language:Ruby 100.0%