Module: MetrifoxSDK::UtilMethods

Included in:
Client
Defined in:
lib/metrifox_sdk/util_methods.rb

Class Method Summary collapse

Class Method Details

.load_dotenvObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/metrifox_sdk/util_methods.rb', line 3

def self.load_dotenv
  return if @dotenv_loaded

  env_files = ['.env.local', '.env']
  env_files.each do |file|
    next unless File.exist?(file)

    File.readlines(file).each do |line|
      line = line.strip
      next if line.empty? || line.start_with?('#')

      key, value = line.split('=', 2)
      next unless key && value

      # Remove quotes if present
      value = value.gsub(/\A['"]|['"]\z/, '')

      # Only set if not already set (allows override)
      ENV[key] ||= value
    end
    break # Use first found file
  end

  @dotenv_loaded = true
end