laserlemon / figaro

Simple Rails app configuration
MIT License
3.76k stars 288 forks source link

Herarchical structure #278

Open mbaev opened 5 years ago

mbaev commented 5 years ago

I :heart: Figaro!

I not found any proposals on this. Is it possible to introduce herarchical structure? Currently we in able to make linear list of settings/variables (excepting environments).

I think it will be helpful to be able to avoid repeating for some settings like:

database_host: localhost
database_name: postgrdb
database_user: postgrusr
database_pass: 111

# or

deploy_user: root
deploy_port: 2121
deploy_server: example.com
deploy_dir: /var/www/domain
deploy_branch: master

It might be look like this:

database:
  host: localhost
  name: postgrdb
  user: postgrusr
  pass: 111

# or

deploy:
  user: root
  port: 2121
  server: example.com
  dir: /var/www/domain
  branch: master

This is only for definition things. I think it's need to be merged into single string variables as well as previously: deploy_user (although it may be available and by the new way)

In this case the first level keywords like development, production or test can work as previously - to define environment.

production:
  database:
    user: prod_user
    pass: prod_pass

This feature will especially helpful for some developers who uses variables prefixed with an app name, like:

app_database_name: db_name
# ...etc.

Thank you! :smile: