www.SmarteGuru.com
  Home | Blogs | Recipe | Find a Friend | Discussion Board | Resources | Developers Area | Articles | Health |  Login | Register Now 

server_config: Ruby on rails plugin for sensitive configuration

A simple plugin to help separate sensitive configuration such as server passwords from your Rails source code.

Repository: git://github.com/peter/server_config.git

Example

Server parameters are configured in a config/server.rb file:

ServerConfig.configure do |c|
c.param :name => :db_password, :value => "my_db_password",
:files => ["vendor/plugins/server_config/spec/files/spec_database.yml.example"]
c.param :name => :payex_merchant_key, :value => “the_merchant_key”,
:files => ["vendor/plugins/server_config/spec/files/merchant.yml"]
c.param :name => :smtp_password, :value => “my_smtp_password”
end

If you provide the :files option then any occurence of the “param_name” (i.e. db_password) in those files will be replaced with the param value when you run the rake task server_config:write. If the extension of the file is .example then the result will be written to a file with the same path but without the .example extension. If the file does not have the .example extension then replacements are made inline.

Server parameters can be accessed via the global server_param(:param_name) method.

In your Capistrano deploy.rb you might want to do something like this:

desc "Copy in server specific configuration files"
task :setup_config do
run <<-END
cp #{shared_path}/server.rb #{release_path}/config &&
cd #{release_path} && rake server_config:write
END
end
task :before_symlink, :roles => :app do
setup_config
end

Social Bookmarks: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Reddit
  • Webnews
  • Y!GG
  • Google Bookmarks
  • SEOigg
  • YahooMyWeb
  • Live-MSN
  • DZone
  • Facebook
  • Technorati
  • Ask
  • Furl
  • Spurl
  • Webbrille

Related Posts

Tags: , , , ,

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Viewed: 218 views

Leave a Reply

Twitter Users!
Enter your personal information in the form or sign in with your Twitter account by clicking the button below.

Home - About Us - Help - Terms and Conditions - Site Map - Link to Us - Resources - Contact Us
Google Rank Calculator | Suggest developer resource | Suggest Article
All rights reserved © 2007 SmarteGuru.com.