0.01
No commit activity in last 3 years
No release in over 3 years
A Simple way to get configs.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

Configureasy

Build Status Coverage Status Inline docs Code Climate

Configureasy is a library for load configs quickly and easily.

Installation

Add this line to your application's Gemfile:

gem 'configureasy'

And then execute:

$ bundle

Or install it yourself as:

$ gem install configureasy

Usage

Load content of config/database.yml

# in ./config/database.yml
# host: localhost
# port: 1234

class DBConfig
  include Configureasy
  load_config :database
end

# You can access config values
DBConfig.database.host # => 'localhost'
DBConfig.database.port # => 1234

Setting different method name

# in ./config/user_keys.yml
# name: secret_key
# value: secret_key_value

class User
  include Configureasy
  load_config :user_keys, as: :keys
end

User.keys.name # => 'secret_key'
User.keys.value # => 'secret_key_value'

Setting different folder

class Censor
  include Configureasy
  load_config :forbidden_words, path: './blacklist'
  # load './blacklist/forbidden_words.yml'
end

Configureasy detect per environment configs

# in ./config/aws.yml
# development:
#   access: development_access
#   secret: development_secret
# production:
#   access: production_access
#   secret: production_secret

class S3Storage
  include Configureasy
  load_config :aws
end

# in development
S3Storage.aws.access # => 'development_access'

# in production
S3Storage.aws.access # => 'production_access'

You can access config data as Hash

# in ./config/access.yml
# admin_group: 1
# user_group: 2

class User
  require Configureasy
  load_config :access
end

User.access.as_hash
# => {'admin_group' => '1', 'user_group' => '2'}

Contributing

  1. Fork it ( https://github.com/alexandreprates/configureasy/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request