Sha256: 9032f402c1355c7c03f83f8ce57eee45777fb4e6205026b7fc41e561a7ac4a3c

Contents?: true

Size: 959 Bytes

Versions: 40

Compression:

Stored size: 959 Bytes

Contents

# frozen_string_literal: true

# encoding=utf-8

# utility functions to read environment variables
#
module Env
  # :reek:BooleanParameter
  # :reek:DataClump
  # :reek:NilCheck
  # :reek:UtilityFunction
  def env_bool(name, default: false)
    return default if name.nil? || (val = ENV.fetch(name, nil)).nil?
    return false if val.empty? || val == '0'

    true
  end

  # :reek:UtilityFunction
  def env_bool_false(name)
    !(val = (name && ENV.fetch(name, nil))).nil? && !(val.empty? || val == '0')
  end

  # skip :reek:DataClump
  # skip :reek:NilCheck
  # skip :reek:UtilityFunction
  def env_int(name, default: 0)
    return default if name.nil? || (val = ENV.fetch(name, nil)).nil?
    return default if val.empty?

    val.to_i
  end

  # skip :reek:DataClump
  # skip :reek:NilCheck
  # skip :reek:UtilityFunction
  def env_str(name, default: '')
    return default if name.nil? || (val = ENV.fetch(name, nil)).nil?

    val || default
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
markdown_exec-2.3.0 lib/env.rb
markdown_exec-2.2.0 lib/env.rb
markdown_exec-2.1.0 lib/env.rb
markdown_exec-2.0.8.4 lib/env.rb
markdown_exec-2.0.8.3 lib/env.rb
markdown_exec-2.0.8.2 lib/env.rb
markdown_exec-2.0.8.1 lib/env.rb
markdown_exec-2.0.8 lib/env.rb
markdown_exec-2.0.7 lib/env.rb
markdown_exec-2.0.6 lib/env.rb
markdown_exec-2.0.5 lib/env.rb
markdown_exec-2.0.4 lib/env.rb
markdown_exec-2.0.3.2 lib/env.rb
markdown_exec-2.0.3.1 lib/env.rb
markdown_exec-2.0.3 lib/env.rb
markdown_exec-2.0.2 lib/env.rb
markdown_exec-2.0.1 lib/env.rb
markdown_exec-2.0.0 lib/env.rb
markdown_exec-1.8.9 lib/env.rb
markdown_exec-1.8.8 lib/env.rb