Class: DotenvUtil

Inherits:
Object
  • Object
show all
Defined in:
lib/dotenv_util.rb

Overview

Provides Generic support for manipulating Dotenv files

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env_file) ⇒ DotenvUtil

Returns a new instance of DotenvUtil.



6
7
8
9
# File 'lib/dotenv_util.rb', line 6

def initialize(env_file)
  @env_text = env_file
  @env = parse_env_file
end

Instance Attribute Details

#envObject (readonly)

Returns the value of attribute env.



5
6
7
# File 'lib/dotenv_util.rb', line 5

def env
  @env
end

#env_textObject (readonly)

Returns the value of attribute env_text.



5
6
7
# File 'lib/dotenv_util.rb', line 5

def env_text
  @env_text
end

Instance Method Details

#generate_envObject



15
16
17
18
19
# File 'lib/dotenv_util.rb', line 15

def generate_env
  env.collect do |key, val|
    %(#{key}="#{val}")
  end.join("\n")
end

#set(target, value) ⇒ Object



11
12
13
# File 'lib/dotenv_util.rb', line 11

def set(target, value)
  env[target] = value
end