class Acclimate::Env

Attributes

sources[R]

Public Class Methods

new( sources ) click to toggle source
# File lib/acclimate/env.rb, line 6
def initialize( sources )
  @sources = sources.map { |s| Pathname.new( s ) }
end

Public Instance Methods

load() click to toggle source
# File lib/acclimate/env.rb, line 10
def load
  sources.each do |source|
    source_env_from( source.expand_path )
  end
end

Protected Instance Methods

bash_env( cmd=nil ) click to toggle source
# File lib/acclimate/env.rb, line 20
def bash_env( cmd=nil )
  env = `#{cmd + ';' if cmd} printenv`
  env.split( /\n/ ).map { |l| l.split(/=/) }
end
bash_source( file ) click to toggle source
# File lib/acclimate/env.rb, line 25
def bash_source( file )
  Hash[bash_env(". #{File.realpath file}") - bash_env]
end
source_env_from( file ) click to toggle source
# File lib/acclimate/env.rb, line 29
def source_env_from( file )
  bash_source( file ).each { |k,v| ENV[k] = v }
end