Module: Vx::Common::EnvFile

Defined in:
lib/vx/common/env_file.rb

Instance Method Summary collapse

Instance Method Details

#read_env_file(file = nil) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/vx/common/env_file.rb', line 5

def read_env_file(file = nil)
  file ||= '/etc/vexor/ci'
  file = File.expand_path(file)

  if File.readable?(file)
    buf  = File.read(file)

    buf.split("\n").each do |line|
      next if line.strip.empty?

      env, value = line.split("=").map(&:strip)
      ::ENV[env] = value
    end
  end

end