File: env_helper.rb

package info (click to toggle)
ruby-sentry-ruby-core 5.28.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 672 kB
  • sloc: ruby: 6,118; makefile: 8; sh: 4
file content (21 lines) | stat: -rw-r--r-- 512 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# frozen_string_literal: true

module Sentry
  module Utils
    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 self.env_to_bool(value, strict: false)
        value = value.to_s
        normalized = value.downcase

        return false if FALSY_ENV_VALUES.include?(normalized)

        return true if TRUTHY_ENV_VALUES.include?(normalized)

        strict ? nil : !(value.nil? || value.empty?)
      end
    end
  end
end