palkan / anyway_config

Configuration library for Ruby gems and applications
MIT License
778 stars 52 forks source link

docs: clarify type coercion rules in README #135

Closed fvsch closed 1 year ago

fvsch commented 1 year ago

What is the purpose of this pull request?

Small documentation change in README.md.

I was looking up the rules for type autocasting, and it was unclear to me if the list "True", "t" and "yes" with a capital T meant that the value True had to use this exact case.

Looking at the code:

https://github.com/palkan/anyway_config/blob/d54f2caf2a9efb0ec4e9a7b095a2e48dcf908ba0/lib/anyway/auto_cast.rb#L19-L24

It looks like values are matched case-insensitively, so both "True" and "true" would work. And it looks like the value "y" is matched as true, which wasn't documented.

What changes did you make? (overview)

  1. Add missing values: make sure that the values "y" (coerced to true) and "n" (coerced to false) are listed.
  2. Try to clarify case-insensitivity: list all values in lower-case (instead of a mix of lowercase and title case), and add a note that matching is case-insensitive.

Is there anything you'd like reviewers to focus on?

Feel free to edit any of my changes. I'm not 100% happy with the way the case-sensitivity note reads, but I figured it might be better to have this note rather than not have that information.

Checklist