public
Description: Simple Ruby framework-agnostic application configuration.
Homepage: http://oshuma.github.com/app_config/
Clone URL: git://github.com/Oshuma/app_config.git
name age message
file .gitignore Sun Oct 25 21:16:16 -0700 2009 fixing gemspec [Oshuma]
file README Sun Oct 25 21:11:13 -0700 2009 a few minor things [Oshuma]
file Rakefile Sat Mar 14 22:43:59 -0700 2009 splitting the Rakefile up [Dale Campbell]
file app_config.gemspec Sun Oct 25 21:57:52 -0700 2009 fixing gemspec date [Oshuma]
directory doc/ Wed Mar 11 14:03:49 -0700 2009 documentation [Dale Campbell]
directory lib/ Sun Oct 25 21:11:23 -0700 2009 v0.4.1 [Oshuma]
directory spec/ Sun Oct 25 21:11:13 -0700 2009 a few minor things [Oshuma]
directory tasks/ Sun Sep 27 22:24:40 -0700 2009 cleaning up rake tasks [Oshuma]
README
= AppConfig

An easy to use, customizable library to easily store and retrieve application
(or library) configuration, API keys or basically anything in 'key/value' pairs.


== Usage

Usage is simple.  Just pass either a hash of options, or a block, to
AppConfig.setup.  See AppConfig::Base for a list of valid storage methods.

As of version 0.4.1, if the <tt>:storage_method</tt> is not set, AppConfig
will act pretty much just like a normal Hash:

  AppConfig.setup(:email => 'admin@example.com')
  AppConfig[:email]    # => 'admin@example.com'


== AppConfig::Storage::YAML

Given this YAML file:

  ---
  admin_email: 'admin@example.com'
  api_name:    'Supr Webz 2.0'
  api_key:     'SUPERAWESOMESERVICE'

Use it like so:

  require 'app_config'

  AppConfig.setup do |config|
    config[:storage_method] = :yaml
    config[:path] = '/path/to/app_config.yml'
    # ..or..
    config[:uri] = 'yaml://path/to/app_config.yml'
  end

  # Later on...
  # Strings or symbols as keys.
  AppConfig['admin_email'] # => 'admin@example.com'
  AppConfig[:api_name]     # => 'Supr Webz 2.0'
  AppConfig[:api_key]      # => 'SUPERAWESOMESERVICE'


== AppConfig::Storage::Sqlite

  AppConfig.setup do |config|
    config[:storage_method] = :sqlite
    config[:table] = 'app_config' # defaults to 'app_config'

    config[:database] = '/path/to/database.sqlite3'
    # ..or..
    config[:uri] = 'sqlite://path/to/database.sqlite3'
  end

  AppConfig[:column]  # => 'value'


== Environment Mode

As of version 0.4.0, there's an 'environment mode' where you can organize
the config file sort of like Rails' database config.

  # config/app_config.yml
  development:
    title: 'Development Mode'

  production:
    title: 'Production Mode'

Then set the <tt>:env</tt> option to your desired environment.

  AppConfig.setup do |config|
    config[:env] = Rails.env  # or any string.
    config[:uri] = 'yaml://path/to/app_config.yml'
  end

  # Uses the given environment section of the config.
  AppConfig[:title] = 'Production Mode'