Skip to content

Commit

Permalink
Downcase boolean strings when comparing boolean env types (#53)
Browse files Browse the repository at this point in the history
* Downcase boolean strings when comparing boolean env types

Allows for configuration such as `True` or `TRUE`

* PR Feedback
  • Loading branch information
JoeSouthan authored Jan 9, 2024
1 parent b5b29da commit 3cc4af0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- Drop support for Ruby 2.6 and 2.7.
- Add support for Ruby 3.2 and 3.3.
- Downcase boolean values when checking for truthiness.

# 5.0.0

Expand Down
2 changes: 2 additions & 0 deletions lib/prius/registry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ def load_int(name, required)
def load_bool(name, required)
value = load_string(name, required)
return nil if value.nil?

value = value.downcase
return true if %w[yes y true t 1].include?(value)
return false if %w[no n false f 0].include?(value)

Expand Down
2 changes: 1 addition & 1 deletion spec/prius/registry_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{
"NAME" => "Harry",
"AGE" => "25",
"ALIVE" => "yes",
"ALIVE" => "Yes",
"BORN" => "2022-09-02",
"INVALID_DATE" => "2022-02-99",
}
Expand Down

0 comments on commit 3cc4af0

Please sign in to comment.