Module: EasyConf
- Defined in:
- lib/easy_conf.rb,
lib/easy_conf/version.rb,
lib/easy_conf/app_config.rb,
lib/easy_conf/configuration.rb,
lib/easy_conf/errors/config_not_found_error.rb,
lib/easy_conf/errors/unpermitted_config_error.rb,
lib/easy_conf/errors/config_file_not_found_error.rb
Defined Under Namespace
Classes: AppConfig, ConfigFileNotFoundError, ConfigNotFoundError, Configuration, UnpermittedConfigError
Constant Summary collapse
- VERSION =
"0.2.0"
Class Method Summary collapse
-
.app_config ⇒ Object
Returns all configurations of your applications.
-
.configuration ⇒ Object
:nodoc.
-
.configure {|configuration| ... } ⇒ Object
Configures the EasyConf gem for the following keys;.
-
.keys ⇒ Object
Read Application config keys.
-
.read(key) ⇒ Object
(also: get)
Read Application configuration by sending key as argument.
-
.to_hash ⇒ Object
Get application configs as Hash.
Class Method Details
.app_config ⇒ Object
23 24 25 |
# File 'lib/easy_conf.rb', line 23 def app_config @config ||= AppConfig.new end |
.configuration ⇒ Object
:nodoc
83 84 85 |
# File 'lib/easy_conf.rb', line 83 def configuration # :nodoc @configuration ||= Configuration.new end |
.configure {|configuration| ... } ⇒ Object
Configures the EasyConf gem for the following keys;
config_files : Required! List of configuration files to be used. inform_with : Optional. Information method used in case of error.
Whether sliently puts log or raises exception.
white_list_keys : Optional. List of config keys to be used.
If this configuration is set, config keys
which are not in this list won't be
accessible through EasyConf!
black_list_keys : Optional! List of config keys to be ignored.
If this configuration is set, config keys
which are in this list won't be accessible
through EasyConf!
environment : Optional. Specifies environment scope. For Rails
applications, the value is same with Rails.
Example:
EasyConf.configure do |config|
config.config_files = [config.yml]
config.white_list_keys = ['access_key', 'secret_key', ...]
config.black_list_keys = ['black_key', ...]
end
78 79 80 81 |
# File 'lib/easy_conf.rb', line 78 def configure yield(configuration) app_config # initialize config end |
.keys ⇒ Object
42 43 44 |
# File 'lib/easy_conf.rb', line 42 def keys app_config.__keys end |
.read(key) ⇒ Object Also known as: get
Read Application configuration by sending key as argument.
Example:
EasyConf.read(:access_key) # => "some_key"
32 33 34 |
# File 'lib/easy_conf.rb', line 32 def read(key) app_config.send(key.to_s) end |
.to_hash ⇒ Object
51 52 53 |
# File 'lib/easy_conf.rb', line 51 def to_hash app_config.__to_hash end |