Check bool environment variables are "1" or "true"

This commit is contained in:
Alex Ling
2020-12-26 07:11:10 +00:00
parent 8931ba8c43
commit 7a7cb78f82
2 changed files with 7 additions and 3 deletions

View File

@@ -61,3 +61,9 @@ class String
self.chars.all? { |c| c.alphanumeric? || c == '_' }
end
end
def env_is_true?(key : String) : Bool
val = ENV[key.upcase]? || ENV[key.downcase]?
return false unless val
val.downcase.in? "1", "true"
end