config icon indicating copy to clipboard operation
config copied to clipboard

Allow symbol value via ENV

Open manjunath724 opened this issue 4 years ago • 1 comments

This PR converts string starting with : to symbol. Allows symbol value via ENV.

Config::Options when overriding settings via ENV variables is enabled and parsing ENV variable values is enabled should recognize strings starting with : as symbols.

But strings starting with :: will be left intact.

Ex:

# Given the following environment:
SETTINGS__SECTION__SERVER_TYPE=:remote
SETTINGS__SECTION__SERVER_ACCESS=::ENABLED
# The following settings will be available:
Settings.section.server_type # => :remote
Settings.section.server_access # => '::ENABLED'

String#strip is used for removing whitespace characters from string inputs, such as: ' :remote ', ' : ', ' : remote '

.gsub is used to replace characters with the help of regex pattern match

.tr to covert to snakecase

.downcase to transform uppercase letters to lowercase

Ref: https://github.com/rubyconfig/config/issues/286

manjunath724 avatar Oct 06 '21 17:10 manjunath724

The tests have passed, can the PR be reviewed?

manjunath724 avatar Oct 12 '21 17:10 manjunath724

Closing because this is stale. I'm open to the idea, but the particular implementation here needs some work.

cjlarose avatar Mar 02 '24 01:03 cjlarose