Sha256: 6af81766162ebe5a9713206588319c81b8938e5483c8eee1862e52100dc91a33

Contents?: true

Size: 512 Bytes

Versions: 12

Compression:

Stored size: 512 Bytes

Contents

# 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

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
sentry-ruby-core-5.22.2 lib/sentry/utils/env_helper.rb
sentry-ruby-5.22.2 lib/sentry/utils/env_helper.rb
sentry-ruby-core-5.22.1 lib/sentry/utils/env_helper.rb
sentry-ruby-5.22.1 lib/sentry/utils/env_helper.rb
sentry-ruby-5.22.0 lib/sentry/utils/env_helper.rb
sentry-ruby-core-5.22.0 lib/sentry/utils/env_helper.rb
sentry-ruby-5.21.0 lib/sentry/utils/env_helper.rb
sentry-ruby-core-5.21.0 lib/sentry/utils/env_helper.rb
sentry-ruby-5.20.1 lib/sentry/utils/env_helper.rb
sentry-ruby-core-5.20.1 lib/sentry/utils/env_helper.rb
sentry-ruby-5.20.0 lib/sentry/utils/env_helper.rb
sentry-ruby-core-5.20.0 lib/sentry/utils/env_helper.rb