Class: Provisionator::Environment
- Inherits:
-
Object
- Object
- Provisionator::Environment
- Defined in:
- lib/provisionator/environment.rb
Class Method Summary collapse
Class Method Details
.load(filename) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/provisionator/environment.rb', line 3 def self.load filename File.read(filename).split("\n").each do |line| if line =~ /\A(?:export\s+)?(\w+)(?:=|: ?)(.*)\z/ key = $1 case val = $2 # Remove single quotes when /\A'(.*)'\z/ then ENV[key] = $1 # Remove double quotes and unescape string preserving newline characters when /\A"(.*)"\z/ then ENV[key] = $1.gsub('\n', "\n").gsub(/\\(.)/, '\1') else ENV[key] = val end end end end |