File        : README.md
Maintainer  : Felix C. Stegerman <[email protected]>
Date        : 2014-10-30

Copyright   : Copyright (C) 2014  Felix C. Stegerman
Version     : v0.3.3

Gem Version

Description

[rb-]localconfig - local configuration for ruby (web) apps

localconfig makes it easy to load (additional) configuration files from ~/.apps/<name>, where name is determined by the current directory. You can easily require ruby files and load json and yaml files from this directory.

Additionally, it allows rails applications to easily define admin:exists and admin:create rake tasks to make it easier to automate application setup.

Just about everything is configurable: see the docs.

For an example w/ rails, see https://github.com/obfusk/localconfig-rails-example.

Examples

Rails

# Gemfile
gem 'localconfig', require: 'localconfig/rails'
# config/localconfig.rb
LocalConfig['rails'].configure do |c|
  puts "env: #{c.env}, #{Rails.env}"

  c.require 'init.rb'

  c.load_json 'pg.json'
  puts c.pg.username

  c.load_yaml 'foo/bar/baz.json'
  puts c.foo.bar.baz.some_value

  c.load_yaml 'git.yml'   # repo:, branch:
  c.git_repo 'more', c.git.repo, branch: c.git.branch
  c.load_dir 'more'       # more/foo.yml, more/bar.json
  puts "more: #{c.more.foo.key1} #{c.more.bar.key2}"

  c.on_admin_exists do |username|
    # ...
  end
  c.on_admin_create do |username, password, email|
    # ...
  end
end

Standalone

require 'localconfig'   # loads config/localconfig.rb

or:

require 'localconfig/config'
LocalConfig['foo'].configure do |c|
  # ...
end

Rake

require 'localconfig'
ManifestDL::Rake.define_tasks

Specs & Docs

rake spec
rake coverage
rake docs

TODO

  • more specs/docs?
  • ...

License

LGPLv3+ [1].

References

[1] GNU Lesser General Public License, version 3 --- http://www.gnu.org/licenses/lgpl-3.0.html