class DotenvUtil
Provides Generic support for manipulating Dotenv files
Constants
- LINE
Retrieved from github.com/bkeepers/dotenv/blob/master/lib/dotenv/parser.rb
Attributes
env[R]
env_text[R]
Public Class Methods
new(env_file)
click to toggle source
# File lib/dotenv_util.rb, line 26 def initialize(env_file) @env_text = env_file @env = parse_env_file end
Public Instance Methods
generate_env()
click to toggle source
# File lib/dotenv_util.rb, line 35 def generate_env env.collect do |key, val| val = %("#{val}") if val =~ /\s/ "#{key}=#{val}" end.join("\n") end
set(target, value)
click to toggle source
# File lib/dotenv_util.rb, line 31 def set(target, value) env[target] = value end
Private Instance Methods
parse_env_file()
click to toggle source
# File lib/dotenv_util.rb, line 44 def parse_env_file env_text.split.each_with_object({}) do |line, hash| match = line.match(LINE) next unless match hash.store(*match.captures) hash end end