forked from getsentry/sentry-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add support for $SENTRY_DEBUG and $SENTRY_SPOTLIGHT
Part of getsentry/spotlight#482. Similar to sentry-python#3443 but it also adds support for `$SENTRY_DEBUG` which was lacking in the Ruby SDK.
- Loading branch information
Burak Yigit Kaya
committed
Aug 15, 2024
1 parent
fa0973a
commit a9334bf
Showing
2 changed files
with
29 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# frozen_string_literal: true | ||
|
||
module Sentry | ||
module EnvHelper | ||
TRUTHY_ENV_VALUES = %w(t true yes y 1 on).freeze | ||
FALSY_ENV_VALUES = %w(f false no n 0 off).freeze | ||
|
||
def env_to_bool(value, strict=false) | ||
value = value.to_s | ||
normalized = value.downcase | ||
|
||
if FALSY_ENV_VALUES.include?(normalized) | ||
return false | ||
end | ||
|
||
if TRUTHY_ENV_VALUES.include?(normalized) | ||
return true | ||
end | ||
|
||
return strict ? nil : !(value.nil? || value.empty?) | ||
end | ||
end | ||
end |