class Etcenv::DotenvFile
Constants
- SHOULD_QUOTE
Attributes
env[R]
Public Class Methods
new(env)
click to toggle source
# File lib/etcenv/dotenv_file.rb, line 5 def initialize(env) @env = env end
Public Instance Methods
lines()
click to toggle source
# File lib/etcenv/dotenv_file.rb, line 11 def lines env.map { |k, v| make_dotenv_line(k, v) } end
to_s()
click to toggle source
# File lib/etcenv/dotenv_file.rb, line 15 def to_s lines.join(?\n) + ?\n end
Private Instance Methods
make_dotenv_line(k,v)
click to toggle source
# File lib/etcenv/dotenv_file.rb, line 22 def make_dotenv_line(k,v) if v.match(SHOULD_QUOTE) v.gsub!('"', '\"') v.gsub!(/\r?\n/, '\n') v.gsub!(/\$([^(])/, '\$\1') "#{k}=\"#{v}\"" else "#{k}=#{v}" end end