GithubHelp home page GithubHelp logo

app_config's Introduction

Copyright (c) 2006 Daniel Owsianski  (daniel-at-jarmark-d0t-org)
Changes by Nate Walker 2008 (kiwinewt-at-gmail-d0t-com)

Rails framework default configuration way is, as we all know,
flexible and simple at the same time. Troubles begins when Your
application starts to grow - some form of app specific configuration
is then required to keep all as DRY as possible.

AppConfig plugin provides a convenient way for configuration
application wide settings. Extra custom files in config/ or other
unusual configuration hacks are no longer needed. AppConfig extends
Rails configuration process in a way that allows to setup application
specific options within default configuration block.

== Installation:
You can install directly from the repository:

  $ script/plugin install git://github.com/kiwinewt/app_config.git

Note: This plugin was originally obtained from:
	$ http://svn.jarmark.org/rails/app_config

*NOTE*: because AppConfig modifies Rails configuration internals,
must be included *before* Rails::Initializer#run.
If You are using Rails v1.1+ this step is taken *automatically* during
installation. Otherwise add the following line to conf/environment.rb file:
	require 'plugins/app_config/lib/configuration'
(somewhere between line 'require File.join(File.dirname(__FILE__), 'boot')
and 'Rails::Initializer.run')

== Usage
You can specify app-wide settings in configuration file(s)
using 'app_config' prefix e.g. environment.rb:
	Rails::Initializer.run do |config|
	...
	   # --- My killer-app specific settings:
	   config.app_config.my_key = 'my value'
	   config.app_config.boot_time = Time.now
	   config.app_config.default_mail_subject = '[appconfig] '
	   config.app_config.my_hash = {:a=>1, :b=>2}
	...

but also in e.g. environment/development.rb
	...
	config.app_config.default_message = "I'm now in development mode..."
	...

Access to previously configured settings from within application
code is also dead easy:

	AppConfig.my_key
	AppConfig[:my_key]
	AppConfig['my_key']
	AppConfig.param('my_key')
	AppConfig.param(:my_key)
	AppConfig.param('my_key', 'value if my_key is nil')
	AppConfig.param(:my_key)do
	 ... #executed when my_key is nil
	end
	
 safe parameter testing
   AppConfig.has_param?(:mail_from_address)
   AppConfig.has_param?('mail_from_address')

Happy (re)configurations!

Author:: Daniel Owsianski, (daniel-at-jarmark-d0t-org)
Author:: Nate Walker 2008 (kiwinewt-at-gmail-d0t-com)
Version:: 0.1
Home page:: http://github.com/kiwinewt/app_config/tree
License::  Copyright (c) 2006 Daniel Owsiañski.
           Released under MIT-LICENCE (included).

app_config's People

Contributors

alexpankov avatar dosire avatar kiwinewt avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  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.